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

Additional comment to noqa added by ruff #10070

Open
ashrub-holvi opened this issue Feb 21, 2024 · 3 comments
Open

Additional comment to noqa added by ruff #10070

ashrub-holvi opened this issue Feb 21, 2024 · 3 comments
Labels
wish Not on the current roadmap; maybe in the future

Comments

@ashrub-holvi
Copy link

Hi!

Ruff can automatically add noqa directives, but they don't have any info about how they were added:

  # noqa: S308

and it may be difficult to distinguish intentionally/manually added noqa and those automatically added.

I think, main use case is migration to ruff for existing codebase without fixing everything at once, but it should be clear that those noqa added automatically and should be handled at some point, something like that:

  # noqa: S308 FIXME when you are here

Downside of it - adding longer comment will produce more formatting changes, so, perhaps

  # noqa: S308 auto

or even ruff may have some argument for provide the text of comment.

@kaddkaka
Copy link

Do you really want to # noqa them if you intend to fix them?

In our CI we have say 10000 ruff lint violations, and we accept if this number shrinks but fail if it ever increases.

@MichaReiser MichaReiser added the wish Not on the current roadmap; maybe in the future label Jan 24, 2025
@ashrub-holvi
Copy link
Author

Do you really want to # noqa them if you intend to fix them?

Yes, first of all it makes it much more visible - when you read the code you see that lines you are touching can be improved - ruff is working on file level, so linter can show issues in lines you are not intended to touch. Also, marking all existing issues as noqa really simplifies to see new issues, approach with number of errors also may work in average, but same time it might be you fixed two old, but introduced a new.
Something like #1149 may also be useful.

@kaddkaka
Copy link

Thanks now I understand the situation much better. For me #1149 would be a more valuable feature.

If you really want to do this it can be done using ruff+other tool.

Example on how to achieve this today with ruff+git+vim:

$ ruff check --add-noqa
$ git jump diff 
:cdo normal! A (added automatically by ruff) 

Perhaps this eliminates the feature need in ruff?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wish Not on the current roadmap; maybe in the future
Projects
None yet
Development

No branches or pull requests

3 participants