Skip to content

[ruff] Implement redirected-noqa (RUF101) - #11052

Merged
charliermarsh merged 10 commits into
astral-sh:mainfrom
augustelalande:ruf101
Apr 27, 2024
Merged

charliermarsh merged 10 commits into
astral-sh:mainfrom
augustelalande:ruf101

Conversation

@augustelalande

@augustelalande augustelalande commented Apr 20, 2024 •

Copy link
Copy Markdown
Contributor

Summary

Based on discussion in #10850.

As it stands today RUF100 will attempt to replace code redirects with their target codes even though this is not the "goal" of RUF100. This behavior is confusing and inconsistent, since code redirects which don't otherwise violate RUF100 will not be updated. The behavior is also undocumented. Additionally, users who want to use RUF100 but do not want to update redirects have no way to opt out.

This PR explicitly detects redirects with a new rule RUF101 and patches RUF100 to keep original codes in fixes and reporting.

Test Plan

Added fixture.

@github-actions

github-actions Bot commented Apr 20, 2024 •

Copy link
Copy Markdown
Contributor

ruff-ecosystem results

Linter (stable)

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

RasaHQ/rasa (+1 -1 violations, +0 -0 fixes)

- tests/graph_components/validators/test_default_recipe_validator.py:815:64: RUF100 [*] Unused `noqa` directive (non-enabled: `B035`)
+ tests/graph_components/validators/test_default_recipe_validator.py:815:64: RUF100 [*] Unused `noqa` directive (non-enabled: `RUF011`)

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
RUF100 2 1 1 0 0

Linter (preview)

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

DisnakeDev/disnake (+1 -0 violations, +0 -0 fixes)

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

+ disnake/utils.py:1161:56: RUF101 [*] `PGH001` is a redirect to `S307`

RasaHQ/rasa (+2 -1 violations, +0 -0 fixes)

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

- tests/graph_components/validators/test_default_recipe_validator.py:815:64: RUF100 [*] Unused `noqa` directive (non-enabled: `B035`)
+ tests/graph_components/validators/test_default_recipe_validator.py:815:64: RUF100 [*] Unused `noqa` directive (non-enabled: `RUF011`)
+ tests/graph_components/validators/test_default_recipe_validator.py:815:72: RUF101 [*] `RUF011` is a redirect to `B035`

Changes by rule (2 rules affected)

code total + violation - violation + fix - fix
RUF101 2 2 0 0 0
RUF100 2 1 1 0 0

@charliermarsh

Copy link
Copy Markdown
Member

Sorry, I know this is blocked on my review.

@charliermarsh charliermarsh self-assigned this Apr 26, 2024
@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Apr 26, 2024

@charliermarsh charliermarsh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@charliermarsh
charliermarsh enabled auto-merge (squash) April 27, 2024 02:01
@charliermarsh charliermarsh added the preview Related to preview-mode features label Apr 27, 2024
@charliermarsh
charliermarsh merged commit 5994414 into astral-sh:main Apr 27, 2024
@augustelalande
augustelalande deleted the ruf101 branch April 27, 2024 03:21
@augustelalande

Copy link
Copy Markdown
Contributor Author

Thanks for taking the time 😄

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

Labels

preview Related to preview-mode features rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants