Skip to content

Conversation

@ltworf
Copy link
Contributor

@ltworf ltworf commented May 3, 2018

Closes: #2091

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Closes: #2091

Apply suggestions from #2092
@JelleZijlstra JelleZijlstra merged commit d289c20 into python:master May 9, 2018
gwk pushed a commit to gwk/typeshed that referenced this pull request May 29, 2018
gvanrossum pushed a commit that referenced this pull request Jul 3, 2018
this solves #2091 when checking Python 2 code (#2092 only fixed it for Python 3).
yedpodtrzitko pushed a commit to yedpodtrzitko/typeshed that referenced this pull request Jan 23, 2019
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).
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.

3 participants