You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd expect that for any t: T, you should be able to call type(t)() and it should either returnT or raise an exception. This seems to be true in most cases, but when using a TypeVar with a union bound it seems to be falling back to the union value.
To Reproduce
I've put together three functions that I believe to be practically equivalent:
Bug Report
I'd expect that for any
t: T
, you should be able to calltype(t)()
and it should either returnT
or raise an exception. This seems to be true in most cases, but when using a TypeVar with a union bound it seems to be falling back to the union value.To Reproduce
I've put together three functions that I believe to be practically equivalent:
https://mypy-play.net/?mypy=latest&python=3.12&flags=show-traceback&gist=ede4bf83e226751762cd82d516093170
Expected Behavior
I'd expect for all three functions to type-check successfully, like it does in the Pyright playground.
Actual Behavior
While Mypy was happy with
generic
andgeneric_constraint
, it errors ongeneric_bound
:I originally bumped into this while working on a function set up slightly differently, which I think has the same problem:
I don't think this is the same problem solved by PEP 747, but it's possible that I've misunderstood.
Your Environment
mypy.ini
(and other config files): N/APotentially related
The text was updated successfully, but these errors were encountered: