modern-di 0.8.0__py3-none-any.whl → 0.9.0__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.

Potentially problematic release.


This version of modern-di might be problematic. Click here for more details.

modern_di/container.py CHANGED
@@ -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
@@ -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
  ]
@@ -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):
@@ -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
 
@@ -1,11 +1,11 @@
1
1
  modern_di/__init__.py,sha256=L01VkzSJiV0d0FPrh1DZ-Wy5mUmoG6X-oLz7xYxtehI,194
2
- modern_di/container.py,sha256=ySfFh9keq5XZvIEpxEFUPW226aVA_JGC2k3buTxPL9U,4831
2
+ modern_di/container.py,sha256=a9NB7P4OQ92seGGztu9SGBChmv79nJ9kHxeF8V2zwpg,4900
3
3
  modern_di/graph.py,sha256=X60wtG3Mqus_5YZNiZlQuXoHODBp7rYl_IHJs7GzSQM,1356
4
- modern_di/provider_state.py,sha256=JBn3Yi2KzFpclVr_Iyiewosqy9MNZk6jrkkF433fJGQ,1358
4
+ modern_di/provider_state.py,sha256=oU08QnMr0yhIZKkz0Pee8_RnWtETDE9ux4JB83qhwTI,1358
5
5
  modern_di/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  modern_di/scope.py,sha256=e6Olc-CF89clbYDNGciy-F8EqJt1Mw2703zfuJaEY94,113
7
- modern_di/providers/__init__.py,sha256=r594L4kWv_XCHVZcsfUIGBtlXCmih6NR1Ifa105XoQ4,649
8
- modern_di/providers/abstract.py,sha256=gi4I340Y5eBg0-_lUFsgv1qA0En7oD0F3j53Gf5TgRY,3161
7
+ modern_di/providers/__init__.py,sha256=tnF38UC-INW1GPPsGlj5tLqGi6fMfHodpi91wHDW-jY,649
8
+ modern_di/providers/abstract.py,sha256=UMj4CRn-JfGZfiveWFTkH7V92h4UXS4eYf8noZqPWGQ,3107
9
9
  modern_di/providers/container_provider.py,sha256=r5IEQXgKtPwvHvbqkbPnmGyDGGCCjokTtdard9Rvt40,548
10
10
  modern_di/providers/context_adapter.py,sha256=_b1x3ToQPWT-9KkDioFhw1W8Q1VXZYUnczfYzMTobVA,760
11
11
  modern_di/providers/dict.py,sha256=nCU9iaqteYHDbILAfhrdnbMgS9_emE4MS7Xn2VoUlPo,858
@@ -15,6 +15,6 @@ modern_di/providers/list.py,sha256=3hx34RfBRmqzh-cT5D6wSTDJPkBGMK_ul4n9gQz-o9M,7
15
15
  modern_di/providers/resource.py,sha256=CsMekkVISklTqN539XqH4iE80vfc6sQMav5OT8fZvyA,4591
16
16
  modern_di/providers/selector.py,sha256=RQbHD2-Liw-TGqu6UELbfCzXYuqxiO_Mg1tLyF3mKQo,1419
17
17
  modern_di/providers/singleton.py,sha256=_hUpCmbHgLAigdhBiu0zypwWwrIGdB6_oZkGfuLxzNE,2372
18
- modern_di-0.8.0.dist-info/METADATA,sha256=io18Xr4sXvf11cQambypZuh4aB4IZ9XPaMq2SJJTG_c,5440
19
- modern_di-0.8.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
20
- modern_di-0.8.0.dist-info/RECORD,,
18
+ modern_di-0.9.0.dist-info/METADATA,sha256=jmn_QkeNOtjU_z1raF5FECSDkaLMhBkTXjb8SEqT7Hc,5493
19
+ modern_di-0.9.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
20
+ modern_di-0.9.0.dist-info/RECORD,,