Skip to content

Conversation

@pkch
Copy link
Contributor

@pkch pkch commented Mar 14, 2017

Fixes #997

def iter(function: Callable[[], _T], sentinel: _T) -> Iterator[_T]: ...
def isinstance(o: object, t: Union[type, Tuple[type, ...]]) -> bool: ...
def issubclass(cls: type, classinfo: Union[type, Tuple[type, ...]]) -> bool: ...
def isinstance(o: object, t: Union[type, Tuple[Union[type, Tuple], ...]]) -> bool: ...
Copy link
Member

Choose a reason for hiding this comment

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

@pkch @gvanrossum
I think here and below it should be Tuple[type, ...] no just Tuple at the end.
Otherwise isinstance(obj, ((1, 2), (3, 4)))will be valid.

This also applies to Python 3 stub.

Copy link
Member

Choose a reason for hiding this comment

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

The problem is that the tuple can be arbitrarily nested. Excluding that example would also exclude isinstance(x, (((int, int), int), int)).

Copy link
Member

Choose a reason for hiding this comment

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

OK, I still prefer the restrictive version a bit more, but this is not important. Anyway, there is no perfect solution until we support recursive types. (Btw, they are in my plans right after Protocols).

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