Unable to type asyncio.Lock as AbstractAsyncContextManager #2435
FasterSpeeding
started this conversation in
General
Replies: 2 comments 1 reply
-
We can probably fix this in typeshed by making the args to AbstractAsyncContextManager positional-only. I submitted python/typeshed#6172 to do that. |
Beta Was this translation helpful? Give feedback.
0 replies
-
This is a legitimate type error. I'm not sure why mypy doesn't report it. This is a bug in the type stub. Looks like @JelleZijlstra is on top of it already. Thanks! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
While linting this code with pyright 1.1.178 I get the following issue error
While this is technically correct this doesn't match the runtime semantics of context managers (where all of these values are passed as positional arguments) which make Lock a valid async context manager but I do see that it isn't type safe to just mix and match names like that with arguments which can be passed both positionally or by their name.
For reference MyPy allows this on strict and python's stubs are accurate as AbstractAsyncContextManager doesn't enforce that those parameters are passed positionally.
To be honest I wasn't exactly sure where this belonged so I thought just a general discussion here would be good enough (or at least better than just not bringing it up at all).
Beta Was this translation helpful? Give feedback.
All reactions