pytypes
pytypes copied to clipboard
Some differences between Python 3.6 and 3.8
I know that Python 3.7/3.8 support is still in progress and I was testing the master
branch and found some differences so I am reporting them to maybe use them as unit tests. With Python 3.6:
>>> import typing
>>> from pytypes import type_util
>>> type_util._issubclass(type_util.deep_type({}), typing.Union[typing.Dict, type(None)])
True
>>> type_util._issubclass(type_util.deep_type({}), typing.Union[typing.Dict[str, typing.Any], type(None)])
True
>>> type_util._issubclass(type_util.deep_type({}), typing.Dict[str, typing.Any])
True
Python 3.8:
>>> import typing
>>> from pytypes import type_util
>>> type_util._issubclass(type_util.deep_type({}), typing.Union[typing.Dict, type(None)])
True
>>> type_util._issubclass(type_util.deep_type({}), typing.Union[typing.Dict[str, typing.Any], type(None)])
False
>>> type_util._issubclass(type_util.deep_type({}), typing.Dict[str, typing.Any])
True
Definitely, the Python 3.6 variant looks correct to me. I will consider this a proper bug to be fixed.
Another set. Python 3.6:
>>> import typing
>>> from pytypes import type_util
>>> class Foo(dict):
... pass
...
>>> type_util._issubclass(type_util.deep_type({}), dict)
True
>>> type_util._issubclass(type_util.deep_type({}), typing.Dict)
True
>>> type_util._issubclass(type_util.deep_type(Foo()), typing.Dict)
True
Python 3.8:
>>> import typing
>>> from pytypes import type_util
>>> class Foo(dict):
... pass
...
>>> type_util._issubclass(type_util.deep_type({}), dict)
True
>>> type_util._issubclass(type_util.deep_type({}), typing.Dict)
True
>>> type_util._issubclass(type_util.deep_type(Foo()), typing.Dict)
False
Another difference. It should be True
, but on Python 3.8 returns False
.
type_util._issubclass(type_util.deep_type([{'cc': 1, 'dd': 2}, {'ee': 1, 'ff': 2}]), typing.Sequence[object])