Repository navigation
fix(ruff): move typing-only imports into TYPE_CHECKING blocks for py314 - #190
Merged
Merged
Conversation
The prepare job now sets ruff target-version to py314. With PEP 649 lazy annotations, ruff flags imports only used in annotations (TC001/TC002/TC003). Apply ruff unsafe fixes repo-wide. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BotellaA
approved these changes
Oct 21, 2026
Member
|
🎉 This PR is included in version 1.35.0-rc.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.35.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
Since Geode-solutions/actions@70242614 ("move web to Python 3.14"), the prepare job rewrites
ruff.tomltotarget-version = "py314"on every PR branch. Python 3.14 evaluates annotations lazily (PEP 649), so withselect = ["ALL"]ruff now reports every import used only in annotations:TC001: 39 first-party importsTC002: 13 third-party importsTC003: 35 standard library importsruff check --fixin CI can't fix them because ruff marks these fixes as unsafe. As a result, every web PR that gets the prepare commit fails the lint job (e.g. #188).How
ruff.toml:target-version = "py314"(what prepare would set anyway).ruff check --fix --unsafe-fixes .thenruff format .(ruff 0.17.1, same as CI). Imports used only in annotations move underif TYPE_CHECKING:. Also fixes 2UP043.Callable,ServerMonitor).Ruff marks these fixes unsafe because they break code that reads annotations at runtime. Checked:
typed_rpc.py:Route/Callableare only used in annotations;route.params/route.responseare attribute accesses.dataclasses_jsonresolves field types withget_type_hints, but the generated dataclasses live in**/schemas/**, which ruff excludes, so none of them were touched.Verification (Python 3.14)
ruff check .→ all checks passed,ruff format --check .→ cleanmypy(strict,mypy.ini) → no issues in 227 source filespytest→ 224 passed. 4 errors were server-startupTimeoutErrors. On rerun,tests/test_viewer_protocols.pyand the 2 other affected files pass (19 + 20 passed).🤖 Generated with Claude Code