-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Hints for using typing_extensions with mypy #316
Comments
I'm not sure there's much to be said from the typing-extensions side. If you want mypy to check Python 3.6, you should set mypy's python_version to 3.6, and pick an appropriate version of typing-extensions. |
+1 to everything Jelle said. Set mypy's Additionally, note that because typing-extensions is highly special cased, type checkers are not typically aware of differences between versions of typing-extensions and usually pretend that typing-extensions works the way the latest release of typing-extensions did at the time that the version of your type checker was released. This typically isn't a big deal. If your type checker is much newer than your typing-extensions you might get a false negative which will usually result in an import time error. If your typing-extensions is much newer than your type checker you might get a somewhat false positive, but new symbols in typing-extensions often require special case support in type checkers anyway so it's arguable how false such false positives would be. Closing, but feel free to ask if you have follow-up questions! |
I’m still confused by the answer here. I want my code to support python 3.6, but I want to use typing features from newer python versions. Isn’t that the point of typing extensions? Isn’t setting mypy’s Python version to 3.6 going to prevent me from using the new features in typing extensions? |
No |
Thanks! |
One last note: mypy dropped support for targeting Python 3.6 in mypy 1.6 (see https://github.com/python/mypy/blob/master/CHANGELOG.md#remove-support-for-targeting-python-36-and-earlier ). So if you need bleeding edge type system features that only mypy 1.6 and newer support, then you need to choose between a) not using those features, b) upgrading mypy and potentially getting false negatives on Python 3.6 |
Thanks! My example was somewhat contrived. We support running on Python 3.6-3.12, but we’re currently setting Most devs are on newer Python versions (3.11, 3.12) and we don’t require that mypy itself be run from Python 3.6. |
Is there a rough set of recommendations for how to configure
mypy
with differenttyping_extension
versions?For example, it looks like the last version of
typing_extensions
to support Python 3.6 was 4.1.1. If I use typing_extensions 4.1.1 with python 3.6, should I setmypy
'spython_version
to 3.8? 3.9? Something else?The text was updated successfully, but these errors were encountered: