@@ -122,11 +122,12 @@ def unlock(self) -> None:
122122class ScopedInjectable [R , T ](Injectable [T ], ABC ):
123123 factory : Caller [..., R ]
124124 scope_name : str
125+ key : SlotKey [T ] = field (default_factory = SlotKey )
125126 logic : CacheLogic [T ] = field (default_factory = CacheLogic )
126127
127128 @property
128129 def is_locked (self ) -> bool :
129- return in_scope_cache (self , self .scope_name )
130+ return in_scope_cache (self . key , self .scope_name )
130131
131132 @abstractmethod
132133 async def abuild (self , scope : Scope ) -> T :
@@ -139,12 +140,12 @@ def build(self, scope: Scope) -> T:
139140 async def aget_instance (self ) -> T :
140141 scope = self .__get_scope ()
141142 factory = partial (self .abuild , scope )
142- return await self .logic .aget_or_create (scope .cache , self , factory )
143+ return await self .logic .aget_or_create (scope .cache , self . key , factory )
143144
144145 def get_instance (self ) -> T :
145146 scope = self .__get_scope ()
146147 factory = partial (self .build , scope )
147- return self .logic .get_or_create (scope .cache , self , factory )
148+ return self .logic .get_or_create (scope .cache , self . key , factory )
148149
149150 def unlock (self ) -> None :
150151 if self .is_locked :
@@ -187,7 +188,7 @@ def build(self, scope: Scope) -> T:
187188 return self .factory .call ()
188189
189190 def unlock (self ) -> None :
190- remove_scoped_values (self , self .scope_name )
191+ remove_scoped_values (self . key , self .scope_name )
191192
192193
193194@dataclass (repr = False , eq = False , frozen = True , slots = True )
0 commit comments