Skip to content

Depend on typing-extensions for Python<3.11; avoid it otherwise#50

Open
musicinmybrain wants to merge 2 commits intomdomke:mainfrom
musicinmybrain:typing-extensions
Open

Depend on typing-extensions for Python<3.11; avoid it otherwise#50
musicinmybrain wants to merge 2 commits intomdomke:mainfrom
musicinmybrain:typing-extensions

Conversation

@musicinmybrain
Copy link
Contributor

Conditionalize the import of typing_extensions, needed only in Python 3.10 and older; use typing instead for Python 3.11 and later. Add a dependency on typing-extensions, appropriately conditioned on the Python interpreter version.

Based on #47 and #47 (comment).

Fixes #44.

Conditionalize the import of `typing_extensions`, needed only in Python
3.10 and older; use `typing` instead for Python 3.11 and later. Add a
dependency on `typing-extensions`, appropriately conditioned on the
Python interpreter version.

Based on mdomke#47 and
mdomke#47 (comment).

Fixes mdomke#44.
@QuLogic
Copy link

QuLogic commented Feb 3, 2026

This import could go in the if TYPE_CHECKING: block, I would think. The only reason to need it at runtime may be

return cast(Self, value)
but you could quote that one to avoid it (there's actually a ruff rule for that, though I don't know how many people follow it.)

@musicinmybrain
Copy link
Contributor Author

This import could go in the if TYPE_CHECKING: block […] you could quote that one […]

That’s a great suggestion. Thanks. Updating with a follow-up commit…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing typing_extensions dependency

2 participants