Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Some differences between Python 3.6 and 3.8 #103

Open
mitar opened this issue Sep 30, 2021 · 3 comments
Open

Some differences between Python 3.6 and 3.8 #103

mitar opened this issue Sep 30, 2021 · 3 comments

Comments

@mitar
Copy link
Collaborator

mitar commented Sep 30, 2021

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
@Stewori
Copy link
Owner

Stewori commented Oct 1, 2021

Definitely, the Python 3.6 variant looks correct to me. I will consider this a proper bug to be fixed.

@mitar
Copy link
Collaborator Author

mitar commented Oct 1, 2021

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

@mitar
Copy link
Collaborator Author

mitar commented Oct 2, 2021

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])

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants