anydi 0.37.0__py3-none-any.whl → 0.37.1__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 +2 -2
- anydi/_types.py +12 -12
- {anydi-0.37.0.dist-info → anydi-0.37.1.dist-info}/METADATA +2 -1
- {anydi-0.37.0.dist-info → anydi-0.37.1.dist-info}/RECORD +7 -7
- {anydi-0.37.0.dist-info → anydi-0.37.1.dist-info}/LICENSE +0 -0
- {anydi-0.37.0.dist-info → anydi-0.37.1.dist-info}/WHEEL +0 -0
- {anydi-0.37.0.dist-info → anydi-0.37.1.dist-info}/entry_points.txt +0 -0
anydi/_container.py
CHANGED
|
@@ -639,7 +639,7 @@ class Container:
|
|
|
639
639
|
|
|
640
640
|
# Wrap the instance in a proxy for testing
|
|
641
641
|
if self.testing:
|
|
642
|
-
return InstanceProxy(interface=parameter.annotation
|
|
642
|
+
return InstanceProxy(instance, interface=parameter.annotation)
|
|
643
643
|
return instance
|
|
644
644
|
|
|
645
645
|
async def _aget_provided_kwargs(
|
|
@@ -683,7 +683,7 @@ class Container:
|
|
|
683
683
|
|
|
684
684
|
# Wrap the instance in a proxy for testing
|
|
685
685
|
if self.testing:
|
|
686
|
-
return InstanceProxy(interface=parameter.annotation
|
|
686
|
+
return InstanceProxy(instance, interface=parameter.annotation)
|
|
687
687
|
return instance
|
|
688
688
|
|
|
689
689
|
def _resolve_parameter(
|
anydi/_types.py
CHANGED
|
@@ -5,6 +5,7 @@ from collections.abc import Iterable
|
|
|
5
5
|
from types import ModuleType
|
|
6
6
|
from typing import Annotated, Any, NamedTuple, Union
|
|
7
7
|
|
|
8
|
+
import wrapt
|
|
8
9
|
from typing_extensions import Literal, Self, TypeAlias
|
|
9
10
|
|
|
10
11
|
Scope = Literal["transient", "singleton", "request"]
|
|
@@ -37,20 +38,19 @@ def is_event_type(obj: Any) -> bool:
|
|
|
37
38
|
return inspect.isclass(obj) and issubclass(obj, Event)
|
|
38
39
|
|
|
39
40
|
|
|
40
|
-
class InstanceProxy:
|
|
41
|
-
|
|
41
|
+
class InstanceProxy(wrapt.ObjectProxy): # type: ignore[misc]
|
|
42
|
+
def __init__(self, wrapped: Any, *, interface: type[Any]) -> None:
|
|
43
|
+
super().__init__(wrapped)
|
|
44
|
+
self._self_interface = interface
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
self.
|
|
46
|
+
@property
|
|
47
|
+
def interface(self) -> type[Any]:
|
|
48
|
+
return self._self_interface
|
|
46
49
|
|
|
47
|
-
def __getattribute__(self,
|
|
48
|
-
if
|
|
49
|
-
return object.__getattribute__(self,
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
def __repr__(self) -> str:
|
|
53
|
-
return f"InstanceProxy({self.interface!r})"
|
|
50
|
+
def __getattribute__(self, item: str) -> Any:
|
|
51
|
+
if item in "interface":
|
|
52
|
+
return object.__getattribute__(self, item)
|
|
53
|
+
return object.__getattribute__(self, item)
|
|
54
54
|
|
|
55
55
|
|
|
56
56
|
class ProviderDecoratorArgs(NamedTuple):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: anydi
|
|
3
|
-
Version: 0.37.
|
|
3
|
+
Version: 0.37.1
|
|
4
4
|
Summary: Dependency Injection library
|
|
5
5
|
Home-page: https://github.com/antonrh/anydi
|
|
6
6
|
License: MIT
|
|
@@ -33,6 +33,7 @@ Requires-Dist: anyio (>=3.7.1)
|
|
|
33
33
|
Requires-Dist: mkdocs (>=1.4.2,<2.0.0) ; extra == "docs"
|
|
34
34
|
Requires-Dist: mkdocs-material (>=9.5.29,<10.0.0) ; extra == "docs"
|
|
35
35
|
Requires-Dist: typing-extensions (>=4.12.1,<5.0.0)
|
|
36
|
+
Requires-Dist: wrapt (>=1.17.0,<2.0.0)
|
|
36
37
|
Project-URL: Repository, https://github.com/antonrh/anydi
|
|
37
38
|
Description-Content-Type: text/markdown
|
|
38
39
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
anydi/__init__.py,sha256=OfRg2EfXD65pHTGQKhfkABMwUhw5LvsuTQV_Tv4V4wk,501
|
|
2
|
-
anydi/_container.py,sha256
|
|
2
|
+
anydi/_container.py,sha256=6dr2sOSkx8GRdqzlokHB5McfBNOWp_9ozyyiS5dpxoE,38320
|
|
3
3
|
anydi/_context.py,sha256=7LV_SL4QWkJeiG7_4D9PZ5lmU-MPzhofxC95zCgY9Gc,2651
|
|
4
4
|
anydi/_provider.py,sha256=1IyxHO83NHjsPDHLDIZtW1pJ7i8VpWD3EM4T6duw9zA,7661
|
|
5
|
-
anydi/_types.py,sha256=
|
|
5
|
+
anydi/_types.py,sha256=fdO4xNXtGMxVArmlfDkFYbyR895ixkBTW6V8lMceN7Q,1562
|
|
6
6
|
anydi/_utils.py,sha256=INI0jNIXrJ6LS4zqJymMO2yUEobpxmBGASf4G_vR6AU,4378
|
|
7
7
|
anydi/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
anydi/ext/_utils.py,sha256=U6sRqWzccWUu7eMhbXX1NrwcaxitQF9cO1KxnKF37gw,2566
|
|
@@ -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.37.
|
|
26
|
-
anydi-0.37.
|
|
27
|
-
anydi-0.37.
|
|
28
|
-
anydi-0.37.
|
|
29
|
-
anydi-0.37.
|
|
25
|
+
anydi-0.37.1.dist-info/LICENSE,sha256=V6rU8a8fv6o2jQ-7ODHs0XfDFimot8Q6Km6CylRIDTo,1069
|
|
26
|
+
anydi-0.37.1.dist-info/METADATA,sha256=9pkB0M7YtPuvIXxskF0h7roe7FY_R90rHZ6772w2LSI,5103
|
|
27
|
+
anydi-0.37.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
28
|
+
anydi-0.37.1.dist-info/entry_points.txt,sha256=GmQblwzxFg42zva1HyBYJJ7TvrTIcSAGBHmyi3bvsi4,42
|
|
29
|
+
anydi-0.37.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|