(func, stripself=False)
return func_args
Return the argument name list of a callable
Return the argument name list of a callable
Return the argument name list of a callable
def get_func_args(func, stripself=False):
    """Return the argument name list of a callable"""
    if inspect.isfunction(func):
        spec = inspect.getfullargspec(func)
        func_args = spec.args + spec.kwonlyargs
    elif inspect.isclass(func):
        return get_func_args(func.__init__, True)
    elif inspect.ismethod(func):
        return get_func_args(func.__func__, True)
    elif inspect.ismethoddescriptor(func):
        return []
    elif isinstance(func, partial):
        return [x for x in get_func_args(func.func)[len(func.args):]
                if not (func.keywords and x in func.keywords)]
    elif hasattr(func, '__call__'):
        if inspect.isroutine(func):
            return []
        elif getattr(func, '__name__', None) == '__call__':
            return []
        else:
            return get_func_args(func.__call__, True)
    else:
        raise TypeError(f'{type(func)} is not callable')
    if stripself:
        func_args.pop(0)
    return func_args
def get_func_args ( func , stripself = False ) : if inspect . isfunction ( func ) : spec = inspect . getfullargspec ( func ) func_args = spec . args + spec . kwonlyargs elif inspect . isclass ( func ) : return get_func_args ( func . __init__ , True ) elif inspect . ismethod ( func ) : return get_func_args ( func . __func__ , True ) elif inspect . ismethoddescriptor ( func ) : return [ ] elif isinstance ( func , partial ) : return [ x for x in get_func_args ( func . func ) [ len ( func . args ) : ] if not ( func . keywords and x in func . keywords ) ] elif hasattr ( func , '__call__' ) : if inspect . isroutine ( func ) : return [ ] elif getattr ( func , '__name__' , None ) == '__call__' : return [ ] else : return get_func_args ( func . __call__ , True ) else : raise TypeError ( f'{type(func)} is not callable' ) if stripself : func_args . pop ( 0 ) return func_args