Fix exclusive rules selection for only
arg
#310
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Earlier, if a user had define a rule selection or exclusion using the
lint.args
setting, it would collide with theonly
parameter. The purpose of theonly
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 theALL
directive won't work because: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