Conversation
|
|
|
||
| RUF100 [*] Unused suppression (unused: `E741`) | ||
| --> suppressions.py:87:21 | ||
| RUF100 [*] Unused suppression (unused: `E741`, `F841`; non-enabled: `F401`) |
| | | ||
| 73 | def f(): | ||
| 74 | # Multiple codes but only one is used | ||
| 75 | # ruff: disable[E741, F401, F841] |
There was a problem hiding this comment.
The suppression range here is a bit misleading because it suggests that all codes are unused. I think I would either:
- Highlight the entire suppression diagnostic. That makes it clear that something's up with the suppression and not with an individual code
- Keep underlining the codes, but only group adjacent codes (in which case we'd emit two diagnostics in this case). I slightly prefer this as it gives more precise ranges.
There was a problem hiding this comment.
Don't bother with this if this matches what we do for noqa today.
There was a problem hiding this comment.
It looks like noqa highlights the entire noqa comment:
RUF100 [*] Unused `noqa` directive (unused: `F401`, `E741`)
--> foo.py:2:12
|
1 | def f():
2 | x = 1 # noqa: F401, F841, E741
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
help: Remove unused `noqa` directive
1 | def f():
- x = 1 # noqa: F401, F841, E741
2 + x = 1 # noqa: F841
There was a problem hiding this comment.
I would then suggest aligning with noqa (which I think should be relatively easy?)
There was a problem hiding this comment.
Yeah I liked the idea in #21873 (comment) of extending the range to only the adjacent codes (if I understood correctly), but aligning with noqa makes sense too.
There was a problem hiding this comment.
I've updated the highlighting logic so that:
- if only one code exists or only one is being removed, it highlights that one code
- otherwise, it highlights the entire suppression
I think this matches noqa now.
| disabled: group | ||
| .disabled_codes | ||
| .iter() | ||
| .map(ToString::to_string) | ||
| .collect_vec(), |
There was a problem hiding this comment.
This is probably better suited for a follow-up, and I thought I saw some previous discussion of this, but do these need to be Strings? I tried making UnusedCodes::disabled a Vec<&'a str> and it seems to be working locally. Combining that with into_values makes this a little nicer:
| disabled: group | |
| .disabled_codes | |
| .iter() | |
| .map(ToString::to_string) | |
| .collect_vec(), | |
| disabled: group.disabled_codes |
There was a problem hiding this comment.
I didn't like this either, but since it would also affect the noqa system I'd prefer to put that change in a different PR
| | | ||
| 73 | def f(): | ||
| 74 | # Multiple codes but only one is used | ||
| 75 | # ruff: disable[E741, F401, F841] |
There was a problem hiding this comment.
Yeah I liked the idea in #21873 (comment) of extending the range to only the adjacent codes (if I understood correctly), but aligning with noqa makes sense too.
9bc09d8 to
7791cc9
Compare
|
Congrats! I think we can now close the block level suppression tracking issue |
Summary
has one or more unused, disabled, or duplicate lint codes.
with one or more invalid lint codes.
Test Plan
Updated fixtures and snapshots
Fixes #22429, #21873