Repository navigation
[flake8-tidy-imports] Stabilize lazy-import-immediately-resolved (TID255) - #28761
Conversation
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| TID255 | 12 | 12 | 0 | 0 | 0 |
Linter (preview)
✅ ecosystem check detected no linter changes.
1c9c374 to
7435936
Compare
|
The ecosystem results are a little weird here. They point to a slightly surprising interaction between Entirely coincidentally, Ruff is actually correct in all of these cases because __lazy_modules__ = ["pathlib"]
from pathlib import Path
class C:
path: PathPython 3.10, diagnostic: https://play.ruff.rs/dd287dcd-8bf7-4e41-90b4-db4665ed0db8 Python 3.14, no diagnostic: https://play.ruff.rs/51dfcc8c-8029-4dfa-8136-a8860818e413 I guess these were probably also present in my |
…otations (`TID255`) (#28767) Summary -- This PR fixes an issue I saw in the ecosystem report for the stabilization PR (#28761 (comment)). In short, we were flagging annotations like this: ```py __lazy_modules__ = ["pathlib"] from pathlib import Path class C: path: Path ``` on Python versions before 3.14, even though they are not actually resolved immediately when `__lazy_modules__` makes the imports lazy (3.15 > 3.14, as it turns out). Because the semantic model checks the target version when setting `TYPING_ONLY_ANNOTATION`, we instead check the other two annotation flags: `RUNTIME_EVALUATED_ANNOTATION` and `RUNTIME_REQUIRED_ANNOTATION`. If an annotation is runtime-evaluated and not runtime-required, and we didn't already bail out at the `semantic.execution_context().is_runtime()` check earlier in the same function, then we know that we're in an annotation that _would_ have been typing-only on 3.14+. Test Plan -- New mdtests and the ecosystem check here. I expect -12 scikit-build-core diagnostics compared to main.
No description provided.