Skip to content

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

Merged
merged 4 commits into from
Mar 25, 2019
Merged

Add overloads for min/max that don't take default #2885

merged 4 commits into from
Mar 25, 2019

Conversation

msullivan
Copy link
Contributor

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?

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?
@msullivan msullivan requested a review from gvanrossum March 25, 2019 20:19
@@ -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: ...
Copy link
Member

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 ....

@@ -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]: ...
Copy link
Member

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?

Copy link
Contributor Author

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

@msullivan msullivan merged commit c526975 into master Mar 25, 2019
@msullivan msullivan deleted the minmax branch March 25, 2019 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants