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 typ, msg, tid, main in entries:
|
||||
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
|
||||
# in 'sphinx.util.nodes.process_index_entry'
|
||||
continue
|
||||
|
@ -1560,8 +1560,7 @@ class BuildEnvironment:
|
||||
if lckey[0:1] in lcletters:
|
||||
return chr(127) + lckey
|
||||
return lckey
|
||||
newlist = list(new.items())
|
||||
newlist.sort(key=keyfunc)
|
||||
newlist = sorted(new.items(), key=keyfunc)
|
||||
|
||||
if group_entries:
|
||||
# fixup entries: transform
|
||||
|
@ -213,8 +213,7 @@ class CoverageBuilder(Builder):
|
||||
try:
|
||||
if self.config.coverage_write_headline:
|
||||
write_header(op, 'Undocumented Python objects', '=')
|
||||
keys = list(self.py_undoc.keys())
|
||||
keys.sort()
|
||||
keys = sorted(self.py_undoc.keys())
|
||||
for name in keys:
|
||||
undoc = self.py_undoc[name]
|
||||
if 'error' in undoc:
|
||||
|
@ -143,7 +143,7 @@ class InheritanceGraph(object):
|
||||
displayed node names.
|
||||
"""
|
||||
all_classes = {}
|
||||
builtins = list(vars(__builtin__).values())
|
||||
builtins = vars(__builtin__).values()
|
||||
|
||||
def recurse(cls):
|
||||
if not show_builtins and cls in builtins:
|
||||
|
@ -350,7 +350,7 @@ class coverage:
|
||||
'-o:': 'omit=',
|
||||
}
|
||||
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)
|
||||
for o, a in options:
|
||||
if o in optmap:
|
||||
@ -743,10 +743,8 @@ class coverage:
|
||||
visitor = StatementFindingAstVisitor(statements, excluded, suite_spots)
|
||||
compiler.walk(ast, visitor, walker=visitor)
|
||||
|
||||
lines = list(statements.keys())
|
||||
lines.sort()
|
||||
excluded_lines = list(excluded.keys())
|
||||
excluded_lines.sort()
|
||||
lines = sorted(statements.keys())
|
||||
excluded_lines = sorted(excluded.keys())
|
||||
return lines, excluded_lines, suite_spots
|
||||
|
||||
# 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.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_err = fmt_name + "%s: %s"
|
||||
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)
|
||||
else:
|
||||
write("<" + tag)
|
||||
items = list(elem.items())
|
||||
items = elem.items()
|
||||
if items or namespaces:
|
||||
items.sort() # lexical order
|
||||
items = sorted(items) # lexical order
|
||||
for k, v in items:
|
||||
if isinstance(k, QName):
|
||||
k = k.text
|
||||
@ -877,8 +877,8 @@ def _serialize_xml(write, elem, encoding, qnames, namespaces):
|
||||
v = _escape_attrib(v, encoding)
|
||||
write(" %s=\"%s\"" % (qnames[k], v))
|
||||
if namespaces:
|
||||
items = list(namespaces.items())
|
||||
items.sort(key=lambda x: x[1]) # sort on prefix
|
||||
items = namespaces.items()
|
||||
items = sorted(items, key=lambda x: x[1]) # sort on prefix
|
||||
for v, k in items:
|
||||
if k:
|
||||
k = ":" + k
|
||||
@ -922,9 +922,9 @@ def _serialize_html(write, elem, encoding, qnames, namespaces):
|
||||
_serialize_html(write, e, encoding, qnames, None)
|
||||
else:
|
||||
write("<" + tag)
|
||||
items = list(elem.items())
|
||||
items = elem.items()
|
||||
if items or namespaces:
|
||||
items.sort() # lexical order
|
||||
items = sorted(items) # lexical order
|
||||
for k, v in items:
|
||||
if isinstance(k, QName):
|
||||
k = k.text
|
||||
@ -935,8 +935,8 @@ def _serialize_html(write, elem, encoding, qnames, namespaces):
|
||||
# FIXME: handle boolean attributes
|
||||
write(" %s=\"%s\"" % (qnames[k], v))
|
||||
if namespaces:
|
||||
items = list(namespaces.items())
|
||||
items.sort(key=lambda x: x[1]) # sort on prefix
|
||||
items = namespaces.items()
|
||||
items = sorted(items, key=lambda x: x[1]) # sort on prefix
|
||||
for v, k in items:
|
||||
if k:
|
||||
k = ":" + k
|
||||
|
@ -190,7 +190,7 @@ class path(text_type):
|
||||
"""
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user