Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.1k
new protocol, overloads to list.sort, sorted; prep. to fix #4051,#4155
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
356c64dc02b7837f5601a3542d39a5a028976e0907e46d4c16ddefc0eb0297bFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -26,6 +26,12 @@ if sys.version_info >= (3, 8): | ||
| else: | ||
| from typing_extensions import Literal | ||
| class _SupportsIndex(Protocol): | ||
| def __index__(self) -> int: ... | ||
| class _SupportsLessThan(Protocol): | ||
| def __lt__(self, other: Any) -> bool: ... | ||
| _T = TypeVar('_T') | ||
| _T_co = TypeVar('_T_co', covariant=True) | ||
| _KT = TypeVar('_KT') | ||
| @@ -37,9 +43,7 @@ _T3 = TypeVar('_T3') | ||
| _T4 = TypeVar('_T4') | ||
| _T5 = TypeVar('_T5') | ||
| _TT = TypeVar('_TT', bound='type') | ||
| class _SupportsIndex(Protocol): | ||
| def __index__(self) -> int: ... | ||
| _LT = TypeVar('_LT', bound=_SupportsLessThan) | ||
| class object: | ||
| __doc__: Optional[str] | ||
| @@ -943,7 +947,10 @@ class list(MutableSequence[_T], Generic[_T]): | ||
| def remove(self, __value: _T) -> None: ... | ||
| def reverse(self) -> None: ... | ||
| if sys.version_info >= (3,): | ||
| def sort(self, *, key: Optional[Callable[[_T], Any]] = ..., reverse: bool = ...) -> None: ... | ||
| @overload | ||
| def sort(self: List[_SupportsLessThan], *, key: None = ..., reverse: bool = ...) -> None: ... | ||
| @overload | ||
| def sort(self, *, key: Callable[[_T], _SupportsLessThan], reverse: bool = ...) -> None: ... | ||
| else: | ||
| def sort(self, cmp: Callable[[_T, _T], Any] = ..., key: Callable[[_T], Any] = ..., reverse: bool = ...) -> None: ... | ||
| @@ -1539,8 +1546,13 @@ else: | ||
| def round(number: SupportsFloat, ndigits: int) -> float: ... | ||
| def setattr(__obj: Any, __name: Text, __value: Any) -> None: ... | ||
| if sys.version_info >= (3,): | ||
| @overload | ||
| def sorted(__iterable: Iterable[_LT], *, | ||
| key: None = ..., | ||
| reverse: bool = ...) -> List[_LT]: ... | ||
| @overload | ||
| def sorted(__iterable: Iterable[_T], *, | ||
| key: Optional[Callable[[_T], Any]] = ..., | ||
| key: Callable[[_T], _LT], | ||
Collaborator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here.
| ||
| reverse: bool = ...) -> List[_T]: ... | ||
| else: | ||
| def sorted(__iterable: Iterable[_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.
This must actually be
List[_LT]to avoid the invariance issue mentioned in my comment.