Commit 39dc5820 authored by Tom Niget's avatar Tom Niget

Add support for subscript setitem

parent d84f8bc7
...@@ -96,8 +96,17 @@ class ScoperBlockVisitor(ScoperVisitor): ...@@ -96,8 +96,17 @@ class ScoperBlockVisitor(ScoperVisitor):
attr_type = self.expr().visit(target) attr_type = self.expr().visit(target)
attr_type.unify(decl_val) attr_type.unify(decl_val)
return False return False
elif isinstance(target, ast.Subscript):
expr = self.expr()
left = expr.visit(target.value)
args = target.slice if type(target.slice) == tuple else [target.slice]
args = [expr.visit(e) for e in args]
if len(args) == 1:
args = args[0]
expr.make_dunder([left, args, decl_val], "setitem")
return False
else: else:
raise NotImplementedError(target) raise NotImplementedError(ast.unparse(target))
def visit_FunctionDef(self, node: ast.FunctionDef): def visit_FunctionDef(self, node: ast.FunctionDef):
argtypes = [self.visit_annotation(arg.annotation) for arg in node.args.args] argtypes = [self.visit_annotation(arg.annotation) for arg in node.args.args]
......
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