Mypy complains about inconsistent MRO when using `isinstance()` on a generic `Series` object
See original GitHub issueTo Reproduce
import pandas as pd
x: pd.Series[int] = pd.Series([1, 3, 4], name="my series")
assert isinstance(x, pd.Series) # this line produces the error below
mypy gives the following error:
repro.py:4: error: Subclass of "Series[int]" and "TimestampSeries" cannot exist: would have inconsistent method resolution order [unreachable]
pyright does not complain. Nor does mypy complain if I drop the [int]
for pd.Series
.
Please complete the following information:
- OS: Linux
- OS Version: Ubuntu 22.04
- python version: 3.10.4
- version of type checker: mypy 0.971
- version of installed
pandas-stubs
: 1.4.3.220829
Issue Analytics
- State:
- Created a year ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Inconsistent MRO error when __new__ returns a subclass and ...
Series [builtins.int]" main.py:21: error: Subclass of "Series[int]" and ... Mypy complains about inconsistent MRO when using isinstance() on a generic Series ...
Read more >Mypy Documentation - Read the Docs
Mypy is a static type checker for Python. Type checkers help ensure that you're using variables and functions in your code correctly.
Read more >How to use isinstance on a generic type in Python
This gives the error 'T' is a type variable and only valid in type context . python · mypy · Share.
Read more >Changelog — Python 3.11.1 documentation
gh-85760: Fix race condition in asyncio where process_exited() called before the pipe_data_received() leading to inconsistent output.
Read more >2.6 PDF - Pylint Documentation
to perform an explicit typecheck in Python is to use isinstance(x, ... inconsistent-mro (E0240) Inconsistent method resolution order for ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I reported it here: https://github.com/python/mypy/issues/13824
Bug still exists in mypy 0.990