diff options
author | Batuhan Taskaya <isidentical@gmail.com> | 2022-05-16 12:38:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-16 12:38:06 (GMT) |
commit | f6fd8aac13714ce17650eb4a648d5c08f0be53b4 (patch) | |
tree | 22d3408fc5f2ed11091b4a394e21ec069c4dc33c /Lib/ast.py | |
parent | ca0cc9c433830e14714a5cc93fb4e7254da3dd76 (diff) | |
download | cpython-f6fd8aac13714ce17650eb4a648d5c08f0be53b4.zip cpython-f6fd8aac13714ce17650eb4a648d5c08f0be53b4.tar.gz cpython-f6fd8aac13714ce17650eb4a648d5c08f0be53b4.tar.bz2 |
gh-92671: Don't omit parentheses when unparsing empty tuples (GH-92673)
Diffstat (limited to 'Lib/ast.py')
-rw-r--r-- | Lib/ast.py | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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": "-"} |