mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #7731 from tk0miya/refactor_pycode
refactor pycode: sort methods
This commit is contained in:
commit
4ded1d5644
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user