diff options
| author | Victor Stinner <vstinner@python.org> | 2020-11-20 14:44:02 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-20 14:44:02 +0100 |
| commit | 3be8e220ede7764a403b74eb2051aa703dde2626 (patch) | |
| tree | 6e518107c32a37adf642f1ebf35a98eb1e191f30 /Lib/importlib/_bootstrap_external.py | |
| parent | a6109ef68d421712ba368ef502c4789e8de113e0 (diff) | |
| download | cpython-git-3be8e220ede7764a403b74eb2051aa703dde2626.tar.gz | |
bpo-42403: Use @staticmethod in importlib (GH-23395)
Use @staticmethod on methods using @classmethod but don't use their
cls parameter on the following classes:
* BuiltinImporter
* FrozenImporter
* WindowsRegistryFinder
* PathFinder
Leave methods using @_requires_builtin or @_requires_frozen unchanged,
since this decorator requires the wrapped method to have an extra parameter
(cls or self).
Diffstat (limited to 'Lib/importlib/_bootstrap_external.py')
| -rw-r--r-- | Lib/importlib/_bootstrap_external.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index a0236c488a..0ae49cf5ba 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -754,8 +754,8 @@ class WindowsRegistryFinder: '\\Modules\\{fullname}\\Debug') DEBUG_BUILD = (_MS_WINDOWS and '_d.pyd' in EXTENSION_SUFFIXES) - @classmethod - def _open_registry(cls, key): + @staticmethod + def _open_registry(key): try: return winreg.OpenKey(winreg.HKEY_CURRENT_USER, key) except OSError: @@ -1219,8 +1219,8 @@ class _NamespaceLoader: def __init__(self, name, path, path_finder): self._path = _NamespacePath(name, path, path_finder) - @classmethod - def module_repr(cls, module): + @staticmethod + def module_repr(module): """Return repr for the module. The method is deprecated. The import machinery does the job itself. @@ -1261,8 +1261,8 @@ class PathFinder: """Meta path finder for sys.path and package __path__ attributes.""" - @classmethod - def invalidate_caches(cls): + @staticmethod + def invalidate_caches(): """Call the invalidate_caches() method on all path entry finders stored in sys.path_importer_caches (where implemented).""" for name, finder in list(sys.path_importer_cache.items()): @@ -1271,8 +1271,8 @@ class PathFinder: elif hasattr(finder, 'invalidate_caches'): finder.invalidate_caches() - @classmethod - def _path_hooks(cls, path): + @staticmethod + def _path_hooks(path): """Search sys.path_hooks for a finder for 'path'.""" if sys.path_hooks is not None and not sys.path_hooks: _warnings.warn('sys.path_hooks is empty', ImportWarning) @@ -1390,8 +1390,8 @@ class PathFinder: return None return spec.loader - @classmethod - def find_distributions(cls, *args, **kwargs): + @staticmethod + def find_distributions(*args, **kwargs): """ Find distributions. |
