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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: modern-di
3
- Version: 0.8.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__ = "context_stack", "instance", "asyncio_lock", "threading_lock"
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.find_container(self.scope).override(self.provider_id, override_object)
42
+ container.override(self.provider_id, override_object)
43
43
 
44
44
  def reset_override(self, container: Container) -> None:
45
- container.find_container(self.scope).reset_override(self.provider_id)
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
@@ -13,10 +13,10 @@ __all__ = [
13
13
  "AbstractProvider",
14
14
  "ContainerProvider",
15
15
  "ContextAdapter",
16
- "Factory",
17
16
  "Dict",
17
+ "Factory",
18
18
  "List",
19
+ "Resource",
19
20
  "Selector",
20
21
  "Singleton",
21
- "Resource",
22
22
  ]
File without changes
File without changes
File without changes