Repository navigation
Fix validation of nonexistent forbidden modules within root packages - #387
Merged
seddonym merged 1 commit intoOct 13, 2026
Merged
Conversation
A forbidden contract only searches for imports of the forbidden modules that are in the graph, so a forbidden module within the root packages that doesn't exist (e.g. a typo) made the contract pass without checking anything. Modules within the root packages are always in the graph, so raise the same "does not exist" error as for source modules. External forbidden modules still don't need to be imported anywhere. Fixes seddonym#386
seddonym
approved these changes
Oct 13, 2026
seddonym
left a comment
Owner
There was a problem hiding this comment.
Thanks so much for your contribution!
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.
Summary
Fixes #386.
A forbidden contract could incorrectly pass when a forbidden module was
specified within a root package but did not exist in the import graph.
For example, a typo in a forbidden module name could result in the contract
being reported as KEPT, even though the intended restriction was never checked.
Changes
exist in the import graph.
legitimately be absent from the graph.
Testing
Added regression tests covering:
as_packagesconfigurations.The new tests fail against the original implementation and pass with this fix.
Validation performed:
test_with_ui_deps_installed-3.12: 507 passed.test_without_ui_deps_installed-3.12: 3 passed.The CLI reproduction now reports:
Module 'pkg.bb' does not exist.instead of incorrectly reporting that the contract is kept.
Compatibility
This intentionally changes the behavior for nonexistent forbidden modules
within root packages: an invalid configuration now raises an error rather
than silently passing.
External forbidden modules retain their existing behavior.