diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-07-07 02:09:50 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-07 02:09:50 +0900 |
commit | 5e5bca98f752cb61c36afc7955183e79a6095cf2 (patch) | |
tree | 66fc9448a4bbab736469fdad514dfa970787d495 /sphinx/pycode/ast.py | |
parent | 988a79de65737e403cd27721ce091760cf62b97f (diff) | |
parent | f0fef96906d80d89e290a780767a92ba85977733 (diff) | |
download | sphinx-git-5e5bca98f752cb61c36afc7955183e79a6095cf2.tar.gz |
Merge branch '4.x' into 6525_linkcheck_warn_redirects
Diffstat (limited to 'sphinx/pycode/ast.py')
-rw-r--r-- | sphinx/pycode/ast.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sphinx/pycode/ast.py b/sphinx/pycode/ast.py index f541ec0a9..23da575bd 100644 --- a/sphinx/pycode/ast.py +++ b/sphinx/pycode/ast.py @@ -213,10 +213,12 @@ class _UnparseVisitor(ast.NodeVisitor): return "%s %s" % (self.visit(node.op), self.visit(node.operand)) def visit_Tuple(self, node: ast.Tuple) -> str: - if node.elts: - return "(" + ", ".join(self.visit(e) for e in node.elts) + ")" - else: + if len(node.elts) == 0: return "()" + elif len(node.elts) == 1: + return "(%s,)" % self.visit(node.elts[0]) + else: + return "(" + ", ".join(self.visit(e) for e in node.elts) + ")" if sys.version_info < (3, 8): # these ast nodes were deprecated in python 3.8 |