-
Notifications
You must be signed in to change notification settings - Fork 53
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
Organize imports
and Ruff: Format imports
apply other autofixes
#328
Comments
Can you share the relevant portion of your |
"ruff.lint.args": [
"--select=F,E,W,I,UP,N,S,C,B,A,T,Q,RUF,YTT,BLE,ANN,FBT,PL,TRY,RSE,SLF,DTZ,EXE,ISC,ICN,G,INP,PIE,RET,SIM,TID,TCH,ARG,PTH,PERF,SLOT",
"--ignore=DTZ005,INP001,TCH003,ANN101,ANN102,ANN401,TID252,T201,B905,S101,TRY003,PLR2004"
], |
I see the problem here. We should be using Edit: We would actually want a |
Hmm. Actually we would also need to check if there's Edit: This would need to account for |
Or, we could filter out the diagnostics to only keep the ones matching in the Edit: This won't be possible as we would directly get the fixed content, so there's no structured data to filter. |
I thought we used |
It seems like $ ruff check --no-cache --isolated src/play.py --select=I,ANN,PT --ignore=ALL
src/play.py:1:1: I001 [*] Import block is un-sorted or un-formatted
src/play.py:5:9: ANN201 Missing return type annotation for public function `test_foo`
src/play.py:5:18: ANN101 Missing type annotation for `self` in method
src/play.py:6:9: PT009 Use a regular `assert` instead of unittest-style `assertTrue`
Found 4 errors.
[*] 1 fixable with the `--fix` option (1 hidden fix can be enabled with the `--unsafe-fixes` option). But, $ ruff check --no-cache --isolated src/play.py --select=I,ANN,PT --ignore=I,ANN
src/play.py:6:9: PT009 Use a regular `assert` instead of unittest-style `assertTrue`
Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option). Version: $ ruff version
ruff 0.1.4 (c4889196e 2023-11-03) From the documentation, it seems like the correct behavior?
|
@dhruvmanila - Yeah I think the use of |
Yeah, that's likely the best option for now. |
## 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
Thanks for the issue! This is fixed and will be available in the next release. |
## 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
Screen.Recording.2023-11-04.at.11.02.26.mov
The text was updated successfully, but these errors were encountered: