3 def extract_decorators(fn_ast: ast.FunctionDef, fname = None, only_name=False):
4 decors = fn_ast.decorator_list
9 if isinstance(decor, ast.Name):
11 elif isinstance(decor, ast.Call):
12 if not isinstance(decor.func, ast.Name):
16 _kwargs = decor.keywords
20 if fname and name != fname:
30 if isinstance(arg, ast.Constant):
31 unpacked.append(arg.value)
34 if isinstance(kwarg.value, ast.Constant):
35 kwargs[kwarg.arg] = kwarg.value.value
37 results.append((name, unpacked, kwargs))
41 def to_displayable(name):
42 l = name.strip().split('_')
43 for i, s in enumerate(l):
44 l[i] = str.upper(s[0]) + s[1:]
47 def is_primitive(val):
48 return val in [int, str, bool]
51 basic = [int, str, bool]
54 any([isinstance(val, x) for x in basic])