gh-92671: Don't omit parentheses when unparsing empty tuples (GH-92673)

(cherry picked from commit f6fd8aac13)

Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
This commit is contained in:
Miss Islington (bot) 2022-05-16 06:01:34 -07:00 committed by GitHub
parent 2ef6a986ee
commit 52e6596fb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View file

@ -1335,7 +1335,11 @@ class _Unparser(NodeVisitor):
)
def visit_Tuple(self, node):
with self.require_parens(_Precedence.TUPLE, node):
with self.delimit_if(
"(",
")",
len(node.elts) == 0 or self.get_precedence(node) > _Precedence.TUPLE
):
self.items_view(self.traverse, node.elts)
unop = {"Invert": "~", "Not": "not", "UAdd": "+", "USub": "-"}