anydi 0.36.1a2__py3-none-any.whl → 0.36.1a3__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 +30 -20
- {anydi-0.36.1a2.dist-info → anydi-0.36.1a3.dist-info}/METADATA +1 -1
- {anydi-0.36.1a2.dist-info → anydi-0.36.1a3.dist-info}/RECORD +6 -6
- {anydi-0.36.1a2.dist-info → anydi-0.36.1a3.dist-info}/LICENSE +0 -0
- {anydi-0.36.1a2.dist-info → anydi-0.36.1a3.dist-info}/WHEEL +0 -0
- {anydi-0.36.1a2.dist-info → anydi-0.36.1a3.dist-info}/entry_points.txt +0 -0
anydi/_container.py
CHANGED
|
@@ -622,9 +622,7 @@ class Container:
|
|
|
622
622
|
return defaults[parameter.name]
|
|
623
623
|
|
|
624
624
|
# Get instance from overrides or context cache
|
|
625
|
-
if parameter.annotation in
|
|
626
|
-
return self._override_instances[parameter.annotation]
|
|
627
|
-
elif context and parameter.annotation in context:
|
|
625
|
+
if context and parameter.annotation in context:
|
|
628
626
|
return context[parameter.annotation]
|
|
629
627
|
|
|
630
628
|
# Resolve the instance
|
|
@@ -666,9 +664,7 @@ class Container:
|
|
|
666
664
|
return defaults[parameter.name]
|
|
667
665
|
|
|
668
666
|
# Get instance from overrides or context cache
|
|
669
|
-
if parameter.annotation in
|
|
670
|
-
return self._override_instances[parameter.annotation]
|
|
671
|
-
elif context and parameter.annotation in context:
|
|
667
|
+
if context and parameter.annotation in context:
|
|
672
668
|
return context[parameter.annotation]
|
|
673
669
|
|
|
674
670
|
# Resolve the instance
|
|
@@ -713,10 +709,9 @@ class Container:
|
|
|
713
709
|
if interface in self._override_instances:
|
|
714
710
|
return self._override_instances[interface]
|
|
715
711
|
|
|
716
|
-
if not hasattr(instance, "__dict__")
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
if hasattr(instance, "__patched__"):
|
|
712
|
+
if not hasattr(instance, "__dict__") or hasattr(
|
|
713
|
+
instance, "__resolver_getter__"
|
|
714
|
+
):
|
|
720
715
|
return instance
|
|
721
716
|
|
|
722
717
|
wrapped = {
|
|
@@ -725,20 +720,35 @@ class Container:
|
|
|
725
720
|
if isinstance(value, InstanceProxy)
|
|
726
721
|
}
|
|
727
722
|
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
_interface = wrapped[_name]
|
|
723
|
+
def __resolver_getter__(name: str) -> Any:
|
|
724
|
+
if name in wrapped:
|
|
725
|
+
_interface = wrapped[name]
|
|
732
726
|
# Resolve the dependency if it's wrapped
|
|
733
727
|
return self.resolve(_interface)
|
|
734
|
-
|
|
735
|
-
|
|
728
|
+
raise LookupError
|
|
729
|
+
|
|
730
|
+
if not hasattr(instance.__class__, "__getattribute_patched__"):
|
|
731
|
+
|
|
732
|
+
def __getattribute__(_self: Any, name: str) -> Any:
|
|
733
|
+
# Skip the resolver getter
|
|
734
|
+
if name in {"__resolver_getter__"}:
|
|
735
|
+
return object.__getattribute__(_self, name)
|
|
736
|
+
|
|
737
|
+
if hasattr(_self, "__resolver_getter__"):
|
|
738
|
+
try:
|
|
739
|
+
return _self.__resolver_getter__(name)
|
|
740
|
+
except LookupError:
|
|
741
|
+
pass
|
|
742
|
+
|
|
743
|
+
# Fall back to default behavior
|
|
744
|
+
return object.__getattribute__(_self, name)
|
|
736
745
|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
instance.__class__.
|
|
746
|
+
# Apply the patched resolver if wrapped attributes exist
|
|
747
|
+
instance.__class__.__getattribute__ = __getattribute__
|
|
748
|
+
instance.__class__.__getattribute_patched__ = True
|
|
740
749
|
|
|
741
|
-
|
|
750
|
+
# Attach the resolver getter to the instance
|
|
751
|
+
instance.__resolver_getter__ = __resolver_getter__
|
|
742
752
|
|
|
743
753
|
return instance
|
|
744
754
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
anydi/__init__.py,sha256=OfRg2EfXD65pHTGQKhfkABMwUhw5LvsuTQV_Tv4V4wk,501
|
|
2
|
-
anydi/_container.py,sha256=
|
|
2
|
+
anydi/_container.py,sha256=iJy5GoGDvs7CmV7NsTtzfnl1k53wWky6IvT0vCLAD2k,38090
|
|
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.1a3.dist-info/LICENSE,sha256=V6rU8a8fv6o2jQ-7ODHs0XfDFimot8Q6Km6CylRIDTo,1069
|
|
26
|
+
anydi-0.36.1a3.dist-info/METADATA,sha256=KacqHtuQbewO_xqZOchuioqBcgXuHcLiGjHUsp8hDDM,5066
|
|
27
|
+
anydi-0.36.1a3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
28
|
+
anydi-0.36.1a3.dist-info/entry_points.txt,sha256=GmQblwzxFg42zva1HyBYJJ7TvrTIcSAGBHmyi3bvsi4,42
|
|
29
|
+
anydi-0.36.1a3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|