Skip to content

Tighten metaclass __call__ handling in protocols #19191

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 1, 2025

Conversation

ilevkivskyi
Copy link
Member

Fixes #19184

This fixes an (edge-case) regression introduced in 1.16. Fix is straightforward, only ignore __call__ if it comes from an actual metaclass.

Copy link
Contributor

github-actions bot commented Jun 1, 2025

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

nox (https://github.com/wntrblm/nox): 1.27x slower (25.1s -> 32.0s in single noisy sample)

typeshed-stats (https://github.com/AlexWaygood/typeshed-stats): 1.64x slower (57.9s -> 95.1s in single noisy sample)

materialize (https://github.com/MaterializeInc/materialize): 1.05x slower (134.2s -> 141.0s in single noisy sample)

scikit-build-core (https://github.com/scikit-build/scikit-build-core): 1.11x slower (42.7s -> 47.6s in single noisy sample)

discord.py (https://github.com/Rapptz/discord.py): 1.05x faster (306.2s -> 290.3s in single noisy sample)

@hauntsaninja hauntsaninja merged commit 5fbfff9 into python:master Jun 1, 2025
19 checks passed
@ilevkivskyi ilevkivskyi deleted the fix-proto-meta-any branch June 1, 2025 01:36
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.

[1.16] Regression in inferring type via unittest.mock.Mock
2 participants