This commit is contained in:
+18
-3
@@ -27,10 +27,9 @@ def forwards_to(func_inner, nfilled=0, appended_kwargs=None):
|
||||
return deco
|
||||
|
||||
|
||||
|
||||
'''
|
||||
def get_args(func):
|
||||
spec = inspect.signature(func)
|
||||
#spec = inspect.getfullargspec(func) #TODO replace by inspect.signature?
|
||||
spec = inspect.getfullargspec(func) #TODO replace by inspect.signature?
|
||||
all_args = spec.args
|
||||
|
||||
defaults = spec.defaults or []
|
||||
@@ -45,7 +44,23 @@ def get_args(func):
|
||||
kw.update(kwonly)
|
||||
|
||||
return pos, kw
|
||||
'''
|
||||
|
||||
def get_args(func):
|
||||
sig = inspect.signature(func)
|
||||
pos = []
|
||||
kw = {}
|
||||
|
||||
for name, param in sig.parameters.items():
|
||||
if param.kind in (inspect.Parameter.POSITIONAL_ONLY, inspect.Parameter.POSITIONAL_OR_KEYWORD):
|
||||
if param.default is inspect._empty:
|
||||
pos.append(name)
|
||||
else:
|
||||
kw[name] = param.default
|
||||
elif param.kind == inspect.Parameter.KEYWORD_ONLY:
|
||||
kw[name] = param.default if param.default is not inspect._empty else inspect._empty
|
||||
|
||||
return pos, kw
|
||||
|
||||
def split_at(lst, index):
|
||||
return lst[:index], lst[index:]
|
||||
|
||||
Reference in New Issue
Block a user