Skip to content

Wait for all superclass method groups before processing subclasses - #22113

Merged
ilevkivskyi merged 1 commit into
python:masterfrom
pablogsal:wait-for-all-superclass-methods
Oct 5, 2026
Merged

ilevkivskyi merged 1 commit into
python:masterfrom
pablogsal:wait-for-all-superclass-methods

Conversation

@pablogsal

Copy link
Copy Markdown
Member

A nested class can split its enclosing class's methods into several groups. Processing the first group currently unblocks subclasses while later base-class methods are still waiting, which can make mypy miss incompatible assignments to inherited attributes.

Count the remaining groups for each class and only unblock subclasses after the last group has been processed. This fixes the existing ordering bug discussed in #22111 separately from that PR's performance change.

@ilevkivskyi ilevkivskyi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice, thanks!

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

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

scipy-stubs (https://github.com/scipy/scipy-stubs)
+ tests/misc/test_submodules_empty.pyi:3: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

@ilevkivskyi
ilevkivskyi merged commit 50c950b into python:master Oct 5, 2026
25 checks passed
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.

2 participants