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

[Autofix error] RUF100 noqa with additional comment #3623

Closed
araffin opened this issue Mar 20, 2023 · 3 comments
Closed

[Autofix error] RUF100 noqa with additional comment #3623

araffin opened this issue Mar 20, 2023 · 3 comments
Labels
suppression Related to supression of violations e.g. noqa

Comments

@araffin
Copy link

araffin commented Mar 20, 2023

Command: ruff --select RUF test.py --fix

Minimal code:

from torch import nn as nn  # noqa: F401 pylint: disable=unused-import

Ruff version: 0.0.257

Side question: what is the recommended way to deal with multiple "ignore"? (for instance noqa for ruff and type: ignore when using mypy)

@JonathanPlasse
Copy link
Contributor

JonathanPlasse commented Mar 20, 2023

You should separate the multiple "ignore" by # (c.f. https://til.simonwillison.net/python/ignore-both-flake8-and-mypy).
Like this # pylint: … will not be removed.

from torch import nn as nn  # noqa: F401 # pylint: disable=unused-import

A lot of tools need the # for it to work.

# Ruff does not detect the noqa on the following line
id: int = ""  # pyright: ignore noqa: A001
# Pyright does not detect the ignore on the following line
id: int = ""  # noqa: A001 pyright: ignore
# These work as expected
id: int = ""  # pyright: ignore # noqa: A001
id: int = ""  # noqa: A001 # pyright: ignore

@charliermarsh
Copy link
Member

This is fixed on main, I think (#3589).

@charliermarsh charliermarsh added the suppression Related to supression of violations e.g. noqa label Mar 20, 2023
@charliermarsh
Copy link
Member

(But yeah, using the extra hash will also fix it.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suppression Related to supression of violations e.g. noqa
Projects
None yet
Development

No branches or pull requests

3 participants