Skip to content
Discussion options

You must be logged in to vote

Hi! What you’re running into here isn’t a special “typing bug” in your code, it’s a consequence of how overload resolution and structural subtyping interact in current Python type checkers.

The key points are:

  • Static type checkers like Pyright and mypy match overloads based on the call signature alone. They don’t re-solve type variables based on deeper protocol conformance after the fact — once a candidate overload is chosen, they stick with it. This is why in your second call example Pyright picks the first overload branch and doesn’t try the other: there isn’t a mechanism in the spec that says “if this overload leads to a constraint contradiction, try another” — overload resolution is…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@RBerga06
Comment options

Answer selected by RBerga06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants