-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-join-v-unionUsing join vs. using unionsUsing join vs. using unions
Description
Bug Report
I think this is related to the join-v-union
discussion but this case is so easy to reproduce that I thought it's worth the ticket
To Reproduce
from itertools import chain
class A:
def foo(self) -> None: ...
class B:
def foo(self) -> None: ...
a_items = [A(), A()]
b_items = [B(), B()]
for item in chain(a_items, b_items):
item.foo()
A workaround for this is to explicitly have an items: Iterator[A | B] = chain(...)
Expected Behavior
There shouldn't be any errors
Actual Behavior
chain.py:14: error: "object" has no attribute "foo" [attr-defined]
Your Environment
$ mypy --version
mypy 1.11.2 (compiled: yes)
$ python --version
Python 3.12.3
slavistan
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-join-v-unionUsing join vs. using unionsUsing join vs. using unions