1*da0073e9SAndroid Build Coastguard Workerfrom importlib.abc import Loader 2*da0073e9SAndroid Build Coastguard Workerfrom types import ModuleType 3*da0073e9SAndroid Build Coastguard Workerfrom typing import cast 4*da0073e9SAndroid Build Coastguard Worker 5*da0073e9SAndroid Build Coastguard Worker 6*da0073e9SAndroid Build Coastguard Workerdef import_module(name: str, path: str) -> ModuleType: 7*da0073e9SAndroid Build Coastguard Worker import importlib.util 8*da0073e9SAndroid Build Coastguard Worker 9*da0073e9SAndroid Build Coastguard Worker spec = importlib.util.spec_from_file_location(name, path) 10*da0073e9SAndroid Build Coastguard Worker assert spec is not None 11*da0073e9SAndroid Build Coastguard Worker module = importlib.util.module_from_spec(spec) 12*da0073e9SAndroid Build Coastguard Worker cast(Loader, spec.loader).exec_module(module) 13*da0073e9SAndroid Build Coastguard Worker return module 14