Closed
Description
pandas-stubs
versions 1.5.3.230227 and later (also tested the most recent and most recent yanked versions) treat []
indexing as producing a Series
, even when the result is a DataFrame
.
To Reproduce
pandas-stubs-bug.py
from pandas import DataFrame
df = DataFrame({"a": (1,)})
reveal_type(df["a"])
reveal_type(df[["a"]])
python -m mypy pandas-stubs-bug.py
The correct output from pandas-stubs==1.5.3.230214
:
pandas-stubs-bug.py:4: note: Revealed type is "pandas.core.series.Series[Any]"
pandas-stubs-bug.py:5: note: Revealed type is "pandas.core.frame.DataFrame"
The output from pandas-stubs==1.5.3.230227
or later:
pandas-stubs-bug.py:4: note: Revealed type is "pandas.core.series.Series[Any]"
pandas-stubs-bug.py:5: note: Revealed type is "pandas.core.series.Series[Any]"
Please complete the following information:
- OS: GuixSD on WSL2
- N/A / Windows 11
- Python 3.8.2
- mypy 1.1.1
- Pandas 1.1.0
pandas-stubs
as described above.
Additional context
#537 seems a likely culprit, but I'm not sure how to bisect to make sure (or how to write a test suite to catch the regression). I'm happy to do either if pointed in the right direction.
Metadata
Metadata
Assignees
Labels
No labels