[ENH] Added catch all exceptions block instead of just catching ImportError & AttributeError in _safe_import#494
Merged
fkiraly merged 5 commits intosktime:mainfrom Feb 25, 2026
Conversation
… & AttributeError
…r auto code quality checks
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #494 +/- ##
==========================================
- Coverage 85.07% 83.45% -1.62%
==========================================
Files 45 52 +7
Lines 3015 3905 +890
==========================================
+ Hits 2565 3259 +694
- Misses 450 646 +196 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…d the Returns section for completeness
_safe_import
fkiraly
approved these changes
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Reference Issues/PRs
Fixes #493 by moving functionality from
sktimetoskbase.What does this implement/fix? Explain your changes.
I have added a catch-all exception block in
_safe_importinstead of the current exception block, which only catches ImportError & AttributeError.This change makes
_safe_importexhibit more aggressive error catching and addresses the problem of occasional breakage due to unsafe cascading imports, e.g., if a new version of a soft dependency has a breaking import.As suggested in this comment
Does your contribution introduce a new dependency? If yes, which one?
No
Did you add any tests for the change?
Yes, added
test_safe_import_catches_non_import_errorinskbase/utils/dependencies/tests/test_safe_import.pyto check the flow of catch-all exception block.PR checklist
For all contributions
the PR topic is related to enhancement, CI/CD, maintenance, documentation, or a bug.
For code contributions
_safe_importis a private function, no action required.New public functionality has been added to the APIReference