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
Actual Behavior
main.py:24: note: Revealed type is "Union[def () -> builtins.list[main.A], def () -> builtins.list[main.B], def () -> builtins.list[main.C]]"
main.py:25: error: Incompatible types in assignment (expression has type "list[A] | list[B] | list[C]", variable has type "list[T]") [assignment]
Found 1 error in 1 file (checked 1 source file)
Your Environment
Mypy version used: 1.14.1
Mypy command-line flags: none
Mypy configuration options from mypy.ini (and other config files): none
Python version used: 3,12
The text was updated successfully, but these errors were encountered:
The issue I think is that mypy incorrectly detects the type of elem.dup. It should be () -> Sequence[T] and not Union[def () -> typing.Sequence[main.A], def () -> typing.Sequence[main.B], def () -> typing.Sequence[main.C]]
Bug Report
For a function that accepts objects of
A | B | C
type, mypy is not correctly inferring types for function calls from that object.To Reproduce
https://mypy-play.net/?mypy=latest&python=3.12&gist=a090296a66d822acabcb0e92e53f5871
Expected Behavior
No error to be reported
Actual Behavior
main.py:24: note: Revealed type is "Union[def () -> builtins.list[main.A], def () -> builtins.list[main.B], def () -> builtins.list[main.C]]"
main.py:25: error: Incompatible types in assignment (expression has type "list[A] | list[B] | list[C]", variable has type "list[T]") [assignment]
Found 1 error in 1 file (checked 1 source file)
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: