(file_path: str)
| 10 | |
| 11 | |
| 12 | def import_module(file_path: str) -> ModuleType: |
| 13 | # Handle file paths with periods in the name using importlib.util |
| 14 | abs_path = get_abs_path(file_path) |
| 15 | module_name = os.path.basename(abs_path).replace(".py", "") |
| 16 | |
| 17 | # Create the module spec and load the module |
| 18 | spec = importlib.util.spec_from_file_location(module_name, abs_path) |
| 19 | if spec is None or spec.loader is None: |
| 20 | raise ImportError(f"Could not load module from {abs_path}") |
| 21 | |
| 22 | module = importlib.util.module_from_spec(spec) |
| 23 | spec.loader.exec_module(module) |
| 24 | return module |
| 25 | |
| 26 | |
| 27 | def load_classes_from_folder( |
no test coverage detected