Improve Error Handling in Module Importer #18
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improve Error Handling in Module Importer
Summary
This PR improves error handling in the module importer by making import failures more explicit and removing silent error suppression. This change ensures that import errors are properly propagated rather than being silently ignored, which helps with debugging and provides better error visibility.
Changes Made
1. Version Bump
0.0.22
to0.0.23
inpy_spring_core/__init__.py
2. Module Importer Error Handling (
py_spring_core/commons/module_importer.py
)import_module_from_path()
to raise exceptions instead of returningNone
on import failuresignore_errors
parameter fromimport_classes_from_paths()
method3. Core Utils Update (
py_spring_core/core/utils.py
)is_ignore_error
parameter fromdynamically_import_modules()
function4. Test Updates (
tests/test_module_importer.py
)None
returns for import failuresFileNotFoundError
)SyntaxError
)Breaking Changes
None
or be silently ignoredFileNotFoundError
,SyntaxError
, etc.)Benefits
Migration Guide
If you're currently using the module importer and relying on silent error handling, you'll need to:
ignore_errors
oris_ignore_error
parameters from your function callsNone
returns from import functionsTesting
Related Issues