Repository navigation
Substitution does not work after ParamSpec substitution of the user generic with a list of TypeVars #88965
Copy link
Copy link
Closed
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Activity
If the user generic with ParamSpec parameter substituted with a parametrised list containing TypeVar, that TypeVar cannot be substituted.
>>> from typing import * >>> T = TypeVar("T") >>> P = ParamSpec("P") >>> class X(Generic[P]): ... f: Callable[P, int] ... >>> Y = X[[int, T]] >>> Y __main__.X[(<class 'int'>, ~T)] >>> Y[str] Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/serhiy/py/cpython/Lib/typing.py", line 309, in inner return func(*args, **kwds) ^^^^^^^^^^^^^^^^^^^ File "/home/serhiy/py/cpython/Lib/typing.py", line 1028, in __getitem__ _check_generic(self, params, len(self.__parameters__)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/serhiy/py/cpython/Lib/typing.py", line 228, in _check_generic raise TypeError(f"{cls} is not a generic class") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: __main__.X[(<class 'int'>, ~T)] is not a generic class
Expected result equal to X[[int, str]].
Reacted by LeeeeT- added3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Aug 1, 2021 Hi there! I'm experiencing the same issue. Will this be fixed? @serhiy-storchaka
- added a commit that references this issue
on Mar 23, 2023 Fixed on
mainand 3.11, but we've decided not to backport to 3.10.- added a commit that references this issue
on Mar 23, 2023 Thanks! You guys are awesome! ❤️
Reacted by Alex WaygoodThanks! You guys are awesome! ❤️
@sobolevn gets all the credit on this one :)
Reacted by LeeeeT- added a commit that references this issue
on Apr 11, 2023
Metadata
Metadata
Assignees
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
ParamSpecsubstitution #102808ParamSpecsubstitution (GH-102808) #102957