summaryrefslogtreecommitdiff
path: root/sphinx/pycode/ast.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-07-07 02:09:50 +0900
committerGitHub <noreply@github.com>2021-07-07 02:09:50 +0900
commit5e5bca98f752cb61c36afc7955183e79a6095cf2 (patch)
tree66fc9448a4bbab736469fdad514dfa970787d495 /sphinx/pycode/ast.py
parent988a79de65737e403cd27721ce091760cf62b97f (diff)
parentf0fef96906d80d89e290a780767a92ba85977733 (diff)
downloadsphinx-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.py8
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