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:
authorEric Wieser <wieser.eric@gmail.com>2020-04-17 18:41:51 +0300
committerEric Wieser <wieser.eric@gmail.com>2020-04-17 18:49:25 +0300
commit11ff9207e6f161c121ff58aad534688f416ae431 (patch)
tree2f1a02450658a06fe3df6202826fc5e9de026c32 /sphinx/pycode
parent48a10179ef22aa90e7a40f20788e697976e3064e (diff)
Group together methods that relate to a python 3.8 deprecation
This will make it easier to remove them all at once in future
Diffstat (limited to 'sphinx/pycode')
-rw-r--r--sphinx/pycode/ast.py28
1 files changed, 15 insertions, 13 deletions
diff --git a/sphinx/pycode/ast.py b/sphinx/pycode/ast.py
index fd80b1b60..3fe0a7fcb 100644
--- a/sphinx/pycode/ast.py
+++ b/sphinx/pycode/ast.py
@@ -91,9 +91,6 @@ class _UnparseVisitor(ast.NodeVisitor):
op = " %s " % self.visit(node.op)
return op.join(self.visit(e) for e in node.values)
- def visit_Bytes(self, node: ast.Bytes) -> str:
- return repr(node.s)
-
def visit_Call(self, node: ast.Call) -> str:
args = ([self.visit(e) for e in node.args] +
["%s=%s" % (k.arg, self.visit(k.value)) for k in node.keywords])
@@ -105,9 +102,6 @@ class _UnparseVisitor(ast.NodeVisitor):
items = (k + ": " + v for k, v in zip(keys, values))
return "{" + ", ".join(items) + "}"
- def visit_Ellipsis(self, node: ast.Ellipsis) -> str:
- return "..."
-
def visit_Index(self, node: ast.Index) -> str:
return self.visit(node.value)
@@ -120,18 +114,26 @@ class _UnparseVisitor(ast.NodeVisitor):
def visit_Name(self, node: ast.Name) -> str:
return node.id
- def visit_NameConstant(self, node: ast.NameConstant) -> str:
- return repr(node.value)
+ if sys.version_info < (3, 8):
+ # these ast nodes were deprecated in python 3.8
+ def visit_Num(self, node: ast.Num) -> str:
+ return repr(node.n)
+
+ def visit_Str(self, node: ast.Str) -> str:
+ return repr(node.s)
- def visit_Num(self, node: ast.Num) -> str:
- return repr(node.n)
+ def visit_Bytes(self, node: ast.Bytes) -> str:
+ return repr(node.s)
+
+ def visit_NameConstant(self, node: ast.NameConstant) -> str:
+ return repr(node.value)
+
+ def visit_Ellipsis(self, node: ast.Ellipsis) -> str:
+ return "..."
def visit_Set(self, node: ast.Set) -> str:
return "{" + ", ".join(self.visit(e) for e in node.elts) + "}"
- def visit_Str(self, node: ast.Str) -> str:
- return repr(node.s)
-
def visit_Subscript(self, node: ast.Subscript) -> str:
return "%s[%s]" % (self.visit(node.value), self.visit(node.slice))