refactor: split large files with backwards-compatible re-exports#133
refactor: split large files with backwards-compatible re-exports#133iloveagent57 wants to merge 1 commit intomainfrom
Conversation
cbfb603 to
fee1aff
Compare
fee1aff to
256d88c
Compare
256d88c to
c5a74d5
Compare
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (85.75%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #133 +/- ##
==========================================
+ Coverage 84.28% 84.29% +0.01%
==========================================
Files 144 147 +3
Lines 12209 12230 +21
Branches 1162 1163 +1
==========================================
+ Hits 10290 10309 +19
- Misses 1598 1600 +2
Partials 321 321 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Split bffs/handlers.py (749 → 71 lines) by extracting learner portal handlers to bffs/learner_portal/handlers.py - Split subsidy_access_policy/models.py (2276 → 2090 lines) by extracting PolicyGroupAssociation and ForcedPolicyRedemption to models_supporting.py - Remove pylint skip-file directive from models.py and fix all pylint issues - Fix bug: action variable used before assignment in assignment_request_redeem() - Add missing docstrings to clean_spend_limit, SubsidyAccessPolicyRequestAssignmentMixin, and assignment_request_redeem - Document module splitting pattern in docs/architecture-patterns.md All existing imports continue to work via re-exports for backwards compatibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
c5a74d5 to
2c20f5b
Compare
| """ | ||
| A base handler class for learner-focused routes. | ||
|
|
||
| The `BaseLearnerHandler` extends `BaseHandler` and provides shared core functionality |
There was a problem hiding this comment.
The class docstring refers to BaseLearnerHandler, but the class name is BaseLearnerPortalHandler. Update the docstring to reference the correct class name to avoid confusion when navigating the codebase.
| The `BaseLearnerHandler` extends `BaseHandler` and provides shared core functionality | |
| The `BaseLearnerPortalHandler` extends `BaseHandler` and provides shared core functionality |
| if not self.bnr_enabled: | ||
| return { | ||
| "error_reason": REASON_BNR_NOT_ENABLED | ||
| } | ||
| return self.assignment_request_can_allocate(learner_credit_requests) | ||
| return self.assignment_request_can_allocate(learner_credit_requests) # pylint: disable=no-member | ||
|
|
There was a problem hiding this comment.
can_approve() is defined on SubsidyAccessPolicy but calls assignment_request_can_allocate(), which is only provided by SubsidyAccessPolicyRequestAssignmentMixin (used by PerLearnerSpendCreditAccessPolicy). Instead of suppressing pylint with # pylint: disable=no-member, consider moving can_approve() onto the mixin / relevant policy subclass, or add a concrete implementation on the base class that fails fast with a clear error when BNR is enabled on an unsupported policy type.
| return self.subsidy_access_policy.uuid | ||
|
|
||
| def __str__(self): | ||
| return ( | ||
| f'<{self.__class__.__name__} policy_uuid={self.subsidy_access_policy.uuid}, ' |
There was a problem hiding this comment.
ForcedPolicyRedemption.subsidy_access_policy is nullable (on_delete=SET_NULL), but both policy_uuid and __str__ unconditionally dereference self.subsidy_access_policy.uuid, which will raise if the related policy is deleted. Guard for a null policy (or make the FK non-nullable if null should be impossible in practice).
| return self.subsidy_access_policy.uuid | |
| def __str__(self): | |
| return ( | |
| f'<{self.__class__.__name__} policy_uuid={self.subsidy_access_policy.uuid}, ' | |
| if self.subsidy_access_policy is None: | |
| return None | |
| return self.subsidy_access_policy.uuid | |
| def __str__(self): | |
| return ( | |
| f'<{self.__class__.__name__} policy_uuid={self.policy_uuid}, ' |
All existing imports continue to work via re-exports for backwards compatibility.
🤖 Generated with Claude Code
Merge checklist:
./manage.py makemigrationshas been runPost merge: