-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
TypeGuard
doesn't work with TypeVar
#11780
Comments
i think this can be closed as a duplicate of #11428, @MicaelJarniac? (as you noticed yourself) |
I believe the bug in question is to do with And in my opinion, the examples I've given here are easier to understand and more straight to the point. I'm not sure about what to do. One thing I did not test is whether the issue I'm describing here also happens on Python 3.10, and that's why this issue is about the I do think our issues are about the same bug, but we've come across it in different ways. I'll try to test my examples against Python 3.10, to see whether it's in any way related to |
TypeGuard
from typing_extensions
doesn't work with TypeVar
TypeGuard
doesn't work with TypeVar
Just tested it with Python 3.10.0 and using the built-in |
Closing as a duplicate of #11428. |
Bug Report
Using a
TypeVar
withTypeGuard
results in Mypy thinking that the resulting type is theTypeVar
itself, and not the type it should be pointing to.To Reproduce
Example adapted from PEP 647:
Expected Behavior
Mypy should substitute the
TypeVar
insideTypeGuard
to the proper type it should be pointing to.Pyre, Pyright, and Pylance do successfully work with the
TypeVar
insideTypeGuard
.Actual Behavior
Your Environment
3.10.0
4.0.1
0.920
0.4.3
0.9.8
0.0.23
0.0.13
0.920
mypy.ini
(and other config files): none3.10.0
The text was updated successfully, but these errors were encountered: