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

Add yesqa-style rule against unused ignores #728

Open
maresb opened this issue Jun 9, 2024 · 2 comments
Open

Add yesqa-style rule against unused ignores #728

maresb opened this issue Jun 9, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@maresb
Copy link

maresb commented Jun 9, 2024

Is your feature request related to a problem? Please describe.

It's good to ensure that the ignores remain up-to-date, in particular it would be nice to ensure that unnecessary ignores are deleted.

Describe the solution you would like

My favorite solution to this type of problem is yesqa or equivalently RUF100. In particular, I'd like a new rule, like maybe DEP005, that fails when there exists an ignore which was never triggered.

@mkniewallner
Copy link
Collaborator

That would be a great feature indeed!

Similarly to Ruff, since it's kind of a "meta" rule, maybe we could use DEP100 rather than DEP005? If we ever add new rules that are closer in behavior to the existing ones, I feel that having DEP006 after this one would feel quite weird for users.

@fpgmaas
Copy link
Owner

fpgmaas commented Jun 17, 2024

I made a quick start with this last week, in which I coincidentally called it DEP100, see here. My idea was to add an attribute to the violation finders;

modules_to_ignore: A tuple of module names to ignore when scanning for issues. Defaults to an
    empty tuple.
used_ignores: a list to keep track of which values in 'modules_to_ignore' were actually used. This list should
    be updated during the `find()` method, so that the set difference of `modules_to_ignore` and `used_ignores`
    results in a set of modules in `modules_to_ignore` that no longer need to be ignored.

I struggled a bit with coming up how to implement it in the reporter classes, since they rely on a location; but we do not know the location for these ignores, they can come from either the command line or from pyproject.toml. Needs some more thought.

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

No branches or pull requests

3 participants