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

Alias that is generic over a ParamSpec cannot be further specialized #124445

Open
Labels
@JelleZijlstra

Description

@JelleZijlstra

A type alias that is generic over a ParamSpec can be specialized with a list of types, and if this list includes a TypeVar, the resulting alias is still generic to type checkers, but it cannot be subscripted again at runtime.

>>> from collections.abc import Callable>>> type X[**P] = Callable[P, int]>>> T = TypeVar("T")>>> X[[T]]X[[~T]]>>> X[[T]][str]Traceback (most recent call last):  File "<python-input-14>", line 1, in <module>    X[[T]][str]    ~~~~~~^^^^^TypeError: X[[~T]] is not a generic class

Pyright accepts this code, and I think it's right:https://pyright-play.net/?strict=true&code=GYJw9gtgBAxmA28CmMAuBLMA7AzgOgEMAjGKdCABzBFSgGEDFjkAoUSKVATwvSwHMylarQAqPJADUCIFi1FQAvFHEUpMgBQAiUVoCUc7mqgANANoAqCwAUAukvqN4zJGesAaMllS2WJhcrmZqK2viwAJkjAUMAaAB4AXKaiZjioILZ6CSxQuVAgSABuSIwA%2BkZI8Xq5AMRQGmkg1QC0AHxeqCxAA

Reported by@Daraan inhttps://github.com/python/typing_extensions/pull/449/files#r1771594266.

I believe this could be fixed by making_Py_make_parameters ingenericaliasobject.c recurse into lists.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp