Skip to content

Conversation

@remimd
Copy link
Member

@remimd remimd commented Dec 29, 2025

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ScopeState protocol to ScopeResolver for better semantic clarity
  • Consolidated separate __CONTEXTUAL_SCOPES and __SHARED_SCOPES dictionaries into a unified __scope_resolvers structure
  • 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() and remove_scoped_values() functions with a single iter_active_scopes() function
  • Removed unlock() method from a class in injectables.py that depended on the removed remove_scoped_values() function
  • Updated tests to reflect the new behavior where unlock() raises a RuntimeError when 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.

@remimd remimd force-pushed the refactor branch 2 times, most recently from 392c3fe to 1e806cd Compare December 29, 2025 16:11
@remimd remimd merged commit 364f583 into dev Dec 29, 2025
6 checks passed
@remimd remimd deleted the refactor branch December 29, 2025 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants