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

Fix crash when passing too many type arguments to generic base class accepting single ParamSpec#17770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
hauntsaninja merged 2 commits intopython:masterfrombrianschubert:fix/gh-17765
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletionsmypy/semanal.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5904,9 +5904,8 @@ def analyze_type_application_args(self, expr: IndexExpr) -> list[Type] | None:

if has_param_spec and num_args == 1 and types:
first_arg = get_proper_type(types[0])
if not (
len(types) == 1 and isinstance(first_arg, (Parameters, ParamSpecType, AnyType))
):
single_any = len(types) == 1 and isinstance(first_arg, AnyType)
if not (single_any or any(isinstance(t, (Parameters, ParamSpecType)) for t in types)):
types = [Parameters(types, [ARG_POS] * len(types), [None] * len(types))]

return types
Expand Down
9 changes: 9 additions & 0 deletionstest-data/unit/check-parameter-specification.test
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1836,6 +1836,15 @@ c: C[int, [int, str], str] # E: Nested parameter specifications are not allowed
reveal_type(c) # N: Revealed type is "__main__.C[Any]"
[builtins fixtures/paramspec.pyi]

[case testParamSpecInheritNoCrashOnNested]
from typing import Generic
from typing_extensions import ParamSpec

P = ParamSpec("P")
class C(Generic[P]): ...
class D(C[int, [int, str], str]): ... # E: Nested parameter specifications are not allowed
[builtins fixtures/paramspec.pyi]

[case testParamSpecConcatenateSelfType]
from typing import Callable
from typing_extensions import ParamSpec, Concatenate
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp