Skip to content

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

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

Merged
merged 1 commit into from
Jun 4, 2025

Conversation

msullivan
Copy link
Collaborator

@msullivan msullivan commented Jun 3, 2025

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
Copy link
Contributor

github-actions bot commented Jun 3, 2025

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)

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.

Thanks!

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

@JukkaL JukkaL merged commit f295bb8 into master Jun 4, 2025
19 checks passed
@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