Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-20476: Fix AssertionError (too many plugin hook passes) on dataclass attribute redefinition #20521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
a12k wants to merge 3 commits into python:master
base: master
Choose a base branch
Loading
from a12k:fix/dataclass-redef-crash

Conversation

@a12k
Copy link
Contributor

@a12k a12k commented Jan 4, 2026
edited
Loading

Fixes gh-20476

There was a crash in the dataclass plugin when an attribute was re-defined, to wit: AssertionError: Internal error: too many class plugin hook passes from the repro script in the issue. Changed a couple things here:

  1. Added a check in mypy/plugins/dataclasses.py detect re-defined attrs. If so, the plugin now skips the transformation for that attribute, allowing the reporting of a [no-redef] error instead of triggering a crash.
  2. Added a guard in mypy/semanal_main.py to break out of potential infinite loops caused by class plugin hooks that don't reach a stable state.

And added a test! All other tests pass as well.

@a12k a12k marked this pull request as draft January 4, 2026 11:55

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Jan 4, 2026

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@a12k a12k marked this pull request as ready for review January 4, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

mypy crashes on a dataclass

1 participant

AltStyle によって変換されたページ (->オリジナル) /