def resolve_type_annotation(annotation):
"""Type annotation resolution."""
if isinstance(annotation, ast.Name):
if annotation.id == 'bool':
return BooleanLyraType()
elif annotation.id == 'int':
return IntegerLyraType()
elif annotation.id == 'float':
return FloatLyraType()
elif annotation.id == 'str':
return StringLyraType()
if isinstance(annotation, ast.Subscript):
if annotation.value.id == 'List':
value = resolve_type_annotation(annotation.slice.value)
return ListLyraType(value)
raise NotImplementedError(f"Type annotation {annotation} is not yet supported!")
评论列表
文章目录