In my python project, I use poetry version 1.7.0 and have a pyproject.toml
containing
[tool.poetry.dependencies]
python = "^3.11"
dogpile-cache = {extras = ["redis"], version = "^1.2.2"}
redis = "^4.5.5"
...
[tool.poetry.group.dev.dependencies]
deptry = "^0.12.0"
....
The rest of the content should be irrelevant, but note there is no [tool.poetry.extras]
section.
I install dependencies via poetry install
, respectively poetry install --withou dev
for production.
When I execute deptry .
, it reports redis
dependency as unused. There is no direct import of redis in my project code, but it is still required by dogpile-cache
. If I remove the explicit dependency, my application stops working.
I did read up on poetry extras, but to my understanding they should not be used here, because they should describe optional extended functionality of my project and not extras of dependencies I want to use.
How to solve the situation? Do I need to change some deptry config to have the tool stop reporting those repositories? Or do I need to adjust my pyproject.toml and the way I install dependencies with poetry?
You can add configuration to your pyproject.toml
to ignore the error for that specific package, see here.
In your case, add the following to your pyproject.toml
:
[tool.deptry.per_rule_ignores]
DEP002 = ["redis"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With