Repository navigation
Move type-only imports into TYPE_CHECKING blocks - #208
Merged
Merged
Conversation
`typing_extensions` is not available at runtime in Sublime Text's plugin host, so importing it unconditionally can fail with ImportError. - Enable ruff's flake8-type-checking (TC) rules and stop exempting `typing_extensions`; exempt `sublime` since it is always available. - Move annotation-only imports behind `TYPE_CHECKING`. - Add `typing-extensions` to the lint dependency group for type checkers. - Bump the `sublime-text-stubs` lower bound.
rchl
commented
Oct 18, 2026
Member
|
The little amount of such type only imports doesn't really justify overhead of extra TYPE_CHECKING imports. |
Member
|
I do not understand how a |
Member
|
It adds useless noise for just gating single imports. |
FichteFoll
reviewed
Oct 18, 2026
Member
|
There are two justifications for TYPE_CHECKING gates
|
Member
|
By the way, we can also remove the typing-extensions dependency from the docs project now for the same reason. |
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.
typing_extensionsisn't available at runtime in Sublime Text's plugin host, and sublime_lib doesn't declare it as a runtime dependency. So the unconditionalfrom typing_extensions import Selfinflags.pyandactivity_indicator.pycould fail withImportError.Changes:
TC) rules.exempt-modules = ["typing", "sublime"]. Ruff exemptstyping_extensionsby default, which hides exactly this problem.sublimeis always present at runtime, so it stays a plain import.Self,TracebackType,IterableandGeneratorbehindTYPE_CHECKING. All of them are used only in annotations, and every affected module hasfrom __future__ import annotations.typing-extensionsto thelintdependency group for type checkers.sublime-text-stubslower bound.ruff checkandruff format --checkpass.