Skip to content

Commit 8f4faf0

Browse files
committed
prefer _get_params_ufunc for ufuncs
1 parent 507200b commit 8f4faf0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

hypothesis-python/src/hypothesis/extra/ghostwriter.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,16 @@ def _get_params(func: Callable) -> dict[str, inspect.Parameter]:
491491
# we're out of ideas and should just re-raise the exception.
492492
raise
493493
else:
494-
# If the params we got look like an uninformative placeholder, try fallbacks.
495494
P = inspect.Parameter
496495
placeholder = [("args", P.VAR_POSITIONAL), ("kwargs", P.VAR_KEYWORD)]
497-
if [(p.name, p.kind) for p in params] == placeholder:
498-
params = _get_params_ufunc(func) or _get_params_builtin_fn(func) or params
496+
if ufunc_params := _get_params_ufunc(func):
497+
# If func is a ufunc, prefer _get_params_ufunc over get_signature,
498+
# as the latter includes keyword arguments we aren't well-equipped
499+
# to ghostwrite.
500+
params = ufunc_params
501+
elif [(p.name, p.kind) for p in params] == placeholder:
502+
# If the params we got look like an uninformative placeholder, try fallbacks.
503+
params = _get_params_builtin_fn(func) or params
499504
return _params_to_dict(params)
500505

501506

0 commit comments

Comments
 (0)