Skip to content

Conversation

sterliakov
Copy link
Collaborator

Fixes #18458.

When checking base class compatibility, the class being defined is not yet in scope. However, it should be equivalent to the class passed to bind_and_map_method with free typevars, as that's exactly what we are currently defining.

@sterliakov sterliakov force-pushed the bugfix/st-map-self-in-inherited-methods branch from ab8a8c3 to e715672 Compare January 14, 2025 21:18
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

pandas (https://github.com/pandas-dev/pandas)
+ pandas/io/common.py:956: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas/core/arrays/datetimes.py:174: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas/core/arrays/_mixins.py:93: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas/core/arrays/numpy_.py:48: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas/core/arrays/datetimelike.py:199: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas/core/arrays/categorical.py:247: error: Unused "type: ignore" comment  [unused-ignore]

ibis (https://github.com/ibis-project/ibis)
- ibis/expr/operations/core.py:21: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/core.py:43: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/relations.py:36: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:32: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:41: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:54: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:67: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:79: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:90: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:101: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:120: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:138: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:156: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:184: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:197: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:233: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:254: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:279: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:290: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:301: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:310: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:319: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:328: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:338: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:348: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:359: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:373: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:395: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/reductions.py:404: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/generic.py:180: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/vectorized.py:36: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/vectorized.py:44: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/operations/geospatial.py:186: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/expr/rewrites.py:29: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/common/tests/test_graph_benchmarks.py:15: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/common/tests/test_graph.py:204: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/common/tests/test_graph.py:246: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/common/tests/test_egraph.py:123: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/common/tests/test_egraph.py:158: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/common/tests/test_egraph.py:175: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/common/tests/test_egraph.py:191: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/common/tests/test_egraph.py:195: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]
- ibis/common/tests/test_egraph.py:211: error: Definition of "__recreate__" in base class "Annotable" is incompatible with definition in base class "Node"  [misc]

@sterliakov
Copy link
Collaborator Author

Hm, looks great - all removed errors are essentially equivalent to the snippet in #18458.

@sterliakov sterliakov marked this pull request as ready for review January 14, 2025 21:54
Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think this makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Self type with multiple inheritance
2 participants