Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-06-20 20:43:55 +0300
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-06-20 20:43:55 +0300
commitb9158b96d261eb6126dbd035aa72c621ddea91e8 (patch)
treea34afaaed7ece7a9fee5d74ba4b59f168ec33658 /sphinx/pycode
parent6918e69600810a4664e53653d6ff0290c3c4a788 (diff)
Fix #9364: autodoc: 1-element tuple on the defarg is wrongly rendered
Diffstat (limited to 'sphinx/pycode')
-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