Skip to content
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

Issues type checking empty lists #32

Closed
mitar opened this issue Apr 5, 2018 · 2 comments
Closed

Issues type checking empty lists #32

mitar opened this issue Apr 5, 2018 · 2 comments

Comments

@mitar
Copy link
Collaborator

mitar commented Apr 5, 2018

>>> import typing
>>> from pytypes import type_util
>>> type_util._isinstance([], typing.Sequence)
True
>>> type_util._isinstance([], typing.Sequence[int])
False

False there is surprising. I understand why it happens: because internally isinstance is converted to issubclass and Sequence[Any] is not a subclass of Sequence[int].

@Stewori
Copy link
Owner

Stewori commented Apr 5, 2018

We use a special type type_util.Empty[T] to model empty sets, dicts, lists to avoid lacking covariance of mutable Any-parameters. So [] should become type_util.Empty[List] which should be subtype of Sequence[int]. Cannot tell right now why this fails, but have to investigate. (Currently busy with upcoming Python 3.7 support.)

@Stewori Stewori closed this as completed in 8f0e738 Apr 5, 2018
@Stewori
Copy link
Owner

Stewori commented Apr 5, 2018

Fixed as of 8f0e738.
Todo: Add test.

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

No branches or pull requests

2 participants