Skip to content

Conversation

@a12k
Copy link
Contributor

@a12k a12k commented Jan 4, 2026

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
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mypy crashes on a dataclass

1 participant