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

# flake8: noqa top-of-the-file comment doesn't respect external config #10202

Closed
Avasam opened this issue Mar 2, 2024 · 1 comment · Fixed by #10203
Closed

# flake8: noqa top-of-the-file comment doesn't respect external config #10202

Avasam opened this issue Mar 2, 2024 · 1 comment · Fixed by #10203
Assignees
Labels
bug Something isn't working

Comments

@Avasam
Copy link
Contributor

Avasam commented Mar 2, 2024

The warning:
warning: Invalid rule code provided to # ruff: noqa at stubs\six\six\moves\builtins.pyi:1: NQA102

The Python file:

# flake8: noqa: NQA102 # https://github.com/plinss/flake8-noqa/issues/22
# six explicitly re-exports builtins. Normally this is something we'd want to avoid.
# But this is specifically a compatibility package.
from builtins import *  # noqa: UP029

The Ruff lint configs (I stripped out format configs):

[tool.ruff.lint]
# We still use flake8-pyi and flake8-noqa to check these (see .flake8 config file)
external = ["F821", "NQA", "Y"]
extend-select = [
    "B", # flake8-bugbear
    "FA", # flake8-future-annotations
    "I", # isort
    "RUF", # Ruff-specific and unused-noqa
    "UP", # pyupgrade
    # PYI: only enable rules that always autofix, avoids duplicate # noqa with flake8-pyi
    # See https://github.com/plinss/flake8-noqa/issues/22
    "PYI009", # use `...`, not `pass`, in empty class bodies
    "PYI010", # function bodies must be empty
    "PYI012", # class bodies must not contain `pass`
    "PYI013", # non-empty class bodies must not contain `...`
    "PYI016", # duplicate union member
    "PYI020", # quoted annotations are always unnecessary in stubs
    "PYI025", # always alias `collections.abc.Set` as `AbstractSet` when importing it
    "PYI032", # use `object`, not `Any`, as the second parameter to `__eq__`
    "PYI055", # multiple `type[T]` usages in a union
    "PYI058", # use `Iterator` as the return type for `__iter__` methods
]
ignore = [
    ###
    # Rules we don't want or don't agree with
    ###
    # Slower and more verbose https://github.com/astral-sh/ruff/issues/7871
    "UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)`
    # Used for direct, non-subclass type comparison, for example: `type(val) is str`
    # see https://github.com/astral-sh/ruff/issues/6465
    "E721", # Do not compare types, use `isinstance()`
    ###
    # False-positives, but already checked by type-checkers
    ###
    # Ruff doesn't support multi-file analysis yet: https://github.com/astral-sh/ruff/issues/5295
    "RUF013", # PEP 484 prohibits implicit `Optional`
]
@charliermarsh
Copy link
Member

Good call!

@charliermarsh charliermarsh self-assigned this Mar 2, 2024
charliermarsh added a commit that referenced this issue Mar 3, 2024
We shouldn't warn when an "external" code is used in a file-level
exemption.

Closes #10202.
nkxxll pushed a commit to nkxxll/ruff that referenced this issue Mar 10, 2024
We shouldn't warn when an "external" code is used in a file-level
exemption.

Closes astral-sh#10202.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants