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

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

Merged
merged 10 commits into from Apr 27, 2024

Conversation

augustelalande
Copy link
Contributor

@augustelalande augustelalande commented Apr 20, 2024

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.

Copy link

github-actions bot commented Apr 20, 2024

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
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
Copy link
Member

@charliermarsh charliermarsh left a comment

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
18 checks passed
@augustelalande augustelalande deleted the ruf101 branch April 27, 2024 03:21
@augustelalande
Copy link
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.

None yet

2 participants