Message397475
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__. |
|
Date |
User |
Action |
Args |
2021-07-14 10:51:57 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka |
2021-07-14 10:51:57 | serhiy.storchaka | set | messageid: <1626259917.98.0.435705646715.issue44635@roundup.psfhosted.org> |
2021-07-14 10:51:57 | serhiy.storchaka | link | issue44635 messages |
2021-07-14 10:51:57 | serhiy.storchaka | create | |
|