modern-di 0.8.0__tar.gz → 0.9.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.
Potentially problematic release.
This version of modern-di might be problematic. Click here for more details.
- {modern_di-0.8.0 → modern_di-0.9.0}/PKG-INFO +2 -1
- {modern_di-0.8.0 → modern_di-0.9.0}/modern_di/container.py +5 -5
- {modern_di-0.8.0 → modern_di-0.9.0}/modern_di/provider_state.py +1 -1
- {modern_di-0.8.0 → modern_di-0.9.0}/modern_di/providers/abstract.py +2 -2
- {modern_di-0.8.0 → modern_di-0.9.0}/.gitignore +0 -0
- {modern_di-0.8.0 → modern_di-0.9.0}/modern_di/__init__.py +0 -0
- {modern_di-0.8.0 → modern_di-0.9.0}/modern_di/graph.py +0 -0
- {modern_di-0.8.0 → modern_di-0.9.0}/modern_di/providers/__init__.py +2 -2
- {modern_di-0.8.0 → modern_di-0.9.0}/modern_di/providers/container_provider.py +0 -0
- {modern_di-0.8.0 → modern_di-0.9.0}/modern_di/providers/context_adapter.py +0 -0
- {modern_di-0.8.0 → modern_di-0.9.0}/modern_di/providers/dict.py +0 -0
- {modern_di-0.8.0 → modern_di-0.9.0}/modern_di/providers/factory.py +0 -0
- {modern_di-0.8.0 → modern_di-0.9.0}/modern_di/providers/injected_factory.py +0 -0
- {modern_di-0.8.0 → modern_di-0.9.0}/modern_di/providers/list.py +0 -0
- {modern_di-0.8.0 → modern_di-0.9.0}/modern_di/providers/resource.py +0 -0
- {modern_di-0.8.0 → modern_di-0.9.0}/modern_di/providers/selector.py +0 -0
- {modern_di-0.8.0 → modern_di-0.9.0}/modern_di/providers/singleton.py +0 -0
- {modern_di-0.8.0 → modern_di-0.9.0}/modern_di/py.typed +0 -0
- {modern_di-0.8.0 → modern_di-0.9.0}/modern_di/scope.py +0 -0
- {modern_di-0.8.0 → modern_di-0.9.0}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: modern-di
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.0
|
|
4
4
|
Summary: Dependency Injection framework with IOC-container and scopes
|
|
5
5
|
Project-URL: repository, https://github.com/modern-python/modern-di
|
|
6
6
|
Project-URL: docs, https://modern-di.readthedocs.io
|
|
@@ -36,6 +36,7 @@ It is in development state yet and gives you the following:
|
|
|
36
36
|
- Overriding dependencies for tests.
|
|
37
37
|
- Package with zero dependencies.
|
|
38
38
|
- Integration with FastAPI and LiteStar
|
|
39
|
+
- Thread-safe and asyncio concurrency safe providers
|
|
39
40
|
|
|
40
41
|
📚 [Documentation](https://modern-di.readthedocs.io)
|
|
41
42
|
|
|
@@ -15,13 +15,13 @@ T_co = typing.TypeVar("T_co", covariant=True)
|
|
|
15
15
|
|
|
16
16
|
class Container(contextlib.AbstractAsyncContextManager["Container"]):
|
|
17
17
|
__slots__ = (
|
|
18
|
-
"scope",
|
|
19
|
-
"parent_container",
|
|
20
|
-
"context",
|
|
21
18
|
"_is_async",
|
|
22
|
-
"_provider_states",
|
|
23
19
|
"_overrides",
|
|
20
|
+
"_provider_states",
|
|
24
21
|
"_use_threading_lock",
|
|
22
|
+
"context",
|
|
23
|
+
"parent_container",
|
|
24
|
+
"scope",
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
def __init__(
|
|
@@ -37,7 +37,7 @@ class Container(contextlib.AbstractAsyncContextManager["Container"]):
|
|
|
37
37
|
self.context: dict[str, typing.Any] = context or {}
|
|
38
38
|
self._is_async: bool | None = None
|
|
39
39
|
self._provider_states: dict[str, ProviderState[typing.Any]] = {}
|
|
40
|
-
self._overrides: dict[str, typing.Any] = {}
|
|
40
|
+
self._overrides: dict[str, typing.Any] = parent_container._overrides if parent_container else {} # noqa: SLF001
|
|
41
41
|
self._use_threading_lock = use_threading_lock
|
|
42
42
|
|
|
43
43
|
def _exit(self) -> None:
|
|
@@ -8,7 +8,7 @@ T_co = typing.TypeVar("T_co", covariant=True)
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class ProviderState(typing.Generic[T_co]):
|
|
11
|
-
__slots__ = "
|
|
11
|
+
__slots__ = "asyncio_lock", "context_stack", "instance", "threading_lock"
|
|
12
12
|
|
|
13
13
|
def __init__(self, use_asyncio_lock: bool, use_threading_lock: bool) -> None:
|
|
14
14
|
self.context_stack: contextlib.AsyncExitStack | contextlib.ExitStack | None = None
|
|
@@ -39,10 +39,10 @@ class AbstractProvider(typing.Generic[T_co], abc.ABC):
|
|
|
39
39
|
|
|
40
40
|
class AbstractOverrideProvider(AbstractProvider[T_co], abc.ABC):
|
|
41
41
|
def override(self, override_object: object, container: Container) -> None:
|
|
42
|
-
container.
|
|
42
|
+
container.override(self.provider_id, override_object)
|
|
43
43
|
|
|
44
44
|
def reset_override(self, container: Container) -> None:
|
|
45
|
-
container.
|
|
45
|
+
container.reset_override(self.provider_id)
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
class AbstractCreatorProvider(AbstractOverrideProvider[T_co], abc.ABC):
|
|
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
|