Bug Report
The problem appeared in the pandas stubs in this issue: pandas-dev/pandas-stubs#269
There, I was told to report it here.
To Reproduce
I reduced the problem to a standalone example, but it might be possible to reduce it further:
Playground URL: https://mypy-play.net/?mypy=master&python=3.10&flags=warn-unreachable&gist=18e35c8047f69e2418498f85cc8f02d0
from __future__ importannotationsimportdatetimefromtypingimportAny, Generic, TypeVar, Union, overloadS1=TypeVar("S1", int, datetime.datetime)
classSeries(Generic[S1]):
@overloaddef__new__(cls, data: datetime.datetime) ->TimestampSeries: ...
@overloaddef__new__(cls, data: dict[int, S1]) ->Series[S1]: ...
def__new__(cls, data: Union[datetime.datetime, dict[int, S1]]) ->Any:
returnclassTimestampSeries(Series[datetime.datetime]): ...
x=Series({0: 0, 1: 1})
reveal_type(x)
assertisinstance(x, Series)Note that the error only appears with --warn-unreachable.
Expected Behavior
Given that the reveal_type() shows that the type is Series[int], I would expect the subsequent isinstance() call to succeed.
Actual Behavior
main.py:20: note: Revealed type is "__main__.Series[builtins.int]"
main.py:21: error: Subclass of "Series[int]" and "TimestampSeries" cannot exist: would have inconsistent method resolution order [unreachable]
Found 1 error in 1 file (checked 1 source file)
Your Environment
See the mypy playground link.
Bug Report
The problem appeared in the pandas stubs in this issue: pandas-dev/pandas-stubs#269
There, I was told to report it here.
To Reproduce
I reduced the problem to a standalone example, but it might be possible to reduce it further:
Playground URL: https://mypy-play.net/?mypy=master&python=3.10&flags=warn-unreachable&gist=18e35c8047f69e2418498f85cc8f02d0
Note that the error only appears with
--warn-unreachable.Expected Behavior
Given that the
reveal_type()shows that the type isSeries[int], I would expect the subsequentisinstance()call to succeed.Actual Behavior
Your Environment
See the mypy playground link.