Replace `--ignore-*` flags with `select` (and optionally `ignore`.)
fpgmaas opened this issue · 2 comments
Currently, we use the flags:
--skip-unused Boolean flag to specify if deptry should
skip scanning the project for unused
dependencies.
--skip-missing Boolean flag to specify if deptry should
skip scanning the project for missing
dependencies.
--skip-transitive Boolean flag to specify if deptry should
skip scanning the project for transitive
dependencies.
--skip-misplaced-dev Boolean flag to specify if deptry should
skip scanning the project for development
dependencies that should be regular
dependencies.
With the addition of the new error codes, we might want to change this to ignore
(and optionally also select
). e.g.
deptry . --ignore "DEP001,DEP002"`
# or in pyproject.toml
ignore = ["DEP001", "DEP002"]
This would also imply changing
-iu, --ignore-unused TUPLE Comma-separated list of dependencies that
should never be marked as unused, even if
they are not imported in any of the files
scanned. For example; `deptry . --ignore-
unused foo,bar`.
-im, --ignore-missing TUPLE Comma-separated list of modules that should
never be marked as missing dependencies,
even if the matching package for the import
statement cannot be found. For example;
`deptry . --ignore-missing foo,bar`.
-it, --ignore-transitive TUPLE Comma-separated list of dependencies that
should never be marked as an issue due to it
being a transitive dependency, even though
deptry determines them to be transitive. For
example; `deptry . --ignore-transitive
foo,bar`.
to something that uses the error codes. Optionally, we could go for something like:
[tool.deptry]
ignore = ["DEP001"]
[tool.deptry.per_rule_ignores]
"DEP002" = ["matplotlib"]
Which implies that DEP001
should be skipped for all files, and DEP002
should only for the dependency matplotlib
.
Advantages
- More flexibility to add new checks. Right now, each check that we add would imply adding two new flags to the CLI arguments.
Disadvantages
ignore_unused = ["tomllib"]
is more intuitive than[tool.deptry.per_check_ignores]; "DEP002" = ["matplotlib"]
- This would introduce another breaking change, and we have another set of arguments to support until we deprecate them.
Questions
- Should we implement this change?
- Does the proposed implementation of the changes sound good?
- Is
tool.deptry.per_rule_ignores
a good name? See also #404
I'm rather in favour of this change, especially since it's in line with tools like flake8 and ruff which provide similar APIs.
Making such a big change makes me think that we could also implement #366 at the same time. This might require rethinking a bit the proposal, but it might come out as a more consistent experience overall, if we think about the overall picture from the start.
Thanks for the tip! I have commented an implementation proposal on #366 that builds on the changes proposed in this issue.
If we decide to go for that proposal, I think we could can merge this to master
in steps; i.e. review and merge #402, and then later add the proposed functionality to ignore per files.