anydi 0.36.1a3__py3-none-any.whl → 0.36.1a4__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 +31 -26
- {anydi-0.36.1a3.dist-info → anydi-0.36.1a4.dist-info}/METADATA +1 -1
- {anydi-0.36.1a3.dist-info → anydi-0.36.1a4.dist-info}/RECORD +6 -6
- {anydi-0.36.1a3.dist-info → anydi-0.36.1a4.dist-info}/LICENSE +0 -0
- {anydi-0.36.1a3.dist-info → anydi-0.36.1a4.dist-info}/WHEEL +0 -0
- {anydi-0.36.1a3.dist-info → anydi-0.36.1a4.dist-info}/entry_points.txt +0 -0
anydi/_container.py
CHANGED
|
@@ -618,25 +618,27 @@ class Container:
|
|
|
618
618
|
**defaults: Any,
|
|
619
619
|
) -> Any:
|
|
620
620
|
"""Retrieve an instance of a dependency from the scoped context."""
|
|
621
|
+
|
|
622
|
+
# Try to get instance from defaults
|
|
621
623
|
if parameter.name in defaults:
|
|
622
|
-
|
|
624
|
+
instance = defaults[parameter.name]
|
|
623
625
|
|
|
624
|
-
#
|
|
625
|
-
|
|
626
|
-
|
|
626
|
+
# Try to get instance from context
|
|
627
|
+
elif context and parameter.annotation in context:
|
|
628
|
+
instance = context[parameter.annotation]
|
|
627
629
|
|
|
628
|
-
# Resolve
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
630
|
+
# Resolve new instance
|
|
631
|
+
else:
|
|
632
|
+
try:
|
|
633
|
+
instance = self._resolve_parameter(provider, parameter)
|
|
634
|
+
except LookupError:
|
|
635
|
+
if parameter.default is inspect.Parameter.empty:
|
|
636
|
+
raise
|
|
637
|
+
instance = parameter.default
|
|
635
638
|
|
|
636
639
|
# Wrap the instance in a proxy for testing
|
|
637
640
|
if self.testing:
|
|
638
641
|
return InstanceProxy(interface=parameter.annotation, instance=instance)
|
|
639
|
-
|
|
640
642
|
return instance
|
|
641
643
|
|
|
642
644
|
async def _aget_provided_kwargs(
|
|
@@ -660,20 +662,23 @@ class Container:
|
|
|
660
662
|
**defaults: Any,
|
|
661
663
|
) -> Any:
|
|
662
664
|
"""Asynchronously retrieve an instance of a dependency from the context."""
|
|
665
|
+
|
|
666
|
+
# Try to get instance from defaults
|
|
663
667
|
if parameter.name in defaults:
|
|
664
|
-
|
|
668
|
+
instance = defaults[parameter.name]
|
|
665
669
|
|
|
666
|
-
#
|
|
667
|
-
|
|
668
|
-
|
|
670
|
+
# Try to get instance from context
|
|
671
|
+
elif context and parameter.annotation in context:
|
|
672
|
+
instance = context[parameter.annotation]
|
|
669
673
|
|
|
670
|
-
# Resolve
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
674
|
+
# Resolve new instance
|
|
675
|
+
else:
|
|
676
|
+
try:
|
|
677
|
+
instance = await self._aresolve_parameter(provider, parameter)
|
|
678
|
+
except LookupError:
|
|
679
|
+
if parameter.default is inspect.Parameter.empty:
|
|
680
|
+
raise
|
|
681
|
+
instance = parameter.default
|
|
677
682
|
|
|
678
683
|
# Wrap the instance in a proxy for testing
|
|
679
684
|
if self.testing:
|
|
@@ -727,6 +732,9 @@ class Container:
|
|
|
727
732
|
return self.resolve(_interface)
|
|
728
733
|
raise LookupError
|
|
729
734
|
|
|
735
|
+
# Attach the resolver getter to the instance
|
|
736
|
+
instance.__resolver_getter__ = __resolver_getter__
|
|
737
|
+
|
|
730
738
|
if not hasattr(instance.__class__, "__getattribute_patched__"):
|
|
731
739
|
|
|
732
740
|
def __getattribute__(_self: Any, name: str) -> Any:
|
|
@@ -747,9 +755,6 @@ class Container:
|
|
|
747
755
|
instance.__class__.__getattribute__ = __getattribute__
|
|
748
756
|
instance.__class__.__getattribute_patched__ = True
|
|
749
757
|
|
|
750
|
-
# Attach the resolver getter to the instance
|
|
751
|
-
instance.__resolver_getter__ = __resolver_getter__
|
|
752
|
-
|
|
753
758
|
return instance
|
|
754
759
|
|
|
755
760
|
def is_resolved(self, interface: AnyInterface) -> bool:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
anydi/__init__.py,sha256=OfRg2EfXD65pHTGQKhfkABMwUhw5LvsuTQV_Tv4V4wk,501
|
|
2
|
-
anydi/_container.py,sha256=
|
|
2
|
+
anydi/_container.py,sha256=LSa1IMR8JeAtA5im9EWU8NOKqSCDjKmxXRt9mVXPAf4,38251
|
|
3
3
|
anydi/_context.py,sha256=7LV_SL4QWkJeiG7_4D9PZ5lmU-MPzhofxC95zCgY9Gc,2651
|
|
4
4
|
anydi/_provider.py,sha256=W42y8wbsnWbb9B9gI-pnEa-lsz68nK0VIm55CJW3pWg,7457
|
|
5
5
|
anydi/_types.py,sha256=Vttj9GTp9g0KKpK-uqolLfVZJPIM7f7_YL8bPlablcQ,1539
|
|
@@ -22,8 +22,8 @@ anydi/ext/pytest_plugin.py,sha256=ShGhiZnP1KyMHhnc9Ci1RKAuHVhw628OTS2P2BLEOfc,50
|
|
|
22
22
|
anydi/ext/starlette/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
23
|
anydi/ext/starlette/middleware.py,sha256=9CQtGg5ZzUz2gFSzJr8U4BWzwNjK8XMctm3n52M77Z0,792
|
|
24
24
|
anydi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
|
-
anydi-0.36.
|
|
26
|
-
anydi-0.36.
|
|
27
|
-
anydi-0.36.
|
|
28
|
-
anydi-0.36.
|
|
29
|
-
anydi-0.36.
|
|
25
|
+
anydi-0.36.1a4.dist-info/LICENSE,sha256=V6rU8a8fv6o2jQ-7ODHs0XfDFimot8Q6Km6CylRIDTo,1069
|
|
26
|
+
anydi-0.36.1a4.dist-info/METADATA,sha256=cDcue6lJu_2S7GNsR8ryi_C_lAti0rSKuXZebraSXRA,5066
|
|
27
|
+
anydi-0.36.1a4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
28
|
+
anydi-0.36.1a4.dist-info/entry_points.txt,sha256=GmQblwzxFg42zva1HyBYJJ7TvrTIcSAGBHmyi3bvsi4,42
|
|
29
|
+
anydi-0.36.1a4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|