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
MyPy seems to be getting confused if function that receives a generic class returns a union type with that generic is used in a comprehension. If the functions is used in a for loop or the function returns just the generic T, then MyPy doesn't show any errors.
Bug Report
MyPy seems to be getting confused if function that receives a generic class returns a union type with that generic is used in a comprehension. If the functions is used in a for loop or the function returns just the generic T, then MyPy doesn't show any errors.
To Reproduce
Error:
https://mypy-play.net/?mypy=latest&python=3.12&gist=ffe7822cc564a6f347c2b8d6fd98c47f
Expected Behavior
The list comprehension line should be interpreted exactly the same as the for loop.
Actual Behavior
MyPy somehow relates the function return to the generic type.
Your Environment
mypy.ini
(and other config files): no configsThe text was updated successfully, but these errors were encountered: