-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Stubs for AsyncMock when using mock backport in Python <3.8 #5947
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
Comments
I believe the reason the stubs for the mock backport have a |
Ah OK, perfect. I will do that. |
Fixed by #5948. |
Unless I'm missing something, why can't the type annotations just be added to the upstream mock.py and remove the need for separate typeshed stubs completely? |
@cjw296 Inline type annotations or stubs shipped with upstream packages are preferred over separate type packages generated by typeshed. |
Right, so what's stopping that happening for Mock? @GDYendell: could you direct your energies to that instead of PRs to typeshed and opening issues on the mock backport? |
Sorry, it seems I have misunderstood. By upstream, I was referring to the mock backports package, which could ship its own annotations, either by using a separate stubs file (possibly copying the one from here) or adding annotation inline. (Also, it would need to ship a |
I'm one of the maintainers of mock in CPython, I also maintain the backport. I would welcome the addition of type annotations, and "not generally accepted" seems weird. @pablogsal, is that really the case? I don't know what a |
py.typed is just a file that says "this package provides type annotations for static type checking"; it's the packaging convention that all type checkers follow as per PEP 561. It has historically been the case that CPython doesn't accept type hints. It's worth noting that, imo, this has generally been good for users of static type checking: typeshed typically moves much faster than the CPython release cycle and improvements benefit users of all Python versions (type checking is a useful tool to help move between Python versions!). I'll also note that mock is a tricky thing to static type (typeshed has made several changes / suffered several mock typing bugs, some regressions, in the last year) — probably not the module I'd pick to get annotations into CPython, if there's any chance of controversy. |
That's great to hear and hopefully a first step to more type annotations directly in the stdlib. I'm not aware of any other CPython packages that use annotations. That said, type checkers will most likely not use stdlib annotations for now. This would most likely need another PEP to disentangle when a type checker can use stdlib annotations directly, when to use stubs shipped with CPython (not possible at the moment, but necessary for extension modules), and when to fall back to typeshed. Cf. #5444. |
Wow, what am absolute mess :-( |
Uh oh!
There was an error while loading. Please reload this page.
Is it possible to make the stubs for
AsyncMock
available for Python <3.8 when using themock
backport rather thanunitest.mock
?Relates to testing-cabal/mock#500
The text was updated successfully, but these errors were encountered: