question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mypy complains about inconsistent MRO when using `isinstance()` on a generic `Series` object

See original GitHub issue

To 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:open
  • Created a year ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
thomkehcommented, Oct 6, 2022
0reactions
Dr-Irvcommented, Nov 20, 2022

Bug still exists in mypy 0.990

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found