Skip to content

When selecting an overload item for constraint template matching, treat any ParamSpec in the template as free #19487

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
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sterliakov
Copy link
Collaborator

@sterliakov sterliakov commented Jul 21, 2025

Fixes #19480. This does not fix the root of the problem, but current logic seems to work well enough to keep as-is, at least until we have an inference engine that can handle multiple alternative constraints ("any of") in some more reliable way.

This should not cause any new false positives: previously a template with paramspec could only be matched against an overload item with *args, **kwargs of some shape, and that will still be matched.

Copy link
Contributor

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

@sterliakov sterliakov marked this pull request as ready for review July 21, 2025 17:55
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.

Assignability of overloaded implementation to Proto[**P](Protocol) is overload-order-sensitive
1 participant