-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Cannot infer type argument 1 of "min" with differing default type #3354
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
Comments
I think this may be similar to #1732. |
Ah, I should have noted it only fails to typecheck with |
Yes, this is similar. And I think the solution should be probably the same: add an overload with a |
So should this be closed here and opened in typeshed instead? @srittau. |
Has been fixed! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(Apologies if this is a typeshed issue.) When calling
min
with different types for the iterable and the default, likemin(Iterable[T], default=S)
,min
often does not infer the correct type for the result, and gives a confusing error message"Cannot infer type argument 1 of "min"
. I assumed that meant it couldn't infer the type of argument 1, but I think it actually means it can't infer the first (only) type parameter in the definition:I would expect the result of
min(Iterable[T], default=S)
to be:But maybe that's hard / impossible to express with the type system?
Here's some code that illustrates the problem. Oddly, fixed-length tuples typecheck fine, but variable-length tuples do not. Explicitly specifying the type of the result (which is the same as the type parameter) does not help.
The text was updated successfully, but these errors were encountered: