mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
remove unnecessary list()
wrappers. In some places, I replaced iterable.sort()
with sorted(iterable)
.
This commit is contained in:
parent
15879896fd
commit
6beeeeb827
@ -110,7 +110,7 @@ class I18nBuilder(Builder):
|
|||||||
for node, entries in traverse_translatable_index(doctree):
|
for node, entries in traverse_translatable_index(doctree):
|
||||||
for typ, msg, tid, main in entries:
|
for typ, msg, tid, main in entries:
|
||||||
for m in split_index_msg(typ, msg):
|
for m in split_index_msg(typ, msg):
|
||||||
if typ == 'pair' and m in list(pairindextypes.values()):
|
if typ == 'pair' and m in pairindextypes.values():
|
||||||
# avoid built-in translated message was incorporated
|
# avoid built-in translated message was incorporated
|
||||||
# in 'sphinx.util.nodes.process_index_entry'
|
# in 'sphinx.util.nodes.process_index_entry'
|
||||||
continue
|
continue
|
||||||
|
@ -1560,8 +1560,7 @@ class BuildEnvironment:
|
|||||||
if lckey[0:1] in lcletters:
|
if lckey[0:1] in lcletters:
|
||||||
return chr(127) + lckey
|
return chr(127) + lckey
|
||||||
return lckey
|
return lckey
|
||||||
newlist = list(new.items())
|
newlist = sorted(new.items(), key=keyfunc)
|
||||||
newlist.sort(key=keyfunc)
|
|
||||||
|
|
||||||
if group_entries:
|
if group_entries:
|
||||||
# fixup entries: transform
|
# fixup entries: transform
|
||||||
|
@ -213,8 +213,7 @@ class CoverageBuilder(Builder):
|
|||||||
try:
|
try:
|
||||||
if self.config.coverage_write_headline:
|
if self.config.coverage_write_headline:
|
||||||
write_header(op, 'Undocumented Python objects', '=')
|
write_header(op, 'Undocumented Python objects', '=')
|
||||||
keys = list(self.py_undoc.keys())
|
keys = sorted(self.py_undoc.keys())
|
||||||
keys.sort()
|
|
||||||
for name in keys:
|
for name in keys:
|
||||||
undoc = self.py_undoc[name]
|
undoc = self.py_undoc[name]
|
||||||
if 'error' in undoc:
|
if 'error' in undoc:
|
||||||
|
@ -143,7 +143,7 @@ class InheritanceGraph(object):
|
|||||||
displayed node names.
|
displayed node names.
|
||||||
"""
|
"""
|
||||||
all_classes = {}
|
all_classes = {}
|
||||||
builtins = list(vars(__builtin__).values())
|
builtins = vars(__builtin__).values()
|
||||||
|
|
||||||
def recurse(cls):
|
def recurse(cls):
|
||||||
if not show_builtins and cls in builtins:
|
if not show_builtins and cls in builtins:
|
||||||
|
@ -350,7 +350,7 @@ class coverage:
|
|||||||
'-o:': 'omit=',
|
'-o:': 'omit=',
|
||||||
}
|
}
|
||||||
short_opts = string.join(map(lambda o: o[1:], optmap.keys()), '')
|
short_opts = string.join(map(lambda o: o[1:], optmap.keys()), '')
|
||||||
long_opts = list(optmap.values())
|
long_opts = optmap.values()
|
||||||
options, args = getopt.getopt(argv, short_opts, long_opts)
|
options, args = getopt.getopt(argv, short_opts, long_opts)
|
||||||
for o, a in options:
|
for o, a in options:
|
||||||
if o in optmap:
|
if o in optmap:
|
||||||
@ -743,10 +743,8 @@ class coverage:
|
|||||||
visitor = StatementFindingAstVisitor(statements, excluded, suite_spots)
|
visitor = StatementFindingAstVisitor(statements, excluded, suite_spots)
|
||||||
compiler.walk(ast, visitor, walker=visitor)
|
compiler.walk(ast, visitor, walker=visitor)
|
||||||
|
|
||||||
lines = list(statements.keys())
|
lines = sorted(statements.keys())
|
||||||
lines.sort()
|
excluded_lines = sorted(excluded.keys())
|
||||||
excluded_lines = list(excluded.keys())
|
|
||||||
excluded_lines.sort()
|
|
||||||
return lines, excluded_lines, suite_spots
|
return lines, excluded_lines, suite_spots
|
||||||
|
|
||||||
# format_lines(statements, lines). Format a list of line numbers
|
# format_lines(statements, lines). Format a list of line numbers
|
||||||
@ -850,7 +848,7 @@ class coverage:
|
|||||||
morfs = self.filter_by_prefix(morfs, omit_prefixes)
|
morfs = self.filter_by_prefix(morfs, omit_prefixes)
|
||||||
morfs.sort(self.morf_name_compare)
|
morfs.sort(self.morf_name_compare)
|
||||||
|
|
||||||
max_name = max([5,] + list(map(len, map(self.morf_name, morfs))))
|
max_name = max(5, *map(len, map(self.morf_name, morfs)))
|
||||||
fmt_name = "%%- %ds " % max_name
|
fmt_name = "%%- %ds " % max_name
|
||||||
fmt_err = fmt_name + "%s: %s"
|
fmt_err = fmt_name + "%s: %s"
|
||||||
header = fmt_name % "Name" + " Stmts Exec Cover"
|
header = fmt_name % "Name" + " Stmts Exec Cover"
|
||||||
|
@ -865,9 +865,9 @@ def _serialize_xml(write, elem, encoding, qnames, namespaces):
|
|||||||
_serialize_xml(write, e, encoding, qnames, None)
|
_serialize_xml(write, e, encoding, qnames, None)
|
||||||
else:
|
else:
|
||||||
write("<" + tag)
|
write("<" + tag)
|
||||||
items = list(elem.items())
|
items = elem.items()
|
||||||
if items or namespaces:
|
if items or namespaces:
|
||||||
items.sort() # lexical order
|
items = sorted(items) # lexical order
|
||||||
for k, v in items:
|
for k, v in items:
|
||||||
if isinstance(k, QName):
|
if isinstance(k, QName):
|
||||||
k = k.text
|
k = k.text
|
||||||
@ -877,8 +877,8 @@ def _serialize_xml(write, elem, encoding, qnames, namespaces):
|
|||||||
v = _escape_attrib(v, encoding)
|
v = _escape_attrib(v, encoding)
|
||||||
write(" %s=\"%s\"" % (qnames[k], v))
|
write(" %s=\"%s\"" % (qnames[k], v))
|
||||||
if namespaces:
|
if namespaces:
|
||||||
items = list(namespaces.items())
|
items = namespaces.items()
|
||||||
items.sort(key=lambda x: x[1]) # sort on prefix
|
items = sorted(items, key=lambda x: x[1]) # sort on prefix
|
||||||
for v, k in items:
|
for v, k in items:
|
||||||
if k:
|
if k:
|
||||||
k = ":" + k
|
k = ":" + k
|
||||||
@ -922,9 +922,9 @@ def _serialize_html(write, elem, encoding, qnames, namespaces):
|
|||||||
_serialize_html(write, e, encoding, qnames, None)
|
_serialize_html(write, e, encoding, qnames, None)
|
||||||
else:
|
else:
|
||||||
write("<" + tag)
|
write("<" + tag)
|
||||||
items = list(elem.items())
|
items = elem.items()
|
||||||
if items or namespaces:
|
if items or namespaces:
|
||||||
items.sort() # lexical order
|
items = sorted(items) # lexical order
|
||||||
for k, v in items:
|
for k, v in items:
|
||||||
if isinstance(k, QName):
|
if isinstance(k, QName):
|
||||||
k = k.text
|
k = k.text
|
||||||
@ -935,8 +935,8 @@ def _serialize_html(write, elem, encoding, qnames, namespaces):
|
|||||||
# FIXME: handle boolean attributes
|
# FIXME: handle boolean attributes
|
||||||
write(" %s=\"%s\"" % (qnames[k], v))
|
write(" %s=\"%s\"" % (qnames[k], v))
|
||||||
if namespaces:
|
if namespaces:
|
||||||
items = list(namespaces.items())
|
items = namespaces.items()
|
||||||
items.sort(key=lambda x: x[1]) # sort on prefix
|
items = sorted(items, key=lambda x: x[1]) # sort on prefix
|
||||||
for v, k in items:
|
for v, k in items:
|
||||||
if k:
|
if k:
|
||||||
k = ":" + k
|
k = ":" + k
|
||||||
|
@ -190,7 +190,7 @@ class path(text_type):
|
|||||||
"""
|
"""
|
||||||
Joins the path with the argument given and returns the result.
|
Joins the path with the argument given and returns the result.
|
||||||
"""
|
"""
|
||||||
return self.__class__(os.path.join(self, *list(map(self.__class__, args))))
|
return self.__class__(os.path.join(self, *map(self.__class__, args)))
|
||||||
|
|
||||||
__div__ = __truediv__ = joinpath
|
__div__ = __truediv__ = joinpath
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user