anydi 0.55.0__tar.gz → 0.55.1__tar.gz
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-0.55.0 → anydi-0.55.1}/PKG-INFO +1 -1
- {anydi-0.55.0 → anydi-0.55.1}/anydi/_container.py +3 -2
- {anydi-0.55.0 → anydi-0.55.1}/anydi/_provider.py +1 -0
- {anydi-0.55.0 → anydi-0.55.1}/anydi/_resolver.py +12 -4
- {anydi-0.55.0 → anydi-0.55.1}/pyproject.toml +1 -1
- {anydi-0.55.0 → anydi-0.55.1}/README.md +0 -0
- {anydi-0.55.0 → anydi-0.55.1}/anydi/__init__.py +0 -0
- {anydi-0.55.0 → anydi-0.55.1}/anydi/_async_lock.py +0 -0
- {anydi-0.55.0 → anydi-0.55.1}/anydi/_context.py +0 -0
- {anydi-0.55.0 → anydi-0.55.1}/anydi/_decorators.py +0 -0
- {anydi-0.55.0 → anydi-0.55.1}/anydi/_module.py +0 -0
- {anydi-0.55.0 → anydi-0.55.1}/anydi/_scanner.py +0 -0
- {anydi-0.55.0 → anydi-0.55.1}/anydi/_types.py +0 -0
- {anydi-0.55.0 → anydi-0.55.1}/anydi/ext/__init__.py +0 -0
- {anydi-0.55.0 → anydi-0.55.1}/anydi/ext/django/__init__.py +0 -0
- {anydi-0.55.0 → anydi-0.55.1}/anydi/ext/fastapi.py +0 -0
- {anydi-0.55.0 → anydi-0.55.1}/anydi/ext/faststream.py +0 -0
- {anydi-0.55.0 → anydi-0.55.1}/anydi/ext/pydantic_settings.py +0 -0
- {anydi-0.55.0 → anydi-0.55.1}/anydi/ext/pytest_plugin.py +0 -0
- {anydi-0.55.0 → anydi-0.55.1}/anydi/ext/starlette/__init__.py +0 -0
- {anydi-0.55.0 → anydi-0.55.1}/anydi/ext/starlette/middleware.py +0 -0
- {anydi-0.55.0 → anydi-0.55.1}/anydi/py.typed +0 -0
- {anydi-0.55.0 → anydi-0.55.1}/anydi/testing.py +0 -0
|
@@ -339,6 +339,7 @@ class Container:
|
|
|
339
339
|
default=default,
|
|
340
340
|
has_default=has_default,
|
|
341
341
|
provider=sub_provider,
|
|
342
|
+
shared_scope=sub_provider.scope == scope and scope != "transient",
|
|
342
343
|
)
|
|
343
344
|
)
|
|
344
345
|
|
|
@@ -389,10 +390,10 @@ class Container:
|
|
|
389
390
|
@staticmethod
|
|
390
391
|
def _validate_provider_scope(scope: Scope, name: str, is_resource: bool) -> None:
|
|
391
392
|
"""Validate the provider scope."""
|
|
392
|
-
if scope not in
|
|
393
|
+
if scope not in ALLOWED_SCOPES:
|
|
393
394
|
raise ValueError(
|
|
394
395
|
f"The provider `{name}` scope is invalid. Only the following "
|
|
395
|
-
f"scopes are supported: {', '.join(
|
|
396
|
+
f"scopes are supported: {', '.join(ALLOWED_SCOPES)}. "
|
|
396
397
|
"Please use one of the supported scopes when registering a provider."
|
|
397
398
|
)
|
|
398
399
|
if scope == "transient" and is_resource:
|
|
@@ -81,6 +81,7 @@ class Resolver:
|
|
|
81
81
|
param_defaults: list[Any] = [None] * num_params
|
|
82
82
|
param_has_default: list[bool] = [False] * num_params
|
|
83
83
|
param_names: list[str] = [""] * num_params
|
|
84
|
+
param_shared_scopes: list[bool] = [False] * num_params
|
|
84
85
|
unresolved_messages: list[str] = [""] * num_params
|
|
85
86
|
|
|
86
87
|
cache = self._async_cache if is_async else self._cache
|
|
@@ -90,6 +91,7 @@ class Resolver:
|
|
|
90
91
|
param_defaults[idx] = p.default
|
|
91
92
|
param_has_default[idx] = p.has_default
|
|
92
93
|
param_names[idx] = p.name
|
|
94
|
+
param_shared_scopes[idx] = p.shared_scope
|
|
93
95
|
|
|
94
96
|
if p.provider is not None:
|
|
95
97
|
compiled = cache.get(p.provider.interface)
|
|
@@ -191,7 +193,8 @@ class Resolver:
|
|
|
191
193
|
)
|
|
192
194
|
create_lines.append(
|
|
193
195
|
f" arg_{idx} = "
|
|
194
|
-
f"await compiled[0](container,
|
|
196
|
+
f"await compiled[0](container, "
|
|
197
|
+
f"context if _param_shared_scopes[{idx}] else None)"
|
|
195
198
|
)
|
|
196
199
|
else:
|
|
197
200
|
create_lines.append(
|
|
@@ -212,7 +215,8 @@ class Resolver:
|
|
|
212
215
|
)
|
|
213
216
|
create_lines.append(
|
|
214
217
|
f" arg_{idx} = "
|
|
215
|
-
f"compiled[0](container,
|
|
218
|
+
f"compiled[0](container, "
|
|
219
|
+
f"context if _param_shared_scopes[{idx}] else None)"
|
|
216
220
|
)
|
|
217
221
|
create_lines.append(" except LookupError:")
|
|
218
222
|
create_lines.append(
|
|
@@ -227,11 +231,14 @@ class Resolver:
|
|
|
227
231
|
if is_async:
|
|
228
232
|
create_lines.append(
|
|
229
233
|
f" arg_{idx} = await resolver("
|
|
230
|
-
f"container,
|
|
234
|
+
f"container, "
|
|
235
|
+
f"context if _param_shared_scopes[{idx}] else None)"
|
|
231
236
|
)
|
|
232
237
|
else:
|
|
233
238
|
create_lines.append(
|
|
234
|
-
f" arg_{idx} = resolver(
|
|
239
|
+
f" arg_{idx} = resolver("
|
|
240
|
+
f"container, "
|
|
241
|
+
f"context if _param_shared_scopes[{idx}] else None)"
|
|
235
242
|
)
|
|
236
243
|
create_lines.append(" else:")
|
|
237
244
|
create_lines.append(f" arg_{idx} = cached")
|
|
@@ -539,6 +546,7 @@ class Resolver:
|
|
|
539
546
|
"_param_defaults": param_defaults,
|
|
540
547
|
"_param_has_default": param_has_default,
|
|
541
548
|
"_param_resolvers": param_resolvers,
|
|
549
|
+
"_param_shared_scopes": param_shared_scopes,
|
|
542
550
|
"_unresolved_messages": unresolved_messages,
|
|
543
551
|
"_unresolved_interfaces": self._unresolved_interfaces,
|
|
544
552
|
"_NOT_SET": NOT_SET,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|