-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add overloads for min/max that don't take default #2885
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
Conversation
PR #2833 introduced more flexible handling for the type of the default parameter, but the extra type variable caused some issues. Add another overload for the case where there is no default param. This is I think related to the issues we have had with `get` recently?
stdlib/2/__builtin__.pyi
Outdated
@@ -1283,6 +1283,8 @@ if sys.version_info >= (3,): | |||
@overload | |||
def max(_arg1: _T, _arg2: _T, *_args: _T, key: Callable[[_T], Any] = ...) -> _T: ... | |||
@overload | |||
def max(_iterable: Iterable[_T], *, key: Callable[[_T], Any] = ...,) -> _T: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need a trailing ,
after the ...
.
stdlib/2/__builtin__.pyi
Outdated
@@ -1283,6 +1283,8 @@ if sys.version_info >= (3,): | |||
@overload | |||
def max(_arg1: _T, _arg2: _T, *_args: _T, key: Callable[[_T], Any] = ...) -> _T: ... | |||
@overload | |||
def max(_iterable: Iterable[_T], *, key: Callable[[_T], Any] = ...,) -> _T: ... | |||
@overload | |||
def max(_iterable: Iterable[_T], *, key: Callable[[_T], Any] = ..., default: _VT = ...) -> Union[_T, _VT]: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't mypy still complain about calls without default=
because this overload can still be called that way? (I.e. why not make default
mandatory in this overload?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mypy will take the first overload, I think, so the change did fix the issue, but I will make it mandatory
PR #2833 introduced more flexible handling for the type of the default
parameter, but the extra type variable caused some issues. Add another
overload for the case where there is no default param.
This is I think related to the issues we have had with
get
recently?