New submission from Ken Jin <kenjin4...@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 <rep...@bugs.python.org> <https://bugs.python.org/issue44490> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com