[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

Ken Jin report at bugs.python.org
Tue Jun 29 06:21:05 EDT 2021


Ken Jin <kenjin4096 at gmail.com> added the comment:

Yurii, thanks for the offer.

We only need to implement __getitem__ if union supports TypeVars. Which
means __parameters__ need to be implemented too (or at least a private
internal implementation of it).

I interpreted Guido's message above as to wait and see if static type
checkers even accept things like int | list[T]. Maybe he meant that if that
syntax isnt valid then theres no point for us to implement it? PEP 604
leaves out how it deals with TypeVars, so adding this behavior may require
us to update the PEP first (which will require approval from others).

Anyways, there's no rush. We probably can't backport this so we have until
the next minor release of Python (3.11 or later) to decide.

----------

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


More information about the Python-bugs-list mailing list