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
Adds first-class classification for conditional imports inside try blocks that handle ImportError or ModuleNotFoundError.
These imports are now marked with ImportKind.CONDITIONAL_IMPORT, allowing dependency graphs and reports to distinguish optional/fallback dependencies from regular runtime imports.
This PR includes regression tests for conditional imports in raw import extraction and graph extraction, plus a short README note documenting the behavior.
I found one blocker around relative conditional imports.
from . import fallback inside a handled ImportError block is now classified as CONDITIONAL_IMPORT, but the resolver only has the stored import name '.' to work with. That means the graph resolves the package path rather than the sibling module being imported. This is a common optional fallback pattern, so it can silently produce the wrong dependency edge for the exact behavior this PR is adding.
Please add coverage for conditional relative imports, especially from . import module, and adjust the extraction/resolution path so the conditional context does not erase the relative import semantics needed to resolve the target correctly.
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.
Pull Request
Adds first-class classification for conditional imports inside
tryblocks that handleImportErrororModuleNotFoundError.These imports are now marked with
ImportKind.CONDITIONAL_IMPORT, allowing dependency graphs and reports to distinguish optional/fallback dependencies from regular runtime imports.This PR includes regression tests for conditional imports in raw import extraction and graph extraction, plus a short README note documenting the behavior.
Change Type