Skip to content

Commit 9518ad0

Browse files
committed
Error when Param types are used without Params wrapper
Callable[[Param[...], ...], ret] now raises TypeError instead of silently producing wrong results. Must use Callable[Params[...], ret].
1 parent 62ff846 commit 9518ad0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

typemap/type_eval/_eval_operators.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,13 @@ def _callable_type_to_signature(callable_type: object) -> inspect.Signature:
547547
# Standard callable (no Params wrapping) — build simple
548548
# positional parameters from the type list
549549
if isinstance(param_types, (list, tuple)):
550+
# Error if someone passes Param types without Params wrapper
551+
for t in param_types:
552+
if typing.get_origin(t) is Param:
553+
raise TypeError(
554+
f"Param types must be wrapped in Params[...], "
555+
f"got Callable[[{t}, ...], ...]"
556+
)
550557
params = []
551558
for i, t in enumerate(param_types):
552559
params.append(

0 commit comments

Comments
 (0)