Commit 88025aeb authored by Tom Niget's avatar Tom Niget

Add support for attribute access in type annotations

parent 1d01f99a
import abc
import ast import ast
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import Optional, List from typing import Optional, List
...@@ -52,3 +53,10 @@ class TypeAnnotationVisitor(NodeVisitorSeq): ...@@ -52,3 +53,10 @@ class TypeAnnotationVisitor(NodeVisitorSeq):
def visit_List(self, node: ast.List) -> List[BaseType]: def visit_List(self, node: ast.List) -> List[BaseType]:
return [self.visit(elt) for elt in node.elts] return [self.visit(elt) for elt in node.elts]
def visit_Attribute(self, node: ast.Attribute) -> BaseType:
left = self.visit(node.value)
res = left.members[node.attr]
assert isinstance(res, TypeType)
return res.type_object
raise NotImplementedError(ast.unparse(node))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment