Skip to content

redirected-noqa (RUF101) does not detect file-level # ruff: noqa comments #14531

@AlexWaygood

Description

@AlexWaygood

Ruff supports file-level noqa comments: # ruff: noqa: TC002 on its own line at the top of a file will lead to the TC002 code being suppressed for the whole file. RUF101, however, appears not to detect these file-level comments when it looks for redirected rule codes; it only flags inline noqa comments of the form # noqa: TCH001.

For example, I would expect Ruff to emit a RUF101 diagnostic on the first line of this snippet, since Ruff's flake8-type-checking rules have been recoded from TCH to TC. However, no RUF101 diagnostic is emitted:

# ruff: noqa: TCH002

from __future__ import annotations

import local_module


def func(sized: local_module.Container) -> int:
    return len(sized)

https://play.ruff.rs/26c8939c-fc09-4d85-a25c-f80bea97a842

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedContributions especially welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions