From 191ddd628e2a9420f9066223edd0eb0bc5e1b954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Stucke?= Date: Thu, 5 Oct 2023 12:38:13 +0200 Subject: [PATCH] helper/plugin: ignore spec_from_loader() possibly returning None --- src/helperFunctions/plugin.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/helperFunctions/plugin.py b/src/helperFunctions/plugin.py index 10d3e5d09..857ba68e1 100644 --- a/src/helperFunctions/plugin.py +++ b/src/helperFunctions/plugin.py @@ -11,6 +11,7 @@ if TYPE_CHECKING: from types import ModuleType + from importlib.machinery import ModuleSpec def discover_analysis_plugins() -> list[ModuleType]: @@ -37,10 +38,7 @@ def _import_plugins(plugin_type) -> list[ModuleType]: module_name = str(plugin_file).replace('/', '.')[len(src_dir + '/') : -len('.py')] loader = SourceFileLoader(module_name, str(plugin_file)) - spec = spec_from_loader(loader.name, loader) - if spec is None: - logging.error(f'Could not import plugin {module_name}: could not create spec from loader') - continue + spec: ModuleSpec = spec_from_loader(loader.name, loader) # type: ignore[assignment] plugin_module = module_from_spec(spec) sys.modules[spec.name] = plugin_module