Commit c25f0293 authored by Tom Niget's avatar Tom Niget

Add support for unary operations in typing

parent 18f3dca4
...@@ -209,7 +209,13 @@ class ScoperExprVisitor(ScoperVisitor): ...@@ -209,7 +209,13 @@ class ScoperExprVisitor(ScoperVisitor):
return self.make_dunder([left, *args], "getitem") return self.make_dunder([left, *args], "getitem")
def visit_UnaryOp(self, node: ast.UnaryOp) -> BaseType: def visit_UnaryOp(self, node: ast.UnaryOp) -> BaseType:
raise NotImplementedError(node) val = self.visit(node.operand)
if isinstance(node.op, ast.Not):
return TY_BOOL
try:
return self.make_dunder([val], DUNDER[type(node.op)])
except IncompatibleTypesError as e:
raise IncompatibleTypesError(f"{e} in `{ast.unparse(node)}`")
def visit_IfExp(self, node: ast.IfExp) -> BaseType: def visit_IfExp(self, node: ast.IfExp) -> BaseType:
self.visit(node.test) self.visit(node.test)
......
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