def get_type(expr):
"""Find the type of an expression.
Args:
expr: The expression to check.
Returns:
The type of the expression.
"""
if isinstance(expr, ast.Num):
return build_pb2.Attribute.INTEGER
elif isinstance(expr, ast.Str):
return build_pb2.Attribute.STRING
elif isinstance(expr, ast.List):
return build_pb2.Attribute.STRING_LIST
elif isinstance(expr, ast.Name) and (expr.id == "True" or expr.id == "False"):
return build_pb2.Attribute.BOOLEAN
else:
return build_pb2.Attribute.UNKNOWN
评论列表
文章目录