Skip to content

Commit ff26a14

Browse files
committed
.param_spec() not available here
1 parent 45bab8c commit ff26a14

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

mypy/subtypes.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,7 @@ def g(x: int) -> int: ...
17181718
ignore_pos_arg_names=ignore_pos_arg_names,
17191719
allow_partial_overlap=allow_partial_overlap,
17201720
strict_concatenate_check=strict_concatenate_check,
1721-
map_template_paramspec=map_template_paramspec,
1721+
template_has_paramspec=map_template_paramspec and right.param_spec() is not None,
17221722
)
17231723

17241724

@@ -1755,7 +1755,7 @@ def are_parameters_compatible(
17551755
ignore_pos_arg_names: bool = False,
17561756
allow_partial_overlap: bool = False,
17571757
strict_concatenate_check: bool = False,
1758-
map_template_paramspec: bool = False,
1758+
template_has_paramspec: bool = False,
17591759
) -> bool:
17601760
"""Helper function for is_callable_compatible, used for Parameter compatibility"""
17611761
if right.is_ellipsis_args and not is_proper_subtype:
@@ -1784,8 +1784,6 @@ def are_parameters_compatible(
17841784
# a subtype of erased template type.
17851785
trivial_vararg_suffix = True
17861786

1787-
right_is_pspec = map_template_paramspec and right.param_spec() is not None
1788-
17891787
# Match up corresponding arguments and check them for compatibility. In
17901788
# every pair (argL, argR) of corresponding arguments from L and R, argL must
17911789
# be "more general" than argR if L is to be a subtype of R.
@@ -1822,7 +1820,7 @@ def _incompatible(left_arg: FormalArgument | None, right_arg: FormalArgument | N
18221820
_incompatible(left_star, right_star)
18231821
and not trivial_vararg_suffix
18241822
or _incompatible(left_star2, right_star2)
1825-
) and not right_is_pspec:
1823+
) and not template_has_paramspec:
18261824
return False
18271825

18281826
# Phase 1b: Check non-star args: for every arg right can accept, left must
@@ -1853,7 +1851,7 @@ def _incompatible(left_arg: FormalArgument | None, right_arg: FormalArgument | N
18531851
# arguments. Get all further positional args of left, and make sure
18541852
# they're more general than the corresponding member in right.
18551853
# TODO: handle suffix in UnpackType (i.e. *args: *Tuple[Ts, X, Y]).
1856-
if right_star is not None and not trivial_vararg_suffix and not right_is_pspec:
1854+
if right_star is not None and not trivial_vararg_suffix and not template_has_paramspec:
18571855
# Synthesize an anonymous formal argument for the right
18581856
right_by_position = right.try_synthesizing_arg_from_vararg(None)
18591857
assert right_by_position is not None
@@ -1880,7 +1878,7 @@ def _incompatible(left_arg: FormalArgument | None, right_arg: FormalArgument | N
18801878
# Phase 1d: Check kw args. Right has an infinite series of optional named
18811879
# arguments. Get all further named args of left, and make sure
18821880
# they're more general than the corresponding member in right.
1883-
if right_star2 is not None and not right_is_pspec:
1881+
if right_star2 is not None and not template_has_paramspec:
18841882
right_names = {name for name in right.arg_names if name is not None}
18851883
left_only_names = set()
18861884
for name, kind in zip(left.arg_names, left.arg_kinds):

0 commit comments

Comments
 (0)