Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the scope management system to improve code readability and maintainability by consolidating scope state tracking, simplifying the API surface, and unifying the scope resolution mechanism.
Key Changes:
- Renamed
ScopeStateprotocol toScopeResolverfor better semantic clarity - Consolidated separate
__CONTEXTUAL_SCOPESand__SHARED_SCOPESdictionaries into a unified__scope_resolversstructure - Simplified the
get_scope()function by removing overloads and the optional default parameter, making it always raise an exception when a scope is not found - Replaced
get_active_scopes()andremove_scoped_values()functions with a singleiter_active_scopes()function - Removed
unlock()method from a class in injectables.py that depended on the removedremove_scoped_values()function - Updated tests to reflect the new behavior where
unlock()raises aRuntimeErrorwhen called within an active scope
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| injection/_core/scope.py | Core refactoring: renamed ScopeState to ScopeResolver, consolidated scope storage into __scope_resolvers, simplified get_scope() API, replaced multiple helper functions with iter_active_scopes(), and streamlined _bind_scope() logic |
| injection/_core/injectables.py | Removed remove_scoped_values import and deleted unlock() method from a class that depended on the removed scope cleanup function |
| tests/core/test_module.py | Updated tests to verify that unlock() now correctly raises RuntimeError when called within an active scope, removing old tests that validated unlocking within scopes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
392c3fe to
1e806cd
Compare
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.
No description provided.