You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importlib.util.find_spec raises ModuleNotFoundError for missing parents in dotted module names. Treat missing modules in the requested name as unavailable while preserving unrelated dependency errors.
Sure — the concrete case is the msgspec extra: package_is_available("msgspec.structs") calls find_spec("msgspec.structs"), which raises ModuleNotFoundError (it doesn't return None) when the parent msgspec isn't installed, so without this patch the check blows up instead of reporting the extra as missing. Same for any dotted extra whose parent is absent. The patch only swallows the error when the missing module is the probed dependency itself — unrelated import errors from an existing parent (like a broken __init__) still propagate, covered by test_missing_dependency_in_parent_is_not_hidden.
I'm still not convinced that this change is required. The function is very clearly scoped to packages rather than modules, it's only use within python-json-logger is with packages, and it is for internal use rather than external consumption.
Without a valid reason I'm inclined to close this pull request.
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
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.
importlib.util.find_spec raises ModuleNotFoundError for missing parents in dotted module names. Treat missing modules in the requested name as unavailable while preserving unrelated dependency errors.