Skip to content

Ruff: Enable RUF105 'noqa-comments' and bump to Ruff>=0.15.22#4761

Open
seisman wants to merge 5 commits into
mainfrom
ruff/RUL105
Open

Ruff: Enable RUF105 'noqa-comments' and bump to Ruff>=0.15.22#4761
seisman wants to merge 5 commits into
mainfrom
ruff/RUL105

Conversation

@seisman

@seisman seisman commented Jul 25, 2026

Copy link
Copy Markdown
Member

Ruff supports two types of comments for suppressing linting errors: # noqa and # ruff: ignore (xref: https://docs.astral.sh/ruff/linter/#error-suppression). The # noqa syntax originates from flake8, whereas # ruff: ignore is Ruff-specific and provides greater flexibility. For example:

In preview, rule names (e.g., unused-import) can be used in ruff: ignore, ruff: file-ignore, ruff: disable, and ruff: enable comments instead of rule codes (e.g., F401).

This means we can write # ruff: ignore[unused-import], which is more readable than either # ruff: ignore[F401] or # noqa: F401.

This PR enables the RUF105 rule, which automatically detects # noqa comments that can be expressed as # ruff: ignore and performs the conversion.

Note that RUF105 is still a preview rule and requires Ruff 0.15.22 (released on 2026-07-16). I'm happy to postpone this PR if you think adopting a preview feature at this stage is too aggressive.

Will explore RUF106 and RUF201 in futher PRs.

Related to #2741.

@seisman seisman added this to the 0.20.0 milestone Jul 25, 2026
@seisman seisman added the maintenance Boring but important stuff for the core devs label Jul 25, 2026
@seisman
seisman requested a review from a team July 25, 2026 06:48
@seisman seisman added the needs review This PR has higher priority and needs review. label Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Boring but important stuff for the core devs needs review This PR has higher priority and needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant