[flake8-type-checking] Fix false positives for typing.Annotated#14311
Conversation
|
@AlexWaygood would you mind taking a look at this PR? I think you have a better understanding of our type checking flags |
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| RUF100 | 3 | 3 | 0 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+3 -0 violations, +0 -0 fixes in 1 projects; 53 projects unchanged)
ibis-project/ibis (+3 -0 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview
+ ibis/expr/operations/generic.py:16:44: RUF100 Unused `noqa` directive (unused: `TCH001`) + ibis/expr/operations/generic.py:18:54: RUF100 Unused `noqa` directive (unused: `TCH001`) + ibis/expr/types/groupby.py:28:42: RUF100 Unused `noqa` directive (unused: `TCH001`)
Changes by rule (1 rules affected)
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| RUF100 | 3 | 3 | 0 | 0 | 0 |
|
Not quite sure what the new LOG015 violations are about and how they are related to this change, but they look correct to me. The RUF100 violations are encouraging, since these are all due to previous false positives. |
|
@Daverball can you try rebasing/merging main. I suspect that will help with the |
typing.Annotatedtyping.Annotated
|
@AlexWaygood I'm assuming this is a bugfix based on the PR title but feel free to update the label if you think it's a rule change. |
typing.Annotatedflake8-type-checking] Fix false positives for typing.Annotated
Yes, I think that's right! Sorry, I should have added the label. |
This partially addresses #13713
Summary
Ruff properly clears the
TYPE_DEFINITIONflag when visiting special parts of an annotation liketyping.Literalandtyping.Annotated. However there are other typing related semantic flags which aren't cleared. This is fine, howeveris_typing_referenceonly check for those higher level flags and completely ignoresTYPE_DEFINITION, which can lead to false positives for TCH001-003.Test Plan
cargo nextest run