-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Allow stubs to use newer syntax than 3.7 #13500
Conversation
Fixes python#13499 Today this code reads like "stubs should all target 3.7" and this is indeed how typeshed operates. But authors of pyi other than typeshed should probably be allowed to choose what Python version they're targetting. This code goes back to python#3000 back in the typed_ast days, when this allowed stubs to use much newer syntax features than the base Python version, so in some ways this is in the spirit of the original code.
Also note that OP is on PyPy. |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Is it worth adding a test that uses newer syntax in a stub file? (We'd have to skip the test on older versions.) |
Can't add one for pos-only because whether or not that is parsed now depends on micro version of CPython (and in particular, wheels repo tests with micro version 0). I think walrus is rejected without feature version in all versions of 3.8? But you wouldn't use that in a stub. Conclusion: not worth it |
I did test locally though |
I guess the only other stub-relevant syntactic change is PEP 646's |
Oddly enough, numpy type checking does work if I run it in my ARM64 built image, but not when I run it in my AMD64 image. |
Fixes #13499 Today this code reads like "stubs should all target 3.7" and this is indeed how typeshed operates. But authors of pyi other than typeshed should probably be allowed to choose what Python version they're targetting. Since typeshed runs checks against 3.7, this should not cause testing regressions for typeshed. This code goes back to #3000 back in the typed_ast days, when this allowed stubs to use much newer syntax features than the base Python version, so in some ways this is in the spirit of the original code.
This can be reverted once a mypy version with python/mypy#13500 is out
This can be reverted once a mypy version with python/mypy#13500 is out
This can be reverted once a mypy version with python/mypy#13500 is out
Has this been released yet? |
No, follow #13385 |
Pin mypy to github version until fix for python 3.10.7 is released. python/mypy#13500
Is there any insight into why the release of python 3.10.7 caused many projects to start seeing this diagnostic? |
Python 3.10.7 includes python/cpython#95935, which means that the latent bug in mypy (that's been around for a while) suddenly becomes a big problem |
Thanks, that makes sense now. |
I also noticed that this appears to be somewhat architecture-dependent for some reason. |
It's not architecture dependent, it's only about the specific version of Python you have in your image. If you have Python 3.10.7 you'll see the error, if you have Python 3.10.6 you won't. In all cases, upgrading to mypy 0.981 will fix. |
Fixes #13499
Today this code reads like "stubs should all target 3.7" and this
is indeed how typeshed operates. But authors of pyi other than typeshed
should probably be allowed to choose what Python version they're
targetting. Since typeshed runs checks against 3.7, this should not
cause testing regressions for typeshed.
This code goes back to #3000 back in the typed_ast days, when this
allowed stubs to use much newer syntax features than the base Python
version, so in some ways this is in the spirit of the original code.