Closed
Description
Describe the bug
import pandas as pd
t: pd.DataFrame
s: list[str] = list(t.columns)
t.py:4: error: Argument 1 to "list" has incompatible type "Index"; expected
"Iterable[str]"
s: list[str] = list(t.columns)
^~~~~~~~~
t.py:4: note: Following member(s) of "Index" have conflicts:
t.py:4: note: Expected:
t.py:4: note: def __iter__(self) -> Iterator[str]
t.py:4: note: Got:
t.py:4: note: def __iter__(self) -> Iterator[Union[Union[str, bytes, date, datetime, timedelta, bool, int, float, complex, Timesta
mp, Timedelta], Tuple[Hashable, ...]]]
Found 1 error in 1 file (checked 1 source file)
Variant:
import pandas as pd
t: pd.DataFrame
s: str
for s in t.columns:
pass
t.py:5: error: Incompatible types in assignment (expression has type
"Union[Union[str, bytes, date, datetime, timedelta, bool, int, float, complex, Timestamp, Timedelta], Tuple[Hashable, ...]]",
variable has type "str")
for s in t.columns:
^
Found 1 error in 1 file (checked 1 source file)
To Reproduce
See above
Please complete the following information:
- Version
1.5.2.230105
- MyPy 0.991