[New-bugs-announce] [issue40408] GenericAlias does not support nested type variables

Serhiy Storchaka report at bugs.python.org
Mon Apr 27 11:57:57 EDT 2020


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

While trying to replace typing._GenericAlias with GenericAlias I have found that the latter does not support nested type variables.

>>> from typing import *
>>> T = TypeVar('T')
>>> X = List[List[T]]
>>> X.__parameters__
(~T,)
>>> X[int]
typing.List[typing.List[int]]
>>> Y = list[list[T]]
>>> Y.__parameters__
()
>>> Y[int]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: There are no type variables left in list[list[~T]]

----------
components: Interpreter Core
messages: 367433
nosy: gvanrossum, levkivskyi, serhiy.storchaka
priority: normal
severity: normal
status: open
title: GenericAlias does not support nested type variables
type: behavior
versions: Python 3.9

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


More information about the New-bugs-announce mailing list