diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-04-12 13:00:04 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-04-12 13:00:04 +0900 |
commit | c8355234ebc63258004ad06da6bcf9dd7b98fac3 (patch) | |
tree | 2acdcd8b6f60fff6a1310294ee0180426bd2d0cb /sphinx | |
parent | 2e219366c433deb56fd3311a9245cdbabac05ca6 (diff) | |
download | sphinx-git-c8355234ebc63258004ad06da6bcf9dd7b98fac3.tar.gz |
Fix #7461: autodoc: empty tuple in type annotation is not shown correctly
Diffstat (limited to 'sphinx')
-rw-r--r-- | sphinx/pycode/ast.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sphinx/pycode/ast.py b/sphinx/pycode/ast.py index 4d8aa8955..fb2a7152d 100644 --- a/sphinx/pycode/ast.py +++ b/sphinx/pycode/ast.py @@ -114,7 +114,10 @@ def unparse(node: ast.AST) -> str: elif isinstance(node, ast.UnaryOp): return "%s %s" % (unparse(node.op), unparse(node.operand)) elif isinstance(node, ast.Tuple): - return ", ".join(unparse(e) for e in node.elts) + if node.elts: + return ", ".join(unparse(e) for e in node.elts) + else: + return "()" elif sys.version_info > (3, 6) and isinstance(node, ast.Constant): # this branch should be placed at last return repr(node.value) |