Open Arfey opened 2 years ago
import trafaret as trf @trf.guard(a=trf.Int) def foo(*, a=1): pass foo() # GuardError: {'a': DataError('is required')}
problem related to defaults property from FullArgSpec class
defaults
FullArgSpec
def foo(*, a=1): pass def bar(a=1): pass getargspec(foo) # FullArgSpec(args=[], varargs=None, varkw=None, defaults=None, kwonlyargs=['a'], kwonlydefaults={'a': 1}, annotations={}) getargspec(bar) # FullArgSpec(args=['a'], varargs=None, varkw=None, defaults=(1,), kwonlyargs=[], kwonlydefaults=None, annotations={})
https://github.com/Deepwalker/trafaret/blob/master/trafaret/base.py#L1493-L1496
here we need try to use the kwonlydefaults mapping
kwonlydefaults
committed some code, will make a release soon
pls check 2.1.1 btw if you like this project, maybe we can convert into org etc.
thx, i will check
problem related to
defaults
property fromFullArgSpec
classhttps://github.com/Deepwalker/trafaret/blob/master/trafaret/base.py#L1493-L1496
here we need try to use the
kwonlydefaults
mapping