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

Fix exclusive rules selection for only arg #310

Merged
merged 1 commit into from
Nov 7, 2023
Merged

Conversation

dhruvmanila
Copy link
Member

@dhruvmanila dhruvmanila commented Nov 7, 2023

Summary

Earlier, if a user had define a rule selection or exclusion using the lint.args setting, it would collide with the only parameter. The purpose of the only parameter is to only run Ruff for the given rule excluding everything else. The "excluding everything else" part was done with --extend-ignore=ALL. The problem, as highlighted in the linked issue, was that if there's a user defined --ignore / --select (or their --extend-* version), then the ALL directive won't work because:

When breaking ties between enabled and disabled rules (via select and ignore, respectively), more specific prefixes override less specific prefixes.

Reference: https://docs.astral.sh/ruff/settings/#ignore

This means that between --select=E,F and --ignore=ALL, the former wins.

This PR fixes this issue by checking for the following argument pattern in user defined settings, skipping them if the only parameter is given:

  • ["--select", "A,B,C"] / ["--select=A,B,C"]
  • ["--ignore", "A,B,C"] / ["--ignore=A,B,C"]

And their --extend-* version.

Test Plan

Manual testing locally :)

fixes: astral-sh/ruff-vscode#328

@dhruvmanila
Copy link
Member Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

ruff_lsp/server.py Outdated Show resolved Hide resolved
ruff_lsp/server.py Outdated Show resolved Hide resolved
@dhruvmanila dhruvmanila marked this pull request as ready for review November 7, 2023 16:01
ruff_lsp/server.py Outdated Show resolved Hide resolved
@dhruvmanila dhruvmanila merged commit 3dc7888 into main Nov 7, 2023
20 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/fix-only-arg branch November 7, 2023 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Organize imports and Ruff: Format imports apply other autofixes
3 participants