This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients serhiy.storchaka
Date 2021-07-14.10:51:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1626259917.98.0.435705646715.issue44635@roundup.psfhosted.org>
In-reply-to
Content
There is a difference between typing.Union and the builtin union type in representing None in __args__:

>>> import typing
>>> typing.Union[int, None].__args__
(<class 'int'>, <class 'NoneType'>)
>>> typing.Union[int, type(None)].__args__
(<class 'int'>, <class 'NoneType'>)
>>> (int | None).__args__
(<class 'int'>, None)
>>> (int | type(None)).__args__
(<class 'int'>, <class 'NoneType'>)

The former converts None to NoneType, the latter leaves it as is, and only performs conversion in __instancecheck__ and __subclasscheck__. In the discussion for issue44606 it was proposed to convert None to NoneType in the union type constructor to make more uniform with typing.Union and simplify __instancecheck__ and __subclasscheck__.
History
Date User Action Args
2021-07-14 10:51:57serhiy.storchakasetrecipients: + serhiy.storchaka
2021-07-14 10:51:57serhiy.storchakasetmessageid: <1626259917.98.0.435705646715.issue44635@roundup.psfhosted.org>
2021-07-14 10:51:57serhiy.storchakalinkissue44635 messages
2021-07-14 10:51:57serhiy.storchakacreate