You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We could probably work around this in typeshed for the 2-arity case of max() by using a separate type var for the arguments and returning an union. The base problem is that mypy looks for a common base type in case like this, though, and only finds object. In my opinion it would be preferable to experiment with what happens if mypy would infer a union instead.
This is arguably a bug / limitation in mypy rather than a problem with the typeshed definition. The problem is that mypy uses a "join" operation to widen types in its type constraint solver rather than using a union operation.
The above sample type checks fine with pyright, which uses unions to widen types in its constraint solver. The return type of the call to max is int | Decimal.
error: Value of type variable "SupportsLessThanT" of "max" cannot be "object"
I would expect this to pass.
The text was updated successfully, but these errors were encountered: