refactor: split allowlist module to prevent circular imports - #3180
Conversation
|
🤖 Review · Commit: |
|
Build succeeded. ✔️ pre-commit SUCCESS in 1m 54s |
a9c0732 to
b9450f7
Compare
|
/fs-review |
|
🤖 Finished Review · ✅ Success · Started 10:46 AM UTC · Completed 11:02 AM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $5.99 |
|
Build succeeded. ✔️ pre-commit SUCCESS in 2m 47s |
|
Looks good to me Previous runReviewFindingsLow
Previous run (2)ReviewFindingsLow
|
b9450f7 to
c644943
Compare
|
🤖 Review · ❌ Terminated · Started 12:04 PM UTC · Ended 12:20 PM UTC Commit: |
|
✔️ pre-commit SUCCESS in 1m 54s |
|
🤖 Finished Review · ✅ Success · Started 12:04 PM UTC · Completed 12:20 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $5.44 |
Split the allowlist module into two separate modules to break the circular import chain that caused ImportError on Python 3.14: allowlist.py → helpers/testing_farm.py → checker/testing_farm.py → handlers/__init__.py → handlers/forges.py → allowlist.py Changes: Core module (allowlist.py): - Removed job helper imports (CoprBuildJobHelper, TestingFarmJobHelper) - Kept all core allowlist management methods: - Static methods for checking/managing namespaces - FAS authentication methods - Namespace approval/denial methods New event checker module (allowlist_checker.py): - Created AllowlistChecker class extending Allowlist - Moved all event checking methods that depend on job helpers: - check_and_report() and all _check_*() event methods - _check_pr_report_status() which uses job helpers - Imports job helpers only in this module Updated imports: - jobs.py: now uses AllowlistChecker for check_and_report() - Test files: updated to use AllowlistChecker where needed - handlers/forges.py: continues to use Allowlist (core methods only) Benefits over local imports (PR packit#3178): 1. Cleaner separation of concerns: Core allowlist logic vs event checking 2. No runtime overhead: Local imports are checked on every call 3. Better maintainability: Clear dependency boundaries 4. Future-proof: Works with all Python versions, including 3.14+ The allowlist.py module can now be imported independently without triggering the circular import chain. Assisted-by: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
c644943 to
682fed6
Compare
|
🤖 Review · ❌ Terminated · Started 12:36 PM UTC · Ended 12:50 PM UTC Commit: |
|
Build succeeded. ✔️ pre-commit SUCCESS in 2m 18s |
|
🤖 Finished Review · ✅ Success · Started 12:36 PM UTC · Completed 12:50 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $6.51 |
Summary
Split the allowlist module into two separate modules to break the circular import chain that caused
ImportErroron Python 3.14. This is a cleaner alternative to the local import workaround in PR #3178.Root Cause
The circular import chain was:
The issue occurred because
allowlist.pyimported job helpers (CoprBuildJobHelper,TestingFarmJobHelper) which eventually led back to importingallowlist.pythrough the handlers chain.Changes
Core module (
allowlist.py)New event checker module (
allowlist_checker.py)AllowlistCheckerclass extendingAllowlistcheck_and_report()and all_check_*()event methods_check_pr_report_status()which uses job helpersUpdated imports
jobs.py: now usesAllowlistCheckerforcheck_and_report()AllowlistCheckerwhere neededhandlers/forges.py: continues to useAllowlist(core methods only)Benefits Over Local Imports (PR #3178)
Testing
The test from PR #3178 (
test_no_circular_import_in_allowlist) now passes without needing local imports. Theallowlist.pymodule can be imported independently:Related
Fixes #3177
Alternative to #3178
🤖 Generated with Claude Code