Remove extra space from the unparser

This commit is contained in:
Adam Turner 2022-06-14 09:46:12 +01:00
parent 873d9f6fda
commit b58ef001ac
2 changed files with 6 additions and 4 deletions

View File

@ -202,6 +202,8 @@ class _UnparseVisitor(ast.NodeVisitor):
return "%s[%s]" % (self.visit(node.value), self.visit(node.slice))
def visit_UnaryOp(self, node: ast.UnaryOp) -> str:
if not 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))
def visit_Tuple(self, node: ast.Tuple) -> str:

View File

@ -25,7 +25,7 @@ from sphinx.pycode import ast
("...", "..."), # Ellipsis
("a // b", "a // b"), # FloorDiv
("Tuple[int, int]", "Tuple[int, int]"), # Index, Subscript
("~ 1", "~ 1"), # Invert
("~1", "~1"), # Invert
("lambda x, y: x + y",
"lambda x, y: ..."), # Lambda
("[1, 2, 3]", "[1, 2, 3]"), # List
@ -42,9 +42,9 @@ from sphinx.pycode import ast
("{1, 2, 3}", "{1, 2, 3}"), # Set
("a - b", "a - b"), # Sub
("'str'", "'str'"), # Str
("+ a", "+ a"), # UAdd
("- 1", "- 1"), # UnaryOp
("- a", "- a"), # USub
("+a", "+a"), # UAdd
("-1", "-1"), # UnaryOp
("-a", "-a"), # USub
("(1, 2, 3)", "(1, 2, 3)"), # Tuple
("()", "()"), # Tuple (empty)
("(1,)", "(1,)"), # Tuple (single item)