Add Type Hints to TypeShed
Closed this issue · 1 comments
The typeshed repo (explained here) contains a stub for contextvars
in 3.7, but does not contain stubs for this backport.
This causes tools like mypy
and PyCharm
to fail to notice typing errors that are caught when using the builtin 3.7
version, as in the following example:
int_var: MyContextVar[int] = ContextVar('int_var', default=42)
int_var.set('') # caught by mypy in 3.7, not caught by backport
It seems like it could be as simple as copying the stub for the builtin to the third-party
directory, but because of the policy outlined here, no one can do this without your explicit agreement.
It seems like it could be as simple as copying the stub for the builtin to the third-party directory, but because of the policy outlined here, no one can do this without your explicit agreement.
I'd be fine with this.
Keep in mind, though, that this backport only adds the contextvars module; it doesn't make asyncio support it in Python < 3.6.