Skip to content

Commit 80bf4b5

Browse files
h-joocopybara-github
authored andcommitted
Do not assert at this location. It is possible that the assertion triggers but pytype is indeed looking at a ParamSpec being passed in.
PiperOrigin-RevId: 754605988
1 parent 547024f commit 80bf4b5

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

pytype/matcher.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,8 +1199,6 @@ def _match_subst_against_subst(
11991199
old_subst.copy(t=b1.AssignToNewVariable(self._node)),
12001200
)
12011201
else:
1202-
# If t isn't a TypeVar here it should be a ParamSpec
1203-
assert t in self._paramspecs
12041202
new_var = self.ctx.program.NewVariable()
12051203
new_var.PasteBindingWithNewData(
12061204
b2, self.ctx.convert.get_maybe_abstract_instance(b2.data)

pytype/tests/test_paramspec.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,25 @@ def f(x: int, y) -> Any: ...
611611
""",
612612
)
613613

614+
def test_paramspec_in_callable_as_param_not_fail(self):
615+
self.Check("""
616+
from typing import ParamSpec, Callable
617+
618+
_P = ParamSpec("_P")
619+
LogTextFn = Callable[_P, None]
620+
621+
class ModelHandlerInterface:
622+
def __init__(self, log_text: LogTextFn, log_code: LogTextFn):
623+
pass
624+
625+
class GeminiModelHandler(ModelHandlerInterface):
626+
def __init__(self, log_text: LogTextFn, log_code: LogTextFn):
627+
super().__init__(
628+
log_text,
629+
log_code,
630+
)
631+
""")
632+
614633

615634
class ContextlibTest(test_base.BaseTest):
616635
"""Test some more complex uses of contextlib."""

0 commit comments

Comments
 (0)