Skip to content

Avoid spurious non-overlapping eq error with metaclass with __eq__ - #19220

Merged
JukkaL merged 1 commit into
masterfrom
elvis-eq
Jun 4, 2025
Merged

JukkaL merged 1 commit into
masterfrom
elvis-eq

Conversation

@msullivan

@msullivan msullivan commented Jun 3, 2025 •

Copy link
Copy Markdown
Collaborator

Currently, doing an == on a type[Foo] where Foo has a metaclass
that defines __eq__ will spuriously produce a non-overlapping equality
error, because custom_special_method, a helper used in the check,
does not consider the TypeType case.

Fix that.

Currently, doing an `==` on a `type[Foo]` where `Foo` has a metaclass
that defines `__eq__` will spurious produce a non-overlapping equality
error, because `custom_special_method`, a helper used in the check,
does not consider the `TypeType` case.

Fix that.
@msullivan
msullivan requested review from JukkaL and jhance June 3, 2025 20:05
@github-actions

github-actions Bot commented Jun 3, 2025

Copy link
Copy Markdown
Contributor

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

antidote (https://github.com/Finistere/antidote): 1.32x slower (69.4s -> 91.5s in single noisy sample)

janus (https://github.com/aio-libs/janus): 1.63x faster (10.8s -> 6.6s in single noisy sample)

AutoSplit (https://github.com/Toufool/AutoSplit): 1.05x faster (111.7s -> 106.3s in single noisy sample)

mypy (https://github.com/python/mypy): 1.06x slower (108.7s -> 115.2s in single noisy sample)

discord.py (https://github.com/Rapptz/discord.py): 1.09x slower (266.6s -> 290.9s in single noisy sample)

@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.

Thanks!

(and it is great to have you back :-))

@JukkaL
JukkaL merged commit f295bb8 into master Jun 4, 2025
@JukkaL
JukkaL deleted the elvis-eq branch June 4, 2025 15: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.

3 participants