Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace --ignore-* flags with select (and optionally ignore.) #398

Closed
fpgmaas opened this issue May 15, 2023 · 2 comments · Fixed by #402
Closed

Replace --ignore-* flags with select (and optionally ignore.) #398

fpgmaas opened this issue May 15, 2023 · 2 comments · Fixed by #402
Labels
enhancement New feature or request

Comments

@fpgmaas
Copy link
Owner

fpgmaas commented May 15, 2023

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

@fpgmaas fpgmaas added the enhancement New feature or request label May 15, 2023
@fpgmaas fpgmaas changed the title Replace --ignore-* flags with select and ignore. Replace --ignore-* flags with select (and optionally ignore.) May 15, 2023
@fpgmaas fpgmaas mentioned this issue May 15, 2023
9 tasks
@fpgmaas fpgmaas linked a pull request May 15, 2023 that will close this issue
9 tasks
@mkniewallner
Copy link
Collaborator

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.

@fpgmaas
Copy link
Owner Author

fpgmaas commented May 17, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants