modern-di 0.6.0__tar.gz → 0.7.1__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,10 +1,11 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: modern-di
3
- Version: 0.6.0
3
+ Version: 0.7.1
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
7
7
  Author-email: Artur Shiriev <me@shiriev.ru>
8
+ License: MIT
8
9
  Keywords: DI,dependency injector,ioc-container,mocks,python
9
10
  Classifier: Programming Language :: Python :: 3.10
10
11
  Classifier: Programming Language :: Python :: 3.11
@@ -27,13 +28,14 @@ Description-Content-Type: text/markdown
27
28
 
28
29
  Dependency injection framework for Python inspired by `dependency-injector` and `dishka`.
29
30
 
30
- It is in early development state and gives you the following:
31
+ It is in development state yet and gives you the following:
31
32
  - DI framework with IOC-container and scopes.
32
33
  - Async and sync resolving.
33
34
  - Python 3.10-3.13 support.
34
35
  - Full coverage by types annotations (mypy in strict mode).
35
36
  - Overriding dependencies for tests.
36
37
  - Package with zero dependencies.
38
+ - Integration with FastAPI and LiteStar
37
39
 
38
40
  📚 [Documentation](https://modern-di.readthedocs.io)
39
41
 
@@ -1,4 +1,5 @@
1
1
  from modern_di.providers.abstract import AbstractProvider
2
+ from modern_di.providers.container_provider import ContainerProvider
2
3
  from modern_di.providers.context_adapter import ContextAdapter
3
4
  from modern_di.providers.dict import Dict
4
5
  from modern_di.providers.factory import Factory
@@ -10,6 +11,7 @@ from modern_di.providers.singleton import Singleton
10
11
 
11
12
  __all__ = [
12
13
  "AbstractProvider",
14
+ "ContainerProvider",
13
15
  "ContextAdapter",
14
16
  "Factory",
15
17
  "Dict",
@@ -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.override(self.provider_id, override_object)
42
+ container.find_container(self.scope).override(self.provider_id, override_object)
43
43
 
44
44
  def reset_override(self, container: Container) -> None:
45
- container.reset_override(self.provider_id)
45
+ container.find_container(self.scope).reset_override(self.provider_id)
46
46
 
47
47
 
48
48
  class AbstractCreatorProvider(AbstractOverrideProvider[T_co], abc.ABC):
@@ -0,0 +1,19 @@
1
+ import typing
2
+
3
+ import modern_di
4
+ from modern_di import Container
5
+ from modern_di.providers import AbstractProvider
6
+
7
+
8
+ T_co = typing.TypeVar("T_co", covariant=True)
9
+ P = typing.ParamSpec("P")
10
+
11
+
12
+ class ContainerProvider(AbstractProvider[modern_di.Container]):
13
+ __slots__ = AbstractProvider.BASE_SLOTS
14
+
15
+ async def async_resolve(self, container: Container) -> modern_di.Container:
16
+ return self.sync_resolve(container)
17
+
18
+ def sync_resolve(self, container: Container) -> modern_di.Container:
19
+ return container.find_container(self.scope)
File without changes
File without changes
File without changes
File without changes
File without changes