-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use typing_extensions only when needed #5331
Conversation
Self was added in Python 3.11 TypeAlias was added in Python 3.10
Since type annotations are only used by mypy, maybe we should make these statements conditional on (Disclaimer: I'm not a maintainer, I'm just providing some feedback.) |
Ruff outputs runtime-import-in-type-checking-block (TCH004) warning if |
I suspect Ruff special-cases imports in type-checking blocks, only allowing things from modules it knows about. It definitely looks like they support some imports in type-checking blocks: it's mentioned here for example. |
Hi! Thanks for the PR. What is the benefit of doing this rather than what we already have? Python 3.8 is currently our minimum supported version. |
Use built-in module in modern Python. |
Those benefits would only happen when we have Python 3.10 as the minimally supported version version though, wouldn't it? There'd be no difference until we reach that point, since it will still be on the dependency list regardless. |
Nope, if distro has Python >= 3.11 maintainer would be able to drop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very well then, thanks for explaining.
Description
Use
typing_extensions
only for Python <= 3.10.Self
was added in Python 3.11.TypeAlias
was added in Python 3.10.To Do