Constrained TypeVars with multiple valid solutions #1168
JelleZijlstra
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Given this code:
A float is both a
SupportsInt
and aSupportsFloat
, so both constraints on the TypeVar are valid solutions. But all of mypy, pyre, and pyright simply pick the first solution. (Pytype picks "float", which I don't think should be allowed.) I feel like inference should not depend on the order in which the constraints are defined, and in pyanalyze I fall back to Any if there are multiple valid solutions.But mypy, pyre, and pyright are all happy to rely on the order of the constraints, so is it OK to do so?
Beta Was this translation helpful? Give feedback.
All reactions