@@ -531,11 +531,13 @@ def failure_raiser(validation_callable, # type: ValidationCallableOrLambda
531531 should_wrap_failures = (failure_type is not None ) or (help_msg is not None ) or (len (kw_context_args ) > 0 )
532532 typ = failure_type if failure_type is not None else InvalidValue
533533
534+ is_mini = False
534535 if is_mini_lambda (validation_callable ):
536+ is_mini = True
535537 validation_callable = validation_callable .as_function ()
536538
537539 # general case - adapt to the signature required (val, ctx), (*args) or (val, **ctx)
538- call_it = make_callable (validation_callable )
540+ call_it = make_callable (validation_callable , is_mini_lambda = is_mini )
539541
540542 def raiser (x , ** ctx ):
541543 """ Wraps validation_callable to raise a failure_type_or_help_msg in case of failure """
@@ -723,24 +725,31 @@ def pop_kwargs(kwargs,
723725 return all_arguments
724726
725727
726- def make_callable (f ):
728+ def make_callable (f , is_mini_lambda = False ):
727729 # inspect the signature to determine if the **kw_context_args should be passed along
728730 # Here we do not want to use inspect.signature but getfullargspec to be faster, but the counterpart is that we have
729731 # a lot of portability-related code to handle.... :(
730- try :
731- args , varargs , varkwargs , defaults = getfullargspec (f , skip_bound_arg = True )[0 :4 ]
732-
733- nbargs = len (args ) if args is not None else 0
734- nbvarargs = 1 if varargs is not None else 0
735- nbkwargs = 1 if varkwargs is not None else 0
736- nbdefaults = len (defaults ) if defaults is not None else 0
737- except IsBuiltInError :
738- # built-ins: TypeError: <built-in function isinstance> is not a Python function
739- # assume signature with a single positional argument
732+
733+ if is_mini_lambda :
740734 nbargs = 1
741735 nbvarargs = 0
742736 nbkwargs = 0
743737 nbdefaults = 0
738+ else :
739+ try :
740+ args , varargs , varkwargs , defaults = getfullargspec (f , skip_bound_arg = True )[0 :4 ]
741+
742+ nbargs = len (args ) if args is not None else 0
743+ nbvarargs = 1 if varargs is not None else 0
744+ nbkwargs = 1 if varkwargs is not None else 0
745+ nbdefaults = len (defaults ) if defaults is not None else 0
746+ except IsBuiltInError :
747+ # built-ins: TypeError: <built-in function isinstance> is not a Python function
748+ # assume signature with a single positional argument
749+ nbargs = 1
750+ nbvarargs = 0
751+ nbkwargs = 0
752+ nbdefaults = 0
744753
745754 if (nbargs == 1 ) or (nbvarargs >= 1 ) or (nbargs >= 2 and nbdefaults >= (nbargs - 1 )): # can it receive 1 positional argument ?
746755 if nbkwargs == 0 : # can it also receive var-keyword arguments ?
0 commit comments