fixed the skip_import_error option

This commit is contained in:
2026-01-20 23:50:24 +05:30
parent 6f9776dff2
commit 0061dbe2eb
3 changed files with 23 additions and 5 deletions

View File

@@ -63,6 +63,7 @@ class GriffeLoader:
self,
module_paths: List[str],
project_name: Optional[str] = None,
skip_import_errors: bool = None,
) -> Project:
if not module_paths:
raise ValueError("At least one module path must be provided")
@@ -73,7 +74,14 @@ class GriffeLoader:
project = Project(name=project_name)
for module_path in module_paths:
module = self.load_module(module_path)
try:
module = self.load_module(module_path)
except ImportError as import_error:
if skip_import_errors:
logger.debug("Could not load %s: %s", module_path, import_error)
continue
else:
raise import_error
project.add_module(module)
return project