[New-bugs-announce] [issue44490] PEP 604 Union (int | str) doesn't have __parameters__
Ken Jin
report at bugs.python.org
Tue Jun 22 09:29:59 EDT 2021
New submission from Ken Jin <kenjin4096 at gmail.com>:
Recently I noticed that the new PEP 604 Union type doesn't collect type variables:
from typing import TypeVar
T = TypeVar('T')
(int | list[T]).__parameters__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'types.Union' object has no attribute '__parameters__'
Whereas the typing.Union version has __parameters__. Is this behavior intentional?
The downside to this is that things like this don't work:
alias: TypeAlias = int | list[T]
alias[str] # Error!
----------
messages: 396329
nosy: Jelle Zijlstra, gvanrossum, kj, levkivskyi
priority: normal
severity: normal
status: open
title: PEP 604 Union (int | str) doesn't have __parameters__
versions: Python 3.10, Python 3.11
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44490>
_______________________________________
More information about the New-bugs-announce
mailing list