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
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 aslist[Any].To Reproduce
Expected Behavior
The type of
[*a]islist[int]Actual Behavior
Your Environment
--strictmypy.ini(and other config files):3.11.4