anydi 0.44.1__tar.gz → 0.45.0__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.44.1 → anydi-0.45.0}/PKG-INFO +1 -1
- {anydi-0.44.1 → anydi-0.45.0}/anydi/_container.py +45 -48
- {anydi-0.44.1 → anydi-0.45.0}/anydi/testing.py +12 -16
- {anydi-0.44.1 → anydi-0.45.0}/pyproject.toml +2 -2
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/fastapi/test_ext.py +2 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/faststream/test_ext.py +2 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/test_container.py +8 -5
- {anydi-0.44.1 → anydi-0.45.0}/uv.lock +1 -1
- {anydi-0.44.1 → anydi-0.45.0}/.editorconfig +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/.github/workflows/ci.yml +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/.gitignore +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/.readthedocs.yaml +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/LICENSE +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/Makefile +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/README.md +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/_async.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/_context.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/_decorators.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/_module.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/_provider.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/_scan.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/_scope.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/_typing.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/ext/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/ext/_utils.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/ext/django/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/ext/django/_container.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/ext/django/_settings.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/ext/django/_utils.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/ext/django/apps.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/ext/django/middleware.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/ext/django/ninja/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/ext/django/ninja/_operation.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/ext/django/ninja/_signature.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/ext/fastapi.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/ext/faststream.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/ext/pydantic_settings.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/ext/pytest_plugin.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/ext/starlette/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/ext/starlette/middleware.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/anydi/py.typed +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/docs/examples/basic.md +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/docs/extensions/django.md +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/docs/extensions/fastapi.md +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/docs/extensions/faststream.md +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/docs/extensions/pydantic_settings.md +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/docs/index.md +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/docs/usage.md +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/mkdocs.yml +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/conftest.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/django/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/django/api/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/django/api/router.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/django/api/test_router.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/django/api/urls.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/django/conftest.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/django/container.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/django/scan/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/django/services.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/django/settings.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/django/test_views.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/django/urls.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/django/views.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/fastapi/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/fastapi/app.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/fastapi/conftest.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/fastapi/test_routes.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/faststream/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/faststream/test_subscribers.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/fixtures.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/starlette/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/starlette/app.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/starlette/conftest.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/starlette/test_routes.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/test_pydantic.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/ext/test_pytest_plugin.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/fixtures.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/scan_app/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/scan_app/a/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/scan_app/a/a1/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/scan_app/a/a1/handlers.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/scan_app/a/a2/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/scan_app/a/a2/a21/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/scan_app/a/a2/a21/handlers.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/scan_app/a/a3/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/scan_app/a/a3/handlers.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/scan_app/b/__init__.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/scan_app/b/handlers.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/test_decorators.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/test_module.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/test_scan.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/test_testing.py +0 -0
- {anydi-0.44.1 → anydi-0.45.0}/tests/test_utils.py +0 -0
|
@@ -399,9 +399,8 @@ class Container:
|
|
|
399
399
|
self._set_provider(provider)
|
|
400
400
|
return provider
|
|
401
401
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
) -> None:
|
|
402
|
+
@staticmethod
|
|
403
|
+
def _validate_provider_scope(scope: Scope, name: str, kind: ProviderKind) -> None:
|
|
405
404
|
"""Validate the provider scope."""
|
|
406
405
|
if scope not in (allowed_scopes := get_args(Scope)):
|
|
407
406
|
raise ValueError(
|
|
@@ -431,10 +430,8 @@ class Container:
|
|
|
431
430
|
) -> Provider:
|
|
432
431
|
"""Get or register a provider by interface."""
|
|
433
432
|
try:
|
|
434
|
-
return self.
|
|
435
|
-
except
|
|
436
|
-
if interface is inspect.Parameter.empty:
|
|
437
|
-
raise
|
|
433
|
+
return self._providers[interface]
|
|
434
|
+
except KeyError:
|
|
438
435
|
if inspect.isclass(interface) and not is_builtin_type(interface):
|
|
439
436
|
# Try to get defined scope
|
|
440
437
|
if is_provided(interface):
|
|
@@ -442,7 +439,12 @@ class Container:
|
|
|
442
439
|
else:
|
|
443
440
|
scope = parent_scope
|
|
444
441
|
return self._register_provider(interface, scope, interface, **defaults)
|
|
445
|
-
raise
|
|
442
|
+
raise LookupError(
|
|
443
|
+
f"The provider interface `{type_repr(interface)}` is either not "
|
|
444
|
+
"registered, not provided, or not set in the scoped context. "
|
|
445
|
+
"Please ensure that the provider interface is properly registered and "
|
|
446
|
+
"that the class is decorated with a scope before attempting to use it."
|
|
447
|
+
) from None
|
|
446
448
|
|
|
447
449
|
def _set_provider(self, provider: Provider) -> None:
|
|
448
450
|
"""Set a provider by interface."""
|
|
@@ -528,40 +530,34 @@ class Container:
|
|
|
528
530
|
del context[interface]
|
|
529
531
|
|
|
530
532
|
def _resolve_or_create(
|
|
531
|
-
self, interface:
|
|
532
|
-
) ->
|
|
533
|
+
self, interface: Any, create: bool, /, **defaults: Any
|
|
534
|
+
) -> Any:
|
|
533
535
|
"""Internal method to handle instance resolution and creation."""
|
|
534
536
|
provider = self._get_or_register_provider(interface, None, **defaults)
|
|
535
537
|
if provider.scope == "transient":
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
)
|
|
545
|
-
|
|
546
|
-
return cast(T, instance)
|
|
538
|
+
return self._create_instance(provider, None, **defaults)
|
|
539
|
+
context = self._get_instance_context(provider.scope)
|
|
540
|
+
with context.lock():
|
|
541
|
+
return (
|
|
542
|
+
self._get_or_create_instance(provider, context)
|
|
543
|
+
if not create
|
|
544
|
+
else self._create_instance(provider, context, **defaults)
|
|
545
|
+
)
|
|
547
546
|
|
|
548
547
|
async def _aresolve_or_create(
|
|
549
|
-
self, interface:
|
|
550
|
-
) ->
|
|
548
|
+
self, interface: Any, create: bool, /, **defaults: Any
|
|
549
|
+
) -> Any:
|
|
551
550
|
"""Internal method to handle instance resolution and creation asynchronously."""
|
|
552
551
|
provider = self._get_or_register_provider(interface, None, **defaults)
|
|
553
552
|
if provider.scope == "transient":
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
)
|
|
563
|
-
|
|
564
|
-
return cast(T, instance)
|
|
553
|
+
return await self._acreate_instance(provider, None, **defaults)
|
|
554
|
+
context = self._get_instance_context(provider.scope)
|
|
555
|
+
async with context.alock():
|
|
556
|
+
return (
|
|
557
|
+
await self._aget_or_create_instance(provider, context)
|
|
558
|
+
if not create
|
|
559
|
+
else await self._acreate_instance(provider, context, **defaults)
|
|
560
|
+
)
|
|
565
561
|
|
|
566
562
|
def _get_or_create_instance(
|
|
567
563
|
self, provider: Provider, context: InstanceContext
|
|
@@ -652,10 +648,9 @@ class Container:
|
|
|
652
648
|
"""Retrieve the arguments for a provider."""
|
|
653
649
|
provided_kwargs = {}
|
|
654
650
|
for parameter in provider.parameters:
|
|
655
|
-
|
|
651
|
+
provided_kwargs[parameter.name] = self._get_provider_instance(
|
|
656
652
|
provider, parameter, context, **defaults
|
|
657
653
|
)
|
|
658
|
-
provided_kwargs[parameter.name] = instance
|
|
659
654
|
return {**defaults, **provided_kwargs}
|
|
660
655
|
|
|
661
656
|
def _get_provider_instance(
|
|
@@ -665,12 +660,12 @@ class Container:
|
|
|
665
660
|
context: InstanceContext | None,
|
|
666
661
|
/,
|
|
667
662
|
**defaults: Any,
|
|
668
|
-
) ->
|
|
663
|
+
) -> Any:
|
|
669
664
|
"""Retrieve an instance of a dependency from the scoped context."""
|
|
670
665
|
|
|
671
666
|
# Try to get instance from defaults
|
|
672
667
|
if parameter.name in defaults:
|
|
673
|
-
return defaults[parameter.name]
|
|
668
|
+
return defaults[parameter.name]
|
|
674
669
|
|
|
675
670
|
# Try to get instance from context
|
|
676
671
|
elif context and parameter.annotation in context:
|
|
@@ -683,8 +678,8 @@ class Container:
|
|
|
683
678
|
except LookupError:
|
|
684
679
|
if parameter.default is inspect.Parameter.empty:
|
|
685
680
|
raise
|
|
686
|
-
return parameter.default
|
|
687
|
-
return instance
|
|
681
|
+
return parameter.default
|
|
682
|
+
return instance
|
|
688
683
|
|
|
689
684
|
async def _aget_provided_kwargs(
|
|
690
685
|
self, provider: Provider, context: InstanceContext | None, /, **defaults: Any
|
|
@@ -692,10 +687,9 @@ class Container:
|
|
|
692
687
|
"""Asynchronously retrieve the arguments for a provider."""
|
|
693
688
|
provided_kwargs = {}
|
|
694
689
|
for parameter in provider.parameters:
|
|
695
|
-
|
|
690
|
+
provided_kwargs[parameter.name] = await self._aget_provider_instance(
|
|
696
691
|
provider, parameter, context, **defaults
|
|
697
692
|
)
|
|
698
|
-
provided_kwargs[parameter.name] = instance
|
|
699
693
|
return {**defaults, **provided_kwargs}
|
|
700
694
|
|
|
701
695
|
async def _aget_provider_instance(
|
|
@@ -705,12 +699,12 @@ class Container:
|
|
|
705
699
|
context: InstanceContext | None,
|
|
706
700
|
/,
|
|
707
701
|
**defaults: Any,
|
|
708
|
-
) ->
|
|
702
|
+
) -> Any:
|
|
709
703
|
"""Asynchronously retrieve an instance of a dependency from the context."""
|
|
710
704
|
|
|
711
705
|
# Try to get instance from defaults
|
|
712
706
|
if parameter.name in defaults:
|
|
713
|
-
return defaults[parameter.name]
|
|
707
|
+
return defaults[parameter.name]
|
|
714
708
|
|
|
715
709
|
# Try to get instance from context
|
|
716
710
|
elif context and parameter.annotation in context:
|
|
@@ -723,20 +717,20 @@ class Container:
|
|
|
723
717
|
except LookupError:
|
|
724
718
|
if parameter.default is inspect.Parameter.empty:
|
|
725
719
|
raise
|
|
726
|
-
return parameter.default
|
|
727
|
-
return instance
|
|
720
|
+
return parameter.default
|
|
721
|
+
return instance
|
|
728
722
|
|
|
729
723
|
def _resolve_parameter(
|
|
730
724
|
self, provider: Provider, parameter: inspect.Parameter
|
|
731
725
|
) -> Any:
|
|
732
726
|
self._validate_resolvable_parameter(provider, parameter)
|
|
733
|
-
return self.
|
|
727
|
+
return self._resolve_or_create(parameter.annotation, False)
|
|
734
728
|
|
|
735
729
|
async def _aresolve_parameter(
|
|
736
730
|
self, provider: Provider, parameter: inspect.Parameter
|
|
737
731
|
) -> Any:
|
|
738
732
|
self._validate_resolvable_parameter(provider, parameter)
|
|
739
|
-
return await self.
|
|
733
|
+
return await self._aresolve_or_create(parameter.annotation, False)
|
|
740
734
|
|
|
741
735
|
def _validate_resolvable_parameter(
|
|
742
736
|
self, provider: Provider, parameter: inspect.Parameter
|
|
@@ -822,6 +816,9 @@ class Container:
|
|
|
822
816
|
self, call: Callable[..., Any], parameter: inspect.Parameter
|
|
823
817
|
) -> None:
|
|
824
818
|
"""Validate an injected parameter."""
|
|
819
|
+
# TODO: temporary disable until strict is enforced
|
|
820
|
+
return None
|
|
821
|
+
|
|
825
822
|
if parameter.annotation is inspect.Parameter.empty:
|
|
826
823
|
raise TypeError(
|
|
827
824
|
f"Missing `{type_repr(call)}` parameter `{parameter.name}` annotation."
|
|
@@ -2,7 +2,7 @@ import contextlib
|
|
|
2
2
|
import inspect
|
|
3
3
|
import logging
|
|
4
4
|
from collections.abc import Iterable, Iterator, Sequence
|
|
5
|
-
from typing import Any, TypeVar
|
|
5
|
+
from typing import Any, TypeVar
|
|
6
6
|
|
|
7
7
|
import wrapt # type: ignore
|
|
8
8
|
from typing_extensions import Self
|
|
@@ -65,18 +65,18 @@ class TestContainer(Container):
|
|
|
65
65
|
self._override_instances.pop(interface, None)
|
|
66
66
|
|
|
67
67
|
def _resolve_or_create(
|
|
68
|
-
self, interface:
|
|
69
|
-
) ->
|
|
68
|
+
self, interface: Any, create: bool, /, **defaults: Any
|
|
69
|
+
) -> Any:
|
|
70
70
|
"""Internal method to handle instance resolution and creation."""
|
|
71
71
|
instance = super()._resolve_or_create(interface, create, **defaults)
|
|
72
|
-
return
|
|
72
|
+
return self._patch_resolver(interface, instance)
|
|
73
73
|
|
|
74
74
|
async def _aresolve_or_create(
|
|
75
|
-
self, interface:
|
|
76
|
-
) ->
|
|
75
|
+
self, interface: Any, create: bool, /, **defaults: Any
|
|
76
|
+
) -> Any:
|
|
77
77
|
"""Internal method to handle instance resolution and creation asynchronously."""
|
|
78
78
|
instance = await super()._aresolve_or_create(interface, create, **defaults)
|
|
79
|
-
return
|
|
79
|
+
return self._patch_resolver(interface, instance)
|
|
80
80
|
|
|
81
81
|
def _get_provider_instance(
|
|
82
82
|
self,
|
|
@@ -87,12 +87,10 @@ class TestContainer(Container):
|
|
|
87
87
|
**defaults: Any,
|
|
88
88
|
) -> Any:
|
|
89
89
|
"""Retrieve an instance of a dependency from the scoped context."""
|
|
90
|
-
instance
|
|
90
|
+
instance = super()._get_provider_instance(
|
|
91
91
|
provider, parameter, context, **defaults
|
|
92
92
|
)
|
|
93
|
-
|
|
94
|
-
instance = InstanceProxy(instance, interface=parameter.annotation)
|
|
95
|
-
return instance, is_default
|
|
93
|
+
return InstanceProxy(instance, interface=parameter.annotation)
|
|
96
94
|
|
|
97
95
|
async def _aget_provider_instance(
|
|
98
96
|
self,
|
|
@@ -103,14 +101,12 @@ class TestContainer(Container):
|
|
|
103
101
|
**defaults: Any,
|
|
104
102
|
) -> Any:
|
|
105
103
|
"""Asynchronously retrieve an instance of a dependency from the context."""
|
|
106
|
-
instance
|
|
104
|
+
instance = await super()._aget_provider_instance(
|
|
107
105
|
provider, parameter, context, **defaults
|
|
108
106
|
)
|
|
109
|
-
|
|
110
|
-
instance = InstanceProxy(instance, interface=parameter.annotation)
|
|
111
|
-
return instance, is_default
|
|
107
|
+
return InstanceProxy(instance, interface=parameter.annotation)
|
|
112
108
|
|
|
113
|
-
def _patch_resolver(self, interface:
|
|
109
|
+
def _patch_resolver(self, interface: Any, instance: Any) -> Any:
|
|
114
110
|
"""Patch the test resolver for the instance."""
|
|
115
111
|
if interface in self._override_instances:
|
|
116
112
|
return self._override_instances[interface]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "anydi"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.45.0"
|
|
4
4
|
description = "Dependency Injection library"
|
|
5
5
|
authors = [{ name = "Anton Ruhlov", email = "antonruhlov@gmail.com" }]
|
|
6
6
|
requires-python = "~=3.9"
|
|
@@ -137,7 +137,7 @@ omit = [
|
|
|
137
137
|
]
|
|
138
138
|
|
|
139
139
|
[tool.bumpversion]
|
|
140
|
-
current_version = "0.
|
|
140
|
+
current_version = "0.45.0"
|
|
141
141
|
parse = """(?x)
|
|
142
142
|
(?P<major>0|[1-9]\\d*)\\.
|
|
143
143
|
(?P<minor>0|[1-9]\\d*)\\.
|
|
@@ -14,6 +14,7 @@ def test_inject_param_missing_interface() -> None:
|
|
|
14
14
|
_ = param.interface
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
@pytest.mark.skip(reason="disable until strict is enforced")
|
|
17
18
|
def test_install_without_annotation() -> None:
|
|
18
19
|
container = Container()
|
|
19
20
|
|
|
@@ -33,6 +34,7 @@ def test_install_without_annotation() -> None:
|
|
|
33
34
|
install(app, container)
|
|
34
35
|
|
|
35
36
|
|
|
37
|
+
@pytest.mark.skip(reason="disable until strict is enforced")
|
|
36
38
|
def test_install_unknown_annotation() -> None:
|
|
37
39
|
container = Container()
|
|
38
40
|
|
|
@@ -14,6 +14,7 @@ def test_inject_param_missing_interface() -> None:
|
|
|
14
14
|
_ = param.interface
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
@pytest.mark.skip(reason="disable until strict is enforced")
|
|
17
18
|
def test_install_without_annotation() -> None:
|
|
18
19
|
container = Container()
|
|
19
20
|
|
|
@@ -33,6 +34,7 @@ def test_install_without_annotation() -> None:
|
|
|
33
34
|
install(broker, container)
|
|
34
35
|
|
|
35
36
|
|
|
37
|
+
@pytest.mark.skip(reason="disable until strict is enforced")
|
|
36
38
|
def test_install_unknown_annotation() -> None:
|
|
37
39
|
container = Container()
|
|
38
40
|
|
|
@@ -962,9 +962,10 @@ class TestContainer:
|
|
|
962
962
|
with pytest.raises(
|
|
963
963
|
LookupError,
|
|
964
964
|
match=(
|
|
965
|
-
"The provider interface
|
|
966
|
-
"
|
|
967
|
-
"
|
|
965
|
+
"The provider interface `str` is either not registered, not provided, "
|
|
966
|
+
"or not set in the scoped context. Please ensure that the provider "
|
|
967
|
+
"interface is properly registered and that the class is decorated "
|
|
968
|
+
"with a scope before attempting to use it."
|
|
968
969
|
),
|
|
969
970
|
):
|
|
970
971
|
container.resolve(str)
|
|
@@ -1419,15 +1420,17 @@ class TestContainerInjector:
|
|
|
1419
1420
|
|
|
1420
1421
|
assert result == "service ident = 1000"
|
|
1421
1422
|
|
|
1423
|
+
@pytest.mark.skip(reason="disable until strict is enforced")
|
|
1422
1424
|
def test_inject_missing_annotation(self, container: Container) -> None:
|
|
1423
|
-
def handler(name=auto) -> str: # type: ignore
|
|
1424
|
-
return name # type: ignore
|
|
1425
|
+
def handler(name=auto) -> str: # type: ignore
|
|
1426
|
+
return name # type: ignore
|
|
1425
1427
|
|
|
1426
1428
|
with pytest.raises(
|
|
1427
1429
|
TypeError, match="Missing `(.*?).handler` parameter `name` annotation."
|
|
1428
1430
|
):
|
|
1429
1431
|
container.inject(handler)
|
|
1430
1432
|
|
|
1433
|
+
@pytest.mark.skip(reason="disable until strict is enforced")
|
|
1431
1434
|
def test_inject_unknown_dependency_using_strict_mode(self) -> None:
|
|
1432
1435
|
container = Container()
|
|
1433
1436
|
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|