Skip to content

Commit a280a44

Browse files
committed
Better comment and unified if statement
1 parent 4d2bdcb commit a280a44

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/typing_extensions.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3024,17 +3024,16 @@ def _check_generic(cls, parameters, elen=_marker):
30243024
30253025
This gives a nice error message in case of count mismatch.
30263026
"""
3027+
# If substituting a single ParamSpec with multiple arguments
3028+
# we do not check the count
30273029
if (inspect.isclass(cls) and issubclass(cls, typing.Generic)
3028-
and any(isinstance(t, ParamSpec) for t in cls.__parameters__)
3030+
and len(cls.__parameters__) == 1
3031+
and isinstance(cls.__parameters__[0], ParamSpec)
3032+
and parameters
3033+
and not _is_param_expr(parameters[0])
30293034
):
3030-
# should actually modify parameters but is immutable
3031-
if (
3032-
len(cls.__parameters__) == 1
3033-
and parameters
3034-
and not _is_param_expr(parameters[0])
3035-
):
3036-
assert isinstance(cls.__parameters__[0], ParamSpec)
3037-
return
3035+
# Generic modifies parameters variable, but here we cannot do this
3036+
return
30383037

30393038
if not elen:
30403039
raise TypeError(f"{cls} is not a generic class")

0 commit comments

Comments
 (0)