Closed fpgmaas closed 6 months ago
The above would lead me to the following solution;
[project.optional-dependencies]
are development dependencies.--requirements-txt-dev
is specified, don't look for development dependencies in the tool itself, but parse them from that/those files.This would be a great enhancement, my current solution is to comment out my dev and test dependencies before running deptry. What do you think about something like this?
[project.optional-dependencies]
pdf = ["pdf"]
dev = ["deptry"]
test = ["pytest"]
[tool.deptry]
# Exclude test + dev dependencies, include pdf
exclude-optional = ["dev", "test"]
I would love to see a feature like this in deptry. This is the only blocker that stops me from using this great tool in my project workflows.
While this issue is unresolved, I have the following in my linting setup (requires uv
):
uv pip compile --no-deps pyproject.toml > $(TEMPFILE)
mv pyproject.toml pyproject.bak.toml
deptry --requirements-txt=$(TEMPFILE) src/ || (mv pyproject.bak.toml pyproject.toml && exit 1)
mv pyproject.bak.toml pyproject.toml
I started implementing a flag to allow users to specify which groups under [project.optional-dependencies]
should be considered development dependencies. First draft PR here: https://github.com/fpgmaas/deptry/pull/628/files
It proposes to add a flag called --pep621-dev-dependency-groups
.
Inspired by this comment of @mkniewallner
https://github.com/fpgmaas/deptry/issues/162 proposes to add support for PEP-621. However PEP-621 does not provide any standards for dealing with development dependencies. Currently,
deptry
has no implemented method to extract development dependencies for such a project.AFAIK, there are now two main methods of specifying development dependencies for these projects:
[project.optional-dependencies]
inpyproject.toml
. A drawback of this approach is that this adds an installation option to end-users, e.g.pip install package[dev]
, which may be undesirable.pyproject.toml
, for example in a separatedev-requirements.txt
My initial proposal was to add a CLI command that allows the user to specify which entries under
[project.optional-dependencies]
are development dependencies, e.g.I think we should implement this regardless of if we provide more flexibility. But this only supports (1) from the above listed ways to specify development dependencies. We might want to provide end-users with more flexibility regarding the detection of development dependencies than we currently support.
On the other hand, we should balance between flexibility and overengineering. I do think additional flexibility only is needed for projects that uses PEP-621 (for now), since for the other projects it's quite straightforward. Below a table of all reasonable combinations I think can occur.