Expand comment

This commit is contained in:
Adam Turner 2022-06-15 09:31:25 +01:00
parent 3dc6ed166f
commit 05b835114b

View File

@ -202,7 +202,8 @@ class _UnparseVisitor(ast.NodeVisitor):
return "%s[%s]" % (self.visit(node.value), self.visit(node.slice)) return "%s[%s]" % (self.visit(node.value), self.visit(node.slice))
def visit_UnaryOp(self, node: ast.UnaryOp) -> str: def visit_UnaryOp(self, node: ast.UnaryOp) -> str:
# UnaryOp is one of {UAdd, USub, Invert, Not}. Only Not needs a space. # UnaryOp is one of {UAdd, USub, Invert, Not}, which refer to ``+x``,
# ``-x``, ``~x``, and ``not x``. Only Not needs a space.
if isinstance(node.op, ast.Not): if isinstance(node.op, ast.Not):
return "%s %s" % (self.visit(node.op), self.visit(node.operand)) return "%s %s" % (self.visit(node.op), self.visit(node.operand))
return "%s%s" % (self.visit(node.op), self.visit(node.operand)) return "%s%s" % (self.visit(node.op), self.visit(node.operand))