diff --git a/hydra/core/plugins.py b/hydra/core/plugins.py index be1cdd5b799..0089b9c4342 100644 --- a/hydra/core/plugins.py +++ b/hydra/core/plugins.py @@ -184,20 +184,15 @@ def _scan_all_plugins( import_time = timer() with warnings.catch_warnings(record=True) as recorded_warnings: - if sys.version_info < (3, 10): - m = importer.find_module(modname) # type: ignore - assert m is not None - loaded_mod = m.load_module(modname) + spec = importer.find_spec(modname) + assert spec is not None + if modname in sys.modules: + loaded_mod = sys.modules[modname] else: - spec = importer.find_spec(modname) - assert spec is not None - if modname in sys.modules: - loaded_mod = sys.modules[modname] - else: - loaded_mod = importlib.util.module_from_spec(spec) - if loaded_mod is not None: - spec.loader.exec_module(loaded_mod) - sys.modules[modname] = loaded_mod + loaded_mod = importlib.util.module_from_spec(spec) + if loaded_mod is not None: + sys.modules[modname] = loaded_mod + spec.loader.exec_module(loaded_mod) import_time = timer() - import_time if len(recorded_warnings) > 0: