macro_extractor.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:skydoc 作者: bazelbuild 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号