Skip to content

Commit

Permalink
fix: "no signature found for builtin" resolved (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
bagxi authored Mar 7, 2023
1 parent c7352fa commit 028030c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions hydra_slayer/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import copy
import inspect
import pydoc
import warnings

from hydra_slayer.factory import Factory, metafactory_factory

Expand Down Expand Up @@ -30,8 +31,14 @@ def _extract_positional_keyword_vars(func: Callable, kwargs: Dict) -> Tuple[Iter
# make a copy of kwargs since we don't want to modify them directly
kwargs = copy.copy(kwargs)

signature = inspect.signature(func)
type2param = {p.kind: name for name, p in signature.parameters.items()}
try:
signature = inspect.signature(func)
type2param = {p.kind: name for name, p in signature.parameters.items()}
except ValueError:
type2param = {}
warnings.warn(
f"No signature found for `{func}`, *args and **kwargs arguments cannot be extracted"
)

var_kwarg = kwargs.pop(type2param.get(inspect.Parameter.VAR_KEYWORD), {})
kwargs.update(var_kwarg)
Expand Down

0 comments on commit 028030c

Please sign in to comment.