Repository navigation
Add __new__ to tuple stub - #2092
Merged
Merged
Conversation
| def indices(self, len: int) -> Tuple[int, int, int]: ... | ||
|
|
||
| class tuple(Sequence[_T_co], Generic[_T_co]): | ||
| def __new__(cls: Type[_T], iterable: Iterable[Any]=tuple()) -> _T: ... |
Member
There was a problem hiding this comment.
The default should always be .... You should basically match __init__ here: take Iterable[_T_co] and return _T[_T_co].
| def indices(self, len: int) -> Tuple[int, int, int]: ... | ||
|
|
||
| class tuple(Sequence[_T_co], Generic[_T_co]): | ||
| def __new__(cls: Type[_T], iterable: Iterable[_T_co] = ...) -> _T[_T_co]: ... |
Member
There was a problem hiding this comment.
It looks like _T[_T_co] is illegal, although conceptually it's what we want here. We could just return tuple[_T_co, ...], but that would not play well with subclasses.
@ilevkivskyi any ideas on how to spell this type?
Member
There was a problem hiding this comment.
I think mypy ignores the return type of __new__ anyway. But IMO the type should be just (cls: Type[T], iterable: Iterable[_T_co] = ...) -> T
JelleZijlstra
approved these changes
May 9, 2018
gwk
pushed a commit
to gwk/typeshed
that referenced
this pull request
May 29, 2018
Closes: python#2091 Apply suggestions from python#2092
gvanrossum
pushed a commit
that referenced
this pull request
Jul 3, 2018
yedpodtrzitko
pushed a commit
to yedpodtrzitko/typeshed
that referenced
this pull request
Jan 23, 2019
Closes: python#2091 Apply suggestions from python#2092
yedpodtrzitko
pushed a commit
to yedpodtrzitko/typeshed
that referenced
this pull request
Jan 23, 2019
this solves python#2091 when checking Python 2 code (python#2092 only fixed it for Python 3).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #2091