MCPcopy Create free account
hub / github.com/SourceCode-AI/aura / get_value

Function get_value

aura/analyzers/python_src_inspector.py:87–107  ·  view source on GitHub ↗
(attr)

Source from the content-addressed store, hash-verified

85
86
87def get_value(attr):
88 t = type(attr)
89
90 if attr is None:
91 return attr
92 elif t in BUILTIN_PURE: # We could also use isinstance but that is slow compared to array lookup
93 return attr
94 elif isinstance(attr, BUILTIN_BYTES):
95 return decode_bytes(attr)
96 elif isinstance(attr, BUILTIN_STR):
97 return decode_str(attr)
98 elif t == list:
99 return list(map(get_value, attr)) # map is faster then list comprehension
100 elif isinstance(attr, ast.AST):
101 return ast2json(attr)
102 elif type(attr) == type(Ellipsis):
103 return {"_type": "Ellipsis"}
104 elif t == complex:
105 return {"_type": "complex", "real": attr.real, "imag": attr.imag}
106 else:
107 raise ValueError("Could not serialize given value {}".format(repr(attr)))
108
109
110def get_builtins():

Callers 1

ast2jsonFunction · 0.85

Calls 3

decode_bytesFunction · 0.85
decode_strFunction · 0.85
ast2jsonFunction · 0.85

Tested by

no test coverage detected