[issue44801] Type expression is coerced to a list of parameter arguments in substitution of ParamSpec

Serhiy Storchaka report at bugs.python.org
Sun Aug 1 03:08:58 EDT 2021


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

Type expression is coerced to a list of parameter arguments in substitution of ParamSpec. For example:

>>> from typing import *
>>> T = TypeVar('T')
>>> P = ParamSpec('P')
>>> C = Callable[P, T]
>>> C[int, str]
typing.Callable[[int], str]

int becomes [int]. There is even a dedicated test for this.

But it is not followed from PEP 612. Furthermore, it contradicts one of examples in the PEP:

>>> class X(Generic[T, P]):
...     f: Callable[P, int]
...     x: T
... 
>>> X[int, int]  # Should be rejected
__main__.X[int, int]

It makes the implementation (at least the code in issue44796) more complex and makes the user code more errorprone.

----------
messages: 398687
nosy: gvanrossum, kj, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Type expression is coerced to a list of parameter arguments in substitution of ParamSpec

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


More information about the Python-bugs-list mailing list