Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
Description
Bug Report
When a value of a user-defined class with __iter__ is converted into a list using [*value], the type of the list is inferred as list[Any].
To Reproduce
importtypingclassSpam: def__iter__(self, /) ->typing.Iterator[int]: yield1a=Spam() # list[int]reveal_type(list(a)) # list[int]reveal_type([iforiina]) # list[int]reveal_type([*(iforiina)]) # list[int]reveal_type([*a.__iter__()]) # list[Any] ???reveal_type([*a]) b, =a# intreveal_type(b)Expected Behavior
The type of [*a] is list[int]
Actual Behavior
example.py:22: note: Revealed type is "builtins.list[Any]" Your Environment
- Mypy version used: 1.4.1
- Mypy command-line flags:
--strict - Mypy configuration options from
mypy.ini(and other config files): - Python version used:
3.11.4
ilevkivskyi