New submission from Serhiy Storchaka <storchaka+cpyt...@gmail.com>:
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__. ---------- components: Interpreter Core messages: 397475 nosy: serhiy.storchaka priority: normal severity: normal status: open title: Convert None to NoneType in the union type constructor type: enhancement versions: Python 3.10, Python 3.11 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44635> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com