[New-bugs-announce] [issue44632] Union with TypeVar does not work as intended

Serhiy Storchaka report at bugs.python.org
Wed Jul 14 01:33:24 EDT 2021


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

>>> import typing
>>> int | typing.T
int | ~T
>>> typing.T | int
typing.Union[~T, int]
>>> T2 = TypeVar('T2')
>>> int | T2
typing.Union[int, ~T2]
>>> T2 | int
typing.Union[~T2, int]

There is a support of TypeVar in type.__or__, but it does not work with user defined TypeVars, only with internal TypeVars defined in the typing module.

----------
components: Interpreter Core
messages: 397466
nosy: gvanrossum, kj, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Union with TypeVar does not work as intended
type: behavior
versions: Python 3.10, Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44632>
_______________________________________


More information about the New-bugs-announce mailing list