Skip to content

[RUF102] Respect rule redirects in invalid rule code detection#20245

Merged
amyreese merged 2 commits into
astral-sh:mainfrom
TaKO8Ki:ruf102-respect-rule-redirects
Sep 10, 2025
Merged

[RUF102] Respect rule redirects in invalid rule code detection#20245
amyreese merged 2 commits into
astral-sh:mainfrom
TaKO8Ki:ruf102-respect-rule-redirects

Conversation

@TaKO8Ki
Copy link
Copy Markdown
Contributor

@TaKO8Ki TaKO8Ki commented Sep 4, 2025

Summary

Fixes #20235

• Fix RUF102 to properly handle rule redirects when validating noqa codes
• Update code_is_valid to check redirect targets before determining validity
• Add test case for rule redirects (TCH002 in this case)

Test Plan

I have added a test case for rule redirects to crates/ruff_linter/resources/test/fixtures/ruff/RUF102.py.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 4, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+0 -2 violations, +0 -0 fixes in 1 projects; 54 projects unchanged)

apache/airflow (+0 -2 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select ALL

- providers/edge3/src/airflow/providers/edge3/worker_api/auth.py:34:79: RUF102 [*] Invalid rule code in `# noqa`: TCH001
- providers/edge3/src/airflow/providers/edge3/worker_api/datamodels.py:28:73: RUF102 [*] Invalid rule code in `# noqa`: TCH001

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
RUF102 2 0 2 0 0

Comment thread crates/ruff_linter/src/rules/ruff/rules/invalid_rule_code.rs Outdated
@TaKO8Ki TaKO8Ki requested a review from amyreese September 10, 2025 08:46
@amyreese amyreese added fixes Related to suggested fixes for violations suppression Related to supression of violations e.g. noqa labels Sep 10, 2025
@amyreese amyreese merged commit 12c337c into astral-sh:main Sep 10, 2025
37 checks passed
@amyreese
Copy link
Copy Markdown
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fixes Related to suggested fixes for violations suppression Related to supression of violations e.g. noqa

Projects

None yet

Development

Successfully merging this pull request may close these issues.

invalid-rule-code (RUF102) doesn't respect rule redirects

2 participants