Open tvdboom opened 9 months ago
pyright
1.1.351 gets it right:
issue877.py:4:13 - information: Type of "df1" is "Series[Unknown]"
issue877.py:5:4 - error: Unnecessary isinstance call; "Series[Unknown]" is always an instance of "Series[Unknown]" (reportUnnecessaryIsInstance)
issue877.py:6:17 - information: Type of "df1" is "Series[Unknown]"
I think this is a mypy
bug. See https://github.com/python/mypy/issues/15322
I'll keep this open in case mypy
ever fixes that issue.
I am unable to reproduce this one, used the same example as @tvdboom above and this is what mypy
returns to me:
===========================================
Beginning: 'Run mypy on 'tests' (using the local stubs) and on the local stubs'
===========================================
tests/test_frame.py:3584: note: Revealed type is "Union[pandas.core.series.Series[Any], pandas.core.frame.DataFrame]"
tests/test_frame.py:3586: note: Revealed type is "pandas.core.series.Series[builtins.float]"
Not sure exactly where it got fixed but it seems like it does not map to TimestampSeries
anymore.
It's still an issue, because what happens now is that it is picking up the first overload for Series.__new__()
, which returns a Series[float]
. The first reveal_type()
showed that the Union
contained Series[Any]
, and you'd expect the same from the second reveal_type()
.
So mypy
still has to address the linked issue.
Ohh I understand, thanks a lot for all the details!
Describe the bug A pd.Series variable changes type after an isinstance check.
To Reproduce
pandas
example that is not properly checked by the stubs.mypy
orpyright
). mypyPlease complete the following information:
pandas-stubs
: 2.2.0.240218