Open
Description
Describe the bug
A pd.Series variable changes type after an isinstance check.
To Reproduce
- Provide a minimal runnable
pandas
example that is not properly checked by the stubs.
df1: pd.Series | pd.DataFrame = pd.Series()
reveal_type(df1) # <- As expected
if isinstance(df1, pd.Series):
reveal_type(df1) # <- ???
- Indicate which type checker you are using (
mypy
orpyright
).
mypy - Show the error message received from that type checker while checking your example.
note: Revealed type is "Union[pandas.core.series.Series[Any], pandas.core.frame.DataFrame]"
note: Revealed type is "pandas.core.series.TimestampSeries"
Please complete the following information:
- OS: Windows
- OS Version: 10
- python version: 3.11
- version of type checker: 1.8.0
- version of installed
pandas-stubs
: 2.2.0.240218