fix(policy): resolve circular import blocking package import#62
Open
Rehan30g wants to merge 1 commit into
Open
fix(policy): resolve circular import blocking package import#62Rehan30g wants to merge 1 commit into
Rehan30g wants to merge 1 commit into
Conversation
engine.py imported Policy back from the redactable.policy package init, which itself imports engine at load time. That made `import redactable` (and the whole test suite) fail with an ImportError before anything could run. Import Policy from policy.model directly instead.
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
redactable.policy.engineimportsPolicyback fromredactable.policy, butredactable/policy/__init__.pyimportsenginebefore it gets to defining/importingPolicyitself. That circular reference meansimport redactablecurrently raises:This isn't a corner case — it fails on a plain
import redactable, and it was blocking pytest from even collectingtest_apply.py,test_policy_engine.py,test_policy_loader.py, andtest_transforms.py.Fix
Import
Policydirectly fromredactable.policy.model(where it's actually defined) instead of re-importing it through the package__init__.Type
Testing
import redactablenow succeeds.pytest tests/test_apply.py tests/test_policy_loader.py tests/test_transforms.py— all pass (these previously failed to even collect).ruff check src/redactable/policy/engine.py— clean.mypy src/redactable/policy/engine.py— clean.Note: a few unrelated tests (
test_detectors.py,test_pandas_integration.py,test_policy_engine.py's audit-event tests) fail for separate, pre-existing reasons (e.g.datetime.utcnow()deprecation warnings promoted to errors, and Finding attribute mismatches) that were previously masked by the collection error. Left those out of scope to keep this fix focused and easy to review.Checklist