Comments (7)
+1 to everything Jelle said. Set mypy's --python-version
to the oldest version of Python you'd like to support.
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!
from 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
from typing_extensions.
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
from typing_extensions.
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.
from typing_extensions.
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?
from typing_extensions.
Thanks!
from typing_extensions.
Thanks! My example was somewhat contrived. We support running on Python 3.6-3.12, but we’re currently setting --python-version
to 3.7, and haven’t found that mypy admits any annotations that are source-incompatible with 3.6 (I’m not familiar enough to say if there are any).
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.
from typing_extensions.
Related Issues (20)
- ParamSpec `_set_default` called from `ParamSpec.__new__` raises Attribute Error HOT 2
- Add an `override` decorator to a .pyi file HOT 8
- Add `inspect.get_annotations` backport
- Add `typing.get_type_hints` backport HOT 1
- Pylint raises error saying "default" isn't valid for TypeVar HOT 2
- Third-party tests failed on Sat Jun 01 2024 HOT 2
- `TypeError` on nested `Annotated`s with `typing_extensions==4.12.0`
- Third-party tests failed on Sun Jun 02 2024 HOT 2
- 4.12.1: `pyupgrade --py38-plus` generated patch causes pytest fails HOT 9
- Third-party tests failed on Mon Jun 03 2024 HOT 1
- Third-party tests failed on Thu Jun 06 2024 HOT 1
- Weird conflict between typing-extensions 4.12.1, xarray, dirty_equals on Python 3.8 HOT 2
- 4.12.2 creates an import bug HOT 2
- Add `typing_extensions.TypeExpr` HOT 4
- Third-party tests failed on Wed Jun 26 2024 HOT 1
- Third-party tests failed on Sat Jul 13 2024 HOT 1
- Third-party tests failed on Sun Jul 14 2024 HOT 3
- Third-party tests failed on Mon Jul 15 2024 HOT 1
- Third-party tests failed on Thu Jul 25 2024 HOT 1
- Incompatibility unknown to package manager: typing_extensions=4.5.0, notebooks, python=3.10 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typing_extensions.