Fix mypy typing issue with importspec loader Optionalness (src/ModuleManager.py)

This commit is contained in:
jesopo 2019-02-06 22:41:37 +00:00
parent c77d8aaac8
commit f94f233eb3

View file

@ -121,7 +121,8 @@ class ModuleManager(object):
import_spec = importlib.util.spec_from_file_location(import_name, path) import_spec = importlib.util.spec_from_file_location(import_name, path)
module = importlib.util.module_from_spec(import_spec) module = importlib.util.module_from_spec(import_spec)
sys.modules[import_name] = module sys.modules[import_name] = module
import_spec.loader.exec_module(module) loader = typing.cast(importlib.abc.Loader, import_spec.loader)
loader.exec_module(module)
module_object_pointer = getattr(module, "Module", None) module_object_pointer = getattr(module, "Module", None)
if not module_object_pointer: if not module_object_pointer: