Mercurial > hg
diff mercurial/extensions.py @ 48913:f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
pycompat.iteritems() just calls .items().
This commit applies a regular expression search and replace to convert
simple instances of pycompat.iteritems() with .items(). There are still
a handful of calls to pycompat.iteritems() remaining. But these all have
more complicated expressions that I wasn't comfortable performing an
automated replace on. In addition, some simple replacements were withheld
because they broke pytype. These will be handled by their own changesets.
Differential Revision: https://phab.mercurial-scm.org/D12318
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 03 Mar 2022 18:28:30 -0800 |
parents | 5917dc5d1e52 |
children | 642e31cb55f0 |
line wrap: on
line diff
--- a/mercurial/extensions.py Thu Mar 03 17:39:20 2022 -0800 +++ b/mercurial/extensions.py Thu Mar 03 18:28:30 2022 -0800 @@ -73,7 +73,7 @@ try: mod = _extensions[name] except KeyError: - for k, v in pycompat.iteritems(_extensions): + for k, v in _extensions.items(): if k.endswith(b'.' + name) or k.endswith(b'/' + name): mod = v break @@ -170,7 +170,7 @@ def _validatecmdtable(ui, cmdtable): """Check if extension commands have required attributes""" - for c, e in pycompat.iteritems(cmdtable): + for c, e in cmdtable.items(): f = e[0] missing = [a for a in _cmdfuncattrs if not util.safehasattr(f, a)] if not missing: @@ -578,7 +578,7 @@ ''' assert callable(wrapper) aliases, entry = cmdutil.findcmd(command, table) - for alias, e in pycompat.iteritems(table): + for alias, e in table.items(): if e is entry: key = alias break @@ -755,7 +755,7 @@ if name in exts or name in _order or name == b'__init__': continue exts[name] = path - for name, path in pycompat.iteritems(_disabledextensions): + for name, path in _disabledextensions.items(): # If no path was provided for a disabled extension (e.g. "color=!"), # don't replace the path we already found by the scan above. if path: @@ -817,7 +817,7 @@ return { name: gettext(desc) - for name, desc in pycompat.iteritems(__index__.docs) + for name, desc in __index__.docs.items() if name not in _order } except (ImportError, AttributeError): @@ -828,7 +828,7 @@ return {} exts = {} - for name, path in pycompat.iteritems(paths): + for name, path in paths.items(): doc = _disabledhelp(path) if doc and name != b'__index__': exts[name] = doc.splitlines()[0] @@ -917,7 +917,7 @@ ext = _finddisabledcmd(ui, cmd, cmd, path, strict=strict) if not ext: # otherwise, interrogate each extension until there's a match - for name, path in pycompat.iteritems(paths): + for name, path in paths.items(): ext = _finddisabledcmd(ui, cmd, name, path, strict=strict) if ext: break @@ -942,9 +942,7 @@ def notloaded(): '''return short names of extensions that failed to load''' - return [ - name for name, mod in pycompat.iteritems(_extensions) if mod is None - ] + return [name for name, mod in _extensions.items() if mod is None] def moduleversion(module):