summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-05-28 01:48:47 +0900
committerGitHub <noreply@github.com>2020-05-28 01:48:47 +0900
commit4ded1d5644b4d97e5bd7a82b102fb853fa1ceafa (patch)
tree7c312f3916714051146ae1d8175e9813bbf8a666
parent2a036bd34d4525a9363bede59842d9b1678b0ed8 (diff)
parent49b91b076dee1f88eab2e551380acfad3c2f8d22 (diff)
downloadsphinx-git-4ded1d5644b4d97e5bd7a82b102fb853fa1ceafa.tar.gz
Merge pull request #7731 from tk0miya/refactor_pycode
refactor pycode: sort methods
-rw-r--r--sphinx/pycode/ast.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/sphinx/pycode/ast.py b/sphinx/pycode/ast.py
index 3d2af3426..9734cb476 100644
--- a/sphinx/pycode/ast.py
+++ b/sphinx/pycode/ast.py
@@ -155,6 +155,12 @@ class _UnparseVisitor(ast.NodeVisitor):
["%s=%s" % (k.arg, self.visit(k.value)) for k in node.keywords])
return "%s(%s)" % (self.visit(node.func), ", ".join(args))
+ def visit_Constant(self, node: ast.Constant) -> str: # type: ignore
+ if node.value is Ellipsis:
+ return "..."
+ else:
+ return repr(node.value)
+
def visit_Dict(self, node: ast.Dict) -> str:
keys = (self.visit(k) for k in node.keys)
values = (self.visit(v) for v in node.values)
@@ -188,13 +194,6 @@ class _UnparseVisitor(ast.NodeVisitor):
else:
return "()"
- if sys.version_info >= (3, 6):
- def visit_Constant(self, node: ast.Constant) -> str: # type: ignore
- if node.value is Ellipsis:
- return "..."
- else:
- return repr(node.value)
-
if sys.version_info < (3, 8):
# these ast nodes were deprecated in python 3.8
def visit_Bytes(self, node: ast.Bytes) -> str: