-
-
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
Document mypy version requirement in third-party stubs #6843
Comments
Do you use |
Using |
If you upgrade to 0.930, mypy should be fine with the new syntax in stub files, even if you're running Python 3.8. Stub files have different rules to |
Thanks, |
types-mock
broken on python3.8
I think it would be reasonable to document this somewhere, either stub-specifically or in a way that applies to all stubs. Even though mypy is just one of the tools that use typeshed, it is important. |
stub_uploader could add a line "These stubs have been tested with mypy A.BCD, pytype YYYY.MM.DD, and pyright A.B.CDE." (gathered from |
When we edit |
That shouldn't be necessary, I think, but I don't particularly mind either way. |
Per #9690, I think it would be reasonable to have a grace period following a mypy release during which breaking changes in third-party stubs aren't released yet. Otherwise the breaking changes may make it harder to actually upgrade mypy in downstream projects. |
It would be great if we could somehow encode breaking changes in the type stub version numbers, but I unfortunately don't see a good way to do that with the version number formats Python allows. |
I think you could have an interleaved |
npm/node has Does python's requirements system / pip have a way to specify such dependencies? Maybe as extras? It wouldn't cover pyright, but honnestly there's not much that can be done there anyway given it's a node module. (and the only non-python-based python type checker afaik). |
I think people who care about not having new type checking failures from a stub version should pin their stubs exactly / this knowledge is somewhat widespread. Extras is worth thinking about, but I don't think there's a trick to be found that isn't horribly surprising and/or does the wrong thing a lot of the time. To me, the most actionable things are:
In today's world, I'm fine with this being an aggressively short grace period, maybe of say 1-2 weeks. I think even such a short grace period would help dependent typing projects or people like me who don't pin stubs. As the ecosystem matures, we can consider extending that period if it proves a persistent painpoint. Finally, we shouldn't have third party stubs depend on a type checker bundled |
We now include the latest type checker version a type package has been tested with in the long description. This is probably the best we can do at this point. |
Another thing we could possibly also do would be to define "compatible-mypy", "compatible-pyright" and "compatible-pytype" extras for our stubs packages. This is something The idea is that if users opt into the @sobolevn, do you know how popular the |
I don't know. This stat is not available: https://pypistats.org/packages/django-stubs |
Determining the minimum and maximum mypy version supported isn't straightforward though. So in django-stubs we just support one mypy major version at a time (e.g. mypy 1.3.x). But I suspect this approach won't scale when lots of stubs packages are in use and they have different mypy requirements. |
Change #6685 switched to using
tuple[Any, ...]
instead ofTuple[Any, ...]
(andlist
instead ofList
) in thetypes-mock
package. This feature is only available in python3.9+ (see: https://mypy.readthedocs.io/en/stable/builtin_types.html#generic-types), leading to spuriouserror: Tuple index out of range
when type-checking under python3.8The text was updated successfully, but these errors were encountered: