anydi 0.64.0__py3-none-any.whl → 0.65.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- anydi/_container.py +5 -0
- anydi/_resolver.py +34 -16
- {anydi-0.64.0.dist-info → anydi-0.65.0.dist-info}/METADATA +1 -1
- {anydi-0.64.0.dist-info → anydi-0.65.0.dist-info}/RECORD +6 -6
- {anydi-0.64.0.dist-info → anydi-0.65.0.dist-info}/WHEEL +0 -0
- {anydi-0.64.0.dist-info → anydi-0.65.0.dist-info}/entry_points.txt +0 -0
anydi/_container.py
CHANGED
anydi/_resolver.py
CHANGED
|
@@ -62,6 +62,13 @@ class Resolver:
|
|
|
62
62
|
def add_unresolved(self, interface: Any) -> None:
|
|
63
63
|
self._unresolved_interfaces.add(interface)
|
|
64
64
|
|
|
65
|
+
def clear_caches(self) -> None:
|
|
66
|
+
"""Clear all cached resolvers."""
|
|
67
|
+
self._cache.clear()
|
|
68
|
+
self._async_cache.clear()
|
|
69
|
+
self._override_cache.clear()
|
|
70
|
+
self._async_override_cache.clear()
|
|
71
|
+
|
|
65
72
|
def get_cached(self, interface: Any, *, is_async: bool) -> CompiledResolver | None:
|
|
66
73
|
"""Get cached resolver if it exists."""
|
|
67
74
|
if self.override_mode:
|
|
@@ -83,9 +90,14 @@ class Resolver:
|
|
|
83
90
|
return cache[provider.interface]
|
|
84
91
|
|
|
85
92
|
# Recursively compile dependencies first
|
|
86
|
-
for
|
|
87
|
-
if
|
|
88
|
-
|
|
93
|
+
for param in provider.parameters:
|
|
94
|
+
if param.provider is not None:
|
|
95
|
+
# Look up the current provider to handle overrides
|
|
96
|
+
current_provider = self._container.providers.get(param.annotation)
|
|
97
|
+
if current_provider is not None:
|
|
98
|
+
self.compile(current_provider, is_async=is_async)
|
|
99
|
+
else:
|
|
100
|
+
self.compile(param.provider, is_async=is_async)
|
|
89
101
|
|
|
90
102
|
# Compile the resolver and creator functions
|
|
91
103
|
compiled = self._compile_resolver(
|
|
@@ -155,23 +167,29 @@ class Resolver:
|
|
|
155
167
|
else (self._async_cache if is_async else self._cache)
|
|
156
168
|
)
|
|
157
169
|
|
|
158
|
-
for idx,
|
|
159
|
-
param_annotations[idx] =
|
|
160
|
-
param_defaults[idx] =
|
|
161
|
-
param_has_default[idx] =
|
|
162
|
-
param_names[idx] =
|
|
163
|
-
param_shared_scopes[idx] =
|
|
164
|
-
|
|
165
|
-
if
|
|
166
|
-
|
|
170
|
+
for idx, param in enumerate(provider.parameters):
|
|
171
|
+
param_annotations[idx] = param.annotation
|
|
172
|
+
param_defaults[idx] = param.default
|
|
173
|
+
param_has_default[idx] = param.has_default
|
|
174
|
+
param_names[idx] = param.name
|
|
175
|
+
param_shared_scopes[idx] = param.shared_scope
|
|
176
|
+
|
|
177
|
+
if param.provider is not None:
|
|
178
|
+
# Look up the current provider from the container to handle overrides
|
|
179
|
+
current_provider = self._container.providers.get(param.annotation)
|
|
180
|
+
if current_provider is not None:
|
|
181
|
+
compiled = cache.get(current_provider.interface)
|
|
182
|
+
else:
|
|
183
|
+
# Fallback to the original provider if not in container
|
|
184
|
+
compiled = cache.get(param.provider.interface)
|
|
167
185
|
if compiled is None:
|
|
168
|
-
compiled = self.compile(
|
|
169
|
-
cache[
|
|
186
|
+
compiled = self.compile(param.provider, is_async=is_async)
|
|
187
|
+
cache[param.provider.interface] = compiled
|
|
170
188
|
param_resolvers[idx] = compiled.resolve
|
|
171
189
|
|
|
172
190
|
unresolved_message = (
|
|
173
|
-
f"You are attempting to get the parameter `{
|
|
174
|
-
f"annotation `{type_repr(
|
|
191
|
+
f"You are attempting to get the parameter `{param.name}` with the "
|
|
192
|
+
f"annotation `{type_repr(param.annotation)}` as a dependency into "
|
|
175
193
|
f"`{type_repr(provider.call)}` which is not registered or set in the "
|
|
176
194
|
"scoped context."
|
|
177
195
|
)
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
anydi/__init__.py,sha256=KFX8OthKXwBuYDPCV61t-044DpJ88tAOzIxeUWRC5OA,633
|
|
2
2
|
anydi/_async_lock.py,sha256=3dwZr0KthXFYha0XKMyXf8jMmGb1lYoNC0O5w29V9ic,1104
|
|
3
|
-
anydi/_container.py,sha256=
|
|
3
|
+
anydi/_container.py,sha256=NFxrzJuWwc4DyT2Ffl0RUU3ecCCF4cl-tLp9LhgKnfQ,29675
|
|
4
4
|
anydi/_context.py,sha256=-9QqeMWo9OpZVXZxZCQgIsswggl3Ch7lgx1KiFX_ezc,3752
|
|
5
5
|
anydi/_decorators.py,sha256=J3W261ZAG7q4XKm4tbAv1wsWr9ysx9_5MUbUvSJB_MQ,2809
|
|
6
6
|
anydi/_injector.py,sha256=1Ux71DhGxu3dLwPJP8gU73olI0pcZ3_tVaVzwKH7100,4411
|
|
7
7
|
anydi/_marker.py,sha256=xVydjGdkxd_DqqwttnJZRkQbhpCTE9OnrhFmFJMlgvI,3415
|
|
8
8
|
anydi/_module.py,sha256=2kN5uEXLd2Dsc58gz5IWK43wJewr_QgIVGSO3iWp798,2609
|
|
9
9
|
anydi/_provider.py,sha256=OV1WFHTYv7W2U0XDk_Kql1r551Vhq8o-pUV5ep1HQcU,1574
|
|
10
|
-
anydi/_resolver.py,sha256=
|
|
10
|
+
anydi/_resolver.py,sha256=nKPuEI69ZBLdPubQlnlQTTkhMK15vG0YcW9jgitzIto,31393
|
|
11
11
|
anydi/_scanner.py,sha256=rbRkHzyd2zMu7AFLffN6_tZJcMaW9gy7E-lVdHLHYrs,4294
|
|
12
12
|
anydi/_types.py,sha256=lsShY_-_CM2EFajeknAYXvLl-rHfopBT8udnK5_BtS4,1161
|
|
13
13
|
anydi/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -21,7 +21,7 @@ anydi/ext/starlette/middleware.py,sha256=n_JJ7BcG2Mg2M5HwM_SBboxZ-mnnD6WWJn4khq7
|
|
|
21
21
|
anydi/ext/typer.py,sha256=z-sDd3jZMPTE2CyEuJ0f9uIJB43FjoLWbjpnkOvqSKA,6236
|
|
22
22
|
anydi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
23
|
anydi/testing.py,sha256=cHg3mMScZbEep9smRqSNQ81BZMQOkyugHe8TvKdPnEg,1347
|
|
24
|
-
anydi-0.
|
|
25
|
-
anydi-0.
|
|
26
|
-
anydi-0.
|
|
27
|
-
anydi-0.
|
|
24
|
+
anydi-0.65.0.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
25
|
+
anydi-0.65.0.dist-info/entry_points.txt,sha256=AgOcQYM5KyS4D37QcYb00tiid0QA-pD1VrjHHq4QAps,44
|
|
26
|
+
anydi-0.65.0.dist-info/METADATA,sha256=1_HiKQhF3W8pOnXHqMkAzLvhTOC7UiZX-0-fIbRVprY,8142
|
|
27
|
+
anydi-0.65.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|