Skip to content

Commit

Permalink
Fix type bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelMarcelino committed Oct 8, 2022
1 parent 115aad6 commit bf101fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions py2many/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,12 @@ def _annotate(node, typename: str):

def visit_List(self, node):
self.generic_visit(node)
self._visit_container_type(node, typename="List")
self._visit_container_type(node, typename="list")
return node

def visit_Tuple(self, node: ast.Tuple) -> Any:
self.generic_visit(node)
self._visit_container_type(node, typename="Tuple")
self._visit_container_type(node, typename="tuple")
return node

def _visit_container_type(self, node, typename="Any"):
Expand Down Expand Up @@ -1018,3 +1018,7 @@ def visit_With(self, node: ast.With) -> Any:
self.visit(n)
self._block_annotations = prev_block_anns
return node

def visit_BoolOp(self, node: ast.BoolOp) -> Any:
node.annotation = ast.Name(id="bool")
return node
6 changes: 3 additions & 3 deletions pyjl/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,12 @@ def visit_Call(self, node: ast.Call) -> str:
fndef_args = [ast.arg(arg="self")] + fndef_args
converted = []
for varg, fnarg, node_arg in zip(vargs, fndef_args, node.args):
actual_type = self._generic_typename_from_annotation(node_arg)
declared_type = self._generic_typename_from_annotation(fnarg)
actual_type = self._typename_from_annotation(node_arg)
declared_type = self._typename_from_annotation(fnarg)
if declared_type and actual_type and declared_type != self._default_type \
and actual_type != self._default_type and actual_type != declared_type and \
not actual_type.startswith("Optional"): # TODO: Skip conversion of Optional for now
converted.append(f"convert({self._map_type(declared_type)}, {varg})")
converted.append(f"convert({declared_type}, {varg})")
else:
converted.append(varg)
else:
Expand Down

0 comments on commit bf101fc

Please sign in to comment.