Permalink
Browse files

typecheck: Add missing type signatures

  • Loading branch information...
simeonkr authored and justinpark715 committed Jun 6, 2018
1 parent 29fe0b3 commit 1dccd32982569f171d614f3502b8373b948a3f95
Showing with 7 additions and 9 deletions.
  1. +1 −1 .gitignore
  2. +1 −1 python_ta/transforms/type_inference_visitor.py
  3. +5 −7 python_ta/typecheck/base.py
View
@@ -19,4 +19,4 @@ __pycache__/
*.DS_Store
# .png files in test_type_inference
tests/test_type_inference/png*
tests/test_type_inference/png*
@@ -279,7 +279,7 @@ def lookup_type(self, node, name):
tvar = self._closest_frame(node, name).type_environment.lookup_in_env(name)
return self.type_constraints.resolve(tvar).getValue()
def lookup_typevar(self, node, name):
def lookup_typevar(self, node: NodeNG, name: str):
return self._closest_frame(node, name).type_environment.lookup_in_env(name)
##############################################################################
@@ -21,9 +21,7 @@ def __init__(self, node_type: type, ast_node: Optional[NodeNG] = None):
self.adj_list = []
self.ast_node = ast_node
def __eq__(self, other):
if not isinstance(other, _TNode):
return False
def __eq__(self, other: '_TNode'):
if str(self.type) == str(other.type):
return True
else:
@@ -273,10 +271,9 @@ def _make_set(self, t: type, ast_node: Optional[NodeNG] = None, add_to_nodes=Tru
def get_tnode(self, t: type, add_to_nodes=True) -> _TNode:
try:
node = self.type_to_tnode[str(t)]
return node
except KeyError:
node = self._make_set(t, None, add_to_nodes)
return node
return node
###########################################################################
# Type lookup ("find")
@@ -299,9 +296,10 @@ def resolve(self, t: type) -> TypeInfo:
def is_concrete(self, type):
if isinstance(type, GenericMeta):
return all([self.is_concrete(arg) for arg in type.__args__])
return not isinstance(type, TypeVar)
else:
return not isinstance(type, TypeVar)
def find_parent(self, tn: _TNode) -> _TNode:
def find_parent(self, tn: _TNode) -> Optional[_TNode]:
"""Do a bfs starting from tn to find a _TNode that has a parent."""
if tn.parent:
return tn.parent

0 comments on commit 1dccd32

Please sign in to comment.