Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug or new behavior of generics parameterization? #98852

Closed
Assignees
JelleZijlstraserhiy-storchaka
Labels
3.10only security fixes3.11only security fixes3.12only security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errortype-crashA hard crash of the interpreter, possibly with a core dump
@Eclips4

Description

@Eclips4
fromtypingimportTypeVar,Generic,CallableT=TypeVar("T")P=TypeVar("P")classTest(Generic[T]): ...S=Callable[[Test],P]deftest(arg:S[T]): ...

On python3.11 i can't run this code. Code falls on an attempt to parameterizeS
Traceback:

Traceback (most recent call last):  File "C:\Users\KIRILL-1\PycharmProjects\dataclass_factory\exp.py", line 12, in <module>                      def test(arg: S[T]): ...                                                                                                 ~^^^                                                                                       File "C:\Users\KIRILL-1\AppData\Local\Programs\Python\Python311\Lib\typing.py", line 360, in inner           return cached(*args, **kwds)           ^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\KIRILL-1\AppData\Local\Programs\Python\Python311\Lib\typing.py", line 1391, in __getitem__    new_args = self._determine_new_args(args)               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\KIRILL-1\AppData\Local\Programs\Python\Python311\Lib\typing.py", line 1440, in _determine_new_args    subargs.append(new_arg_by_param[x])                   ~~~~~~~~~~~~~~~~^^^KeyError: ~T

How i understand, in 3.11, an attempt is being made to parameterizeTest inS, but in 3.10 - not
Is it new behavior or a bug?

Metadata

Metadata

Labels

3.10only security fixes3.11only security fixes3.12only security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errortype-crashA hard crash of the interpreter, possibly with a core dump

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp