modern-di 0.5.0__tar.gz → 0.6.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.

Files changed (56) hide show
  1. modern_di-0.6.0/PKG-INFO +120 -0
  2. {modern_di-0.5.0 → modern_di-0.6.0}/modern_di/providers/factory.py +5 -0
  3. modern_di-0.6.0/modern_di/providers/injected_factory.py +24 -0
  4. {modern_di-0.5.0 → modern_di-0.6.0}/modern_di/providers/resource.py +14 -2
  5. modern_di-0.6.0/pyproject.toml +56 -0
  6. modern_di-0.5.0/.github/workflows/core-ci.yml +0 -52
  7. modern_di-0.5.0/.github/workflows/fastapi-ci.yml +0 -54
  8. modern_di-0.5.0/.github/workflows/publish.yml +0 -30
  9. modern_di-0.5.0/.readthedocs.yaml +0 -13
  10. modern_di-0.5.0/Justfile +0 -23
  11. modern_di-0.5.0/LICENSE +0 -21
  12. modern_di-0.5.0/PKG-INFO +0 -39
  13. modern_di-0.5.0/README.md +0 -20
  14. modern_di-0.5.0/docs/conf.py +0 -34
  15. modern_di-0.5.0/docs/dev/contributing.md +0 -19
  16. modern_di-0.5.0/docs/dev/development-notes.md +0 -25
  17. modern_di-0.5.0/docs/index.md +0 -11
  18. modern_di-0.5.0/docs/requirements.txt +0 -4
  19. modern_di-0.5.0/integrations/fastapi/Justfile +0 -18
  20. modern_di-0.5.0/integrations/fastapi/README.md +0 -6
  21. modern_di-0.5.0/integrations/fastapi/modern_di_fastapi/__init__.py +0 -9
  22. modern_di-0.5.0/integrations/fastapi/modern_di_fastapi/main.py +0 -47
  23. modern_di-0.5.0/integrations/fastapi/pyproject.toml +0 -87
  24. modern_di-0.5.0/integrations/fastapi/tests/__init__.py +0 -0
  25. modern_di-0.5.0/integrations/fastapi/tests/conftest.py +0 -28
  26. modern_di-0.5.0/integrations/fastapi/tests/dependencies.py +0 -17
  27. modern_di-0.5.0/integrations/fastapi/tests/test_routes.py +0 -57
  28. modern_di-0.5.0/integrations/fastapi/tests/test_websockets.py +0 -33
  29. modern_di-0.5.0/modern_di/py.typed +0 -0
  30. modern_di-0.5.0/pyproject.toml +0 -91
  31. modern_di-0.5.0/tests/__init__.py +0 -0
  32. modern_di-0.5.0/tests/creators.py +0 -22
  33. modern_di-0.5.0/tests/providers/__init__.py +0 -0
  34. modern_di-0.5.0/tests/providers/test_context_adapter.py +0 -30
  35. modern_di-0.5.0/tests/providers/test_dict.py +0 -24
  36. modern_di-0.5.0/tests/providers/test_factory.py +0 -93
  37. modern_di-0.5.0/tests/providers/test_list.py +0 -24
  38. modern_di-0.5.0/tests/providers/test_resource.py +0 -119
  39. modern_di-0.5.0/tests/providers/test_selector.py +0 -45
  40. modern_di-0.5.0/tests/providers/test_singleton.py +0 -115
  41. modern_di-0.5.0/tests/test_container.py +0 -46
  42. modern_di-0.5.0/tests/test_graph.py +0 -39
  43. {modern_di-0.5.0 → modern_di-0.6.0}/.gitignore +0 -0
  44. {modern_di-0.5.0 → modern_di-0.6.0}/modern_di/__init__.py +0 -0
  45. {modern_di-0.5.0 → modern_di-0.6.0}/modern_di/container.py +0 -0
  46. {modern_di-0.5.0 → modern_di-0.6.0}/modern_di/graph.py +0 -0
  47. {modern_di-0.5.0 → modern_di-0.6.0}/modern_di/provider_state.py +0 -0
  48. {modern_di-0.5.0 → modern_di-0.6.0}/modern_di/providers/__init__.py +0 -0
  49. {modern_di-0.5.0 → modern_di-0.6.0}/modern_di/providers/abstract.py +0 -0
  50. {modern_di-0.5.0 → modern_di-0.6.0}/modern_di/providers/context_adapter.py +0 -0
  51. {modern_di-0.5.0 → modern_di-0.6.0}/modern_di/providers/dict.py +0 -0
  52. {modern_di-0.5.0 → modern_di-0.6.0}/modern_di/providers/list.py +0 -0
  53. {modern_di-0.5.0 → modern_di-0.6.0}/modern_di/providers/selector.py +0 -0
  54. {modern_di-0.5.0 → modern_di-0.6.0}/modern_di/providers/singleton.py +0 -0
  55. {modern_di-0.5.0/integrations/fastapi/modern_di_fastapi → modern_di-0.6.0/modern_di}/py.typed +0 -0
  56. {modern_di-0.5.0 → modern_di-0.6.0}/modern_di/scope.py +0 -0
@@ -0,0 +1,120 @@
1
+ Metadata-Version: 2.3
2
+ Name: modern-di
3
+ Version: 0.6.0
4
+ Summary: Dependency Injection framework with IOC-container and scopes
5
+ Project-URL: repository, https://github.com/modern-python/modern-di
6
+ Project-URL: docs, https://modern-di.readthedocs.io
7
+ Author-email: Artur Shiriev <me@shiriev.ru>
8
+ Keywords: DI,dependency injector,ioc-container,mocks,python
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Topic :: Software Development :: Libraries
14
+ Classifier: Typing :: Typed
15
+ Requires-Python: <4,>=3.10
16
+ Description-Content-Type: text/markdown
17
+
18
+ "Modern-DI"
19
+ ==
20
+
21
+ | Project | Badges |
22
+ |--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
23
+ | common | [![MyPy Strict](https://img.shields.io/badge/mypy-strict-blue)](https://mypy.readthedocs.io/en/stable/getting_started.html#strict-mode-and-configuration) [![GitHub stars](https://img.shields.io/github/stars/modern-python/modern-di)](https://github.com/modern-python/modern-di/stargazers) |
24
+ | modern-di | [![Supported versions](https://img.shields.io/pypi/pyversions/modern-di.svg)](https://pypi.python.org/pypi/modern-di ) [![downloads](https://img.shields.io/pypi/dm/modern-di.svg)](https://pypistats.org/packages/modern-di) |
25
+ | modern-di-fastapi | [![Supported versions](https://img.shields.io/pypi/pyversions/modern-di-fastapi.svg)](https://pypi.python.org/pypi/modern-di-fastapi) [![downloads](https://img.shields.io/pypi/dm/modern-di-fastapi.svg)](https://pypistats.org/packages/modern-di-fastapi) |
26
+ | modern-di-litestar | [![Supported versions](https://img.shields.io/pypi/pyversions/modern-di-litestar.svg)](https://pypi.python.org/pypi/modern-di-litestar) [![downloads](https://img.shields.io/pypi/dm/modern-di-litestar.svg)](https://pypistats.org/packages/modern-di-litestar) |
27
+
28
+ Dependency injection framework for Python inspired by `dependency-injector` and `dishka`.
29
+
30
+ It is in early development state and gives you the following:
31
+ - DI framework with IOC-container and scopes.
32
+ - Async and sync resolving.
33
+ - Python 3.10-3.13 support.
34
+ - Full coverage by types annotations (mypy in strict mode).
35
+ - Overriding dependencies for tests.
36
+ - Package with zero dependencies.
37
+
38
+ 📚 [Documentation](https://modern-di.readthedocs.io)
39
+
40
+ ## Describe resources and classes:
41
+ ```python
42
+ import dataclasses
43
+ import logging
44
+ import typing
45
+
46
+
47
+ logger = logging.getLogger(__name__)
48
+
49
+
50
+ # singleton provider with finalization
51
+ def create_sync_resource() -> typing.Iterator[str]:
52
+ logger.debug("Resource initiated")
53
+ try:
54
+ yield "sync resource"
55
+ finally:
56
+ logger.debug("Resource destructed")
57
+
58
+
59
+ # same, but async
60
+ async def create_async_resource() -> typing.AsyncIterator[str]:
61
+ logger.debug("Async resource initiated")
62
+ try:
63
+ yield "async resource"
64
+ finally:
65
+ logger.debug("Async resource destructed")
66
+
67
+
68
+ @dataclasses.dataclass(kw_only=True, slots=True)
69
+ class DependentFactory:
70
+ sync_resource: str
71
+ async_resource: str
72
+ ```
73
+
74
+ ## Describe dependencies graph (IoC-container)
75
+ ```python
76
+ from modern_di import BaseGraph, Scope, providers
77
+
78
+
79
+ class Dependencies(BaseGraph):
80
+ sync_resource = providers.Resource(Scope.APP, create_sync_resource)
81
+ async_resource = providers.Resource(Scope.APP, create_async_resource)
82
+
83
+ simple_factory = providers.Factory(Scope.REQUEST, SimpleFactory, dep1="text", dep2=123)
84
+ dependent_factory = providers.Factory(
85
+ Scope.REQUEST,
86
+ sync_resource=sync_resource,
87
+ async_resource=async_resource,
88
+ )
89
+ ```
90
+
91
+ ## Create container and resolve dependencies in your code
92
+ ```python
93
+ from modern_di import Container, Scope
94
+
95
+
96
+ # init container of app scope in sync mode
97
+ with Container(scope=Scope.APP) as app_container:
98
+ # resolve sync resource
99
+ Dependencies.sync_resource.sync_resolve(app_container)
100
+
101
+
102
+ # init container of app scope in async mode
103
+ async with Container(scope=Scope.APP) as app_container:
104
+ # resolve async resource
105
+ await Dependencies.async_resource.async_resolve(app_container)
106
+
107
+ # resolve sync resource
108
+ instance1 = await Dependencies.sync_resource.async_resolve(app_container)
109
+ instance2 = Dependencies.sync_resource.sync_resolve(app_container)
110
+ assert instance1 is instance2
111
+
112
+ # create container of request scope
113
+ async with app_container.build_child_container(scope=Scope.REQUEST) as request_container:
114
+ # resolve factories of request scope
115
+ Dependencies.simple_factory.sync_resolve(request_container)
116
+ await Dependencies.dependent_factory.async_resolve(request_container)
117
+
118
+ # resources of app-scope also can be resolved here
119
+
120
+ ```
@@ -3,6 +3,7 @@ import typing
3
3
 
4
4
  from modern_di import Container
5
5
  from modern_di.providers.abstract import AbstractCreatorProvider
6
+ from modern_di.providers.injected_factory import InjectedFactory
6
7
 
7
8
 
8
9
  T_co = typing.TypeVar("T_co", covariant=True)
@@ -21,6 +22,10 @@ class Factory(AbstractCreatorProvider[T_co]):
21
22
  ) -> None:
22
23
  super().__init__(scope, creator, *args, **kwargs)
23
24
 
25
+ @property
26
+ def factory_provider(self) -> InjectedFactory[T_co]:
27
+ return InjectedFactory(self)
28
+
24
29
  async def async_resolve(self, container: Container) -> T_co:
25
30
  container = container.find_container(self.scope)
26
31
  if (override := container.fetch_override(self.provider_id)) is not None:
@@ -0,0 +1,24 @@
1
+ import functools
2
+ import typing
3
+
4
+ from modern_di import Container
5
+ from modern_di.providers.abstract import AbstractProvider
6
+
7
+
8
+ T_co = typing.TypeVar("T_co", covariant=True)
9
+ P = typing.ParamSpec("P")
10
+
11
+
12
+ class InjectedFactory(typing.Generic[T_co]):
13
+ __slots__ = ("_factory_provider",)
14
+
15
+ def __init__(self, factory_provider: AbstractProvider[T_co]) -> None:
16
+ self._factory_provider = factory_provider
17
+
18
+ async def async_resolve(self, container: Container) -> typing.Callable[[], T_co]:
19
+ await self._factory_provider.async_resolve(container)
20
+ return functools.partial(self._factory_provider.sync_resolve, container)
21
+
22
+ def sync_resolve(self, container: Container) -> typing.Callable[[], T_co]:
23
+ self._factory_provider.sync_resolve(container)
24
+ return functools.partial(self._factory_provider.sync_resolve, container)
@@ -23,7 +23,13 @@ class Resource(AbstractCreatorProvider[T_co]):
23
23
  def __init__(
24
24
  self,
25
25
  scope: enum.IntEnum,
26
- creator: typing.Callable[P, typing.Iterator[T_co] | typing.AsyncIterator[T_co]],
26
+ creator: typing.Callable[
27
+ P,
28
+ typing.Iterator[T_co]
29
+ | typing.AsyncIterator[T_co]
30
+ | typing.ContextManager[T_co]
31
+ | typing.AsyncContextManager[T_co],
32
+ ],
27
33
  *args: P.args,
28
34
  **kwargs: P.kwargs,
29
35
  ) -> None:
@@ -34,9 +40,15 @@ class Resource(AbstractCreatorProvider[T_co]):
34
40
  elif inspect.isgeneratorfunction(creator):
35
41
  self._is_async = False
36
42
  new_creator = contextlib.contextmanager(creator)
43
+ elif isinstance(creator, type) and issubclass(creator, typing.AsyncContextManager):
44
+ self._is_async = True
45
+ new_creator = creator
46
+ elif isinstance(creator, type) and issubclass(creator, typing.ContextManager):
47
+ self._is_async = False
48
+ new_creator = creator
37
49
  else:
38
50
  msg = "Unsupported resource type"
39
- raise RuntimeError(msg)
51
+ raise TypeError(msg)
40
52
 
41
53
  super().__init__(scope, new_creator, *args, **kwargs)
42
54
 
@@ -0,0 +1,56 @@
1
+ [project]
2
+ name = "modern-di"
3
+ description = "Dependency Injection framework with IOC-container and scopes"
4
+ authors = [{ name = "Artur Shiriev", email = "me@shiriev.ru" }]
5
+ requires-python = ">=3.10,<4"
6
+ license = "MIT"
7
+ keywords = ["DI", "dependency injector", "ioc-container", "mocks", "python"]
8
+ classifiers = [
9
+ "Programming Language :: Python :: 3.10",
10
+ "Programming Language :: Python :: 3.11",
11
+ "Programming Language :: Python :: 3.12",
12
+ "Programming Language :: Python :: 3.13",
13
+ "Typing :: Typed",
14
+ "Topic :: Software Development :: Libraries",
15
+ ]
16
+ dynamic = ["version", "readme"]
17
+
18
+ [project.urls]
19
+ repository = "https://github.com/modern-python/modern-di"
20
+ docs = "https://modern-di.readthedocs.io"
21
+
22
+ [dependency-groups]
23
+ dev = [
24
+ "pytest",
25
+ "pytest-cov",
26
+ "pytest-asyncio",
27
+ "ruff",
28
+ "mypy",
29
+ "typing-extensions",
30
+ ]
31
+
32
+ [build-system]
33
+ requires = ["hatchling", "hatch-vcs", "hatch-fancy-pypi-readme"]
34
+ build-backend = "hatchling.build"
35
+
36
+ [tool.hatch.version]
37
+ source = "vcs"
38
+ raw-options.root = "../.."
39
+ fallback-version = "0"
40
+
41
+ [tool.hatch.build]
42
+ include = ["modern_di"]
43
+
44
+ [tool.hatch.metadata.hooks.fancy-pypi-readme]
45
+ content-type = "text/markdown"
46
+
47
+ [[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
48
+ path = "../../README.md"
49
+
50
+ [tool.pytest.ini_options]
51
+ addopts = "--cov=. --cov-report term-missing"
52
+ asyncio_mode = "auto"
53
+ asyncio_default_fixture_loop_scope = "function"
54
+
55
+ [tool.coverage.report]
56
+ exclude_also = ["if typing.TYPE_CHECKING:"]
@@ -1,52 +0,0 @@
1
- name: core ci
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
- paths:
8
- - 'modern_di/**'
9
- - 'tests/**'
10
- - '.github/workflows/core-ci.yml'
11
- pull_request:
12
- paths:
13
- - 'modern_di/**'
14
- - 'tests/**'
15
- - '.github/workflows/core-ci.yml'
16
-
17
- concurrency:
18
- group: ${{ github.head_ref || github.run_id }} core
19
- cancel-in-progress: true
20
-
21
- jobs:
22
- lint:
23
- runs-on: ubuntu-latest
24
- steps:
25
- - uses: actions/checkout@v4
26
- - uses: extractions/setup-just@v2
27
- - uses: astral-sh/setup-uv@v3
28
- with:
29
- enable-cache: true
30
- cache-dependency-glob: "pyproject.toml"
31
- - run: uv python install 3.10
32
- - run: just install lint-ci
33
-
34
- pytest:
35
- runs-on: ubuntu-latest
36
- strategy:
37
- fail-fast: false
38
- matrix:
39
- python-version:
40
- - "3.10"
41
- - "3.11"
42
- - "3.12"
43
- - "3.13"
44
- steps:
45
- - uses: actions/checkout@v4
46
- - uses: extractions/setup-just@v2
47
- - uses: astral-sh/setup-uv@v3
48
- with:
49
- enable-cache: true
50
- cache-dependency-glob: "pyproject.toml"
51
- - run: uv python install ${{ matrix.python-version }}
52
- - run: just install test . --cov=. --cov-report xml
@@ -1,54 +0,0 @@
1
- name: fastapi ci
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
- paths:
8
- - 'integrations/fastapi/**'
9
- - '.github/workflows/fastapi-ci.yml'
10
- pull_request:
11
- paths:
12
- - 'integrations/fastapi/**'
13
- - '.github/workflows/fastapi-ci.yml'
14
-
15
- defaults:
16
- run:
17
- working-directory: integrations/fastapi
18
-
19
- concurrency:
20
- group: ${{ github.head_ref || github.run_id }} fastapi
21
- cancel-in-progress: false
22
-
23
- jobs:
24
- lint:
25
- runs-on: ubuntu-latest
26
- steps:
27
- - uses: actions/checkout@v4
28
- - uses: extractions/setup-just@v2
29
- - uses: astral-sh/setup-uv@v3
30
- with:
31
- enable-cache: true
32
- cache-dependency-glob: "pyproject.toml"
33
- - run: uv python install 3.10
34
- - run: just install lint-ci
35
-
36
- pytest:
37
- runs-on: ubuntu-latest
38
- strategy:
39
- fail-fast: false
40
- matrix:
41
- python-version:
42
- - "3.10"
43
- - "3.11"
44
- - "3.12"
45
- - "3.13"
46
- steps:
47
- - uses: actions/checkout@v4
48
- - uses: extractions/setup-just@v2
49
- - uses: astral-sh/setup-uv@v3
50
- with:
51
- enable-cache: true
52
- cache-dependency-glob: "pyproject.toml"
53
- - run: uv python install ${{ matrix.python-version }}
54
- - run: just install test . --cov=. --cov-report xml
@@ -1,30 +0,0 @@
1
- name: Publish Package
2
-
3
- on:
4
- release:
5
- types:
6
- - published
7
-
8
- jobs:
9
- publish:
10
- runs-on: ubuntu-latest
11
- steps:
12
- - uses: actions/checkout@v4
13
- - uses: extractions/setup-just@v2
14
- - uses: astral-sh/setup-uv@v3
15
- with:
16
- enable-cache: true
17
- cache-dependency-glob: "pyproject.toml"
18
-
19
- - if: startsWith(github.ref_name, 'core')
20
- run: just publish modern-di
21
- env:
22
- PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
23
-
24
- - if: startsWith(github.ref_name, 'fastapi')
25
- run: |
26
- export SETUPTOOLS_SCM_PRETEND_VERSION=$(echo "${{ github.ref_name }}" | sed 's/^fastapi-//; s/-.*$//')
27
- echo "SETUPTOOLS_SCM_PRETEND_VERSION=$SETUPTOOLS_SCM_PRETEND_VERSION"
28
- just publish modern-di-fastapi
29
- env:
30
- PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
@@ -1,13 +0,0 @@
1
- version: 2
2
-
3
- build:
4
- os: "ubuntu-22.04"
5
- tools:
6
- python: "3.10"
7
-
8
- python:
9
- install:
10
- - requirements: docs/requirements.txt
11
-
12
- sphinx:
13
- configuration: docs/conf.py
modern_di-0.5.0/Justfile DELETED
@@ -1,23 +0,0 @@
1
- default: install lint test
2
-
3
- install:
4
- uv lock --upgrade
5
- uv sync --all-extras --frozen
6
-
7
- lint:
8
- uv run ruff format .
9
- uv run ruff check . --fix
10
- uv run mypy .
11
-
12
- lint-ci:
13
- uv run ruff format . --check
14
- uv run ruff check . --no-fix
15
- uv run mypy .
16
-
17
- test *args:
18
- uv run pytest tests {{ args }}
19
-
20
- publish package:
21
- rm -rf dist
22
- uv build --package {{package}}
23
- uv publish --token $PYPI_TOKEN
modern_di-0.5.0/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 modern-python
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
modern_di-0.5.0/PKG-INFO DELETED
@@ -1,39 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: modern-di
3
- Version: 0.5.0
4
- Summary: Dependency Injection framework with IOC-container and scopes
5
- Project-URL: repository, https://github.com/modern-python/modern-di
6
- Project-URL: docs, https://modern-di.readthedocs.io
7
- Author-email: Artur Shiriev <me@shiriev.ru>
8
- License-Expression: MIT
9
- License-File: LICENSE
10
- Keywords: dependency injector,di,ioc-container,mocks,python
11
- Classifier: Programming Language :: Python :: 3.10
12
- Classifier: Programming Language :: Python :: 3.11
13
- Classifier: Programming Language :: Python :: 3.12
14
- Classifier: Programming Language :: Python :: 3.13
15
- Classifier: Topic :: Software Development :: Libraries
16
- Classifier: Typing :: Typed
17
- Requires-Python: <4,>=3.10
18
- Description-Content-Type: text/markdown
19
-
20
- "Modern-DI"
21
- ==
22
-
23
- | Project | Badges |
24
- |-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
25
- | common | [![MyPy Strict](https://img.shields.io/badge/mypy-strict-blue)](https://mypy.readthedocs.io/en/stable/getting_started.html#strict-mode-and-configuration) [![GitHub stars](https://img.shields.io/github/stars/modern-python/modern-di)](https://github.com/modern-python/modern-di/stargazers) |
26
- | modern-di | [![Supported versions](https://img.shields.io/pypi/pyversions/modern-di.svg)](https://pypi.python.org/pypi/modern-di ) [![downloads](https://img.shields.io/pypi/dm/modern-di.svg)](https://pypistats.org/packages/modern-di) |
27
- | modern-di-fastapi | [![Supported versions](https://img.shields.io/pypi/pyversions/modern-di-fastapi.svg)](https://pypi.python.org/pypi/modern-di-fastapi) [![downloads](https://img.shields.io/pypi/dm/modern-di-fastapi.svg)](https://pypistats.org/packages/modern-di-fastapi) |
28
-
29
- Dependency injection framework for Python inspired by `dependency-injector` and `dishka`.
30
-
31
- It is in early development state and gives you the following:
32
- - DI framework with IOC-container and scopes.
33
- - Async and sync resolving.
34
- - Python 3.10-3.13 support.
35
- - Full coverage by types annotations (mypy in strict mode).
36
- - Overriding dependencies for tests.
37
- - Package with zero dependencies.
38
-
39
- 📚 [Documentation](https://modern-di.readthedocs.io)
modern_di-0.5.0/README.md DELETED
@@ -1,20 +0,0 @@
1
- "Modern-DI"
2
- ==
3
-
4
- | Project | Badges |
5
- |-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
6
- | common | [![MyPy Strict](https://img.shields.io/badge/mypy-strict-blue)](https://mypy.readthedocs.io/en/stable/getting_started.html#strict-mode-and-configuration) [![GitHub stars](https://img.shields.io/github/stars/modern-python/modern-di)](https://github.com/modern-python/modern-di/stargazers) |
7
- | modern-di | [![Supported versions](https://img.shields.io/pypi/pyversions/modern-di.svg)](https://pypi.python.org/pypi/modern-di ) [![downloads](https://img.shields.io/pypi/dm/modern-di.svg)](https://pypistats.org/packages/modern-di) |
8
- | modern-di-fastapi | [![Supported versions](https://img.shields.io/pypi/pyversions/modern-di-fastapi.svg)](https://pypi.python.org/pypi/modern-di-fastapi) [![downloads](https://img.shields.io/pypi/dm/modern-di-fastapi.svg)](https://pypistats.org/packages/modern-di-fastapi) |
9
-
10
- Dependency injection framework for Python inspired by `dependency-injector` and `dishka`.
11
-
12
- It is in early development state and gives you the following:
13
- - DI framework with IOC-container and scopes.
14
- - Async and sync resolving.
15
- - Python 3.10-3.13 support.
16
- - Full coverage by types annotations (mypy in strict mode).
17
- - Overriding dependencies for tests.
18
- - Package with zero dependencies.
19
-
20
- 📚 [Documentation](https://modern-di.readthedocs.io)
@@ -1,34 +0,0 @@
1
- # Configuration file for the Sphinx documentation builder.
2
-
3
- # -- Project information
4
- project = "modern-di"
5
- copyright = "2024, Modern Python"
6
- author = "Modern Python Community"
7
-
8
- release = ""
9
- version = ""
10
-
11
- # -- General configuration
12
- extensions = [
13
- "sphinx_copybutton",
14
- "sphinx.ext.duration",
15
- "sphinx.ext.doctest",
16
- "sphinx.ext.autodoc",
17
- "sphinx.ext.autosummary",
18
- "sphinx.ext.intersphinx",
19
- "myst_parser",
20
- ]
21
-
22
- intersphinx_mapping = {
23
- "python": ("https://docs.python.org/3/", None),
24
- "sphinx": ("https://www.sphinx-doc.org/en/master/", None),
25
- }
26
- intersphinx_disabled_domains = ["std"]
27
-
28
- templates_path = ["_templates"]
29
-
30
- # -- Options for HTML output
31
- html_theme = "sphinx_rtd_theme"
32
-
33
- # -- Options for EPUB output
34
- epub_show_urls = "footnote"
@@ -1,19 +0,0 @@
1
- # Contributing
2
- This is an opensource project, and we are opened to new contributors.
3
-
4
- ## Getting started
5
- 1. Make sure that you have [uv](https://docs.astral.sh/uv/) and [just](https://just.systems/) installed.
6
- 2. Clone project:
7
- ```
8
- git@github.com:modern-python/modern-di.git
9
- cd modern-di
10
- ```
11
- 3. Install dependencies running `just install`
12
-
13
- ## Running linters
14
- `Ruff` and `mypy` are used for static analysis.
15
-
16
- Run all checks by command `just lint`
17
-
18
- ## Running tests
19
- Run all tests by command `just test`
@@ -1,25 +0,0 @@
1
- # Development Notes
2
- ## Base parts
3
- ### Scope
4
- - any int enum, starting from 1 with step 1
5
-
6
- ### Container
7
- - all states live in containers:
8
- - resolved dependencies
9
- - context stacks for resources
10
- - overrides
11
-
12
- ### Providers
13
- - completely stateless
14
- - if dependency is already saved or overridden in `Container`, returns it
15
- - otherwise build dependency and save it to `Container`
16
- - can have dependencies only the same or lower scope, check in init
17
-
18
- ### Graph
19
- - Cannot be instantiated
20
- - Contains graph of `Providers`
21
- - Can initialize its resources and factories to container
22
-
23
- ### Questions
24
- 1. Thread-safety
25
- 2. Configuration without global object
@@ -1,11 +0,0 @@
1
- ```{include} ../README.md
2
- ```
3
-
4
- ```{eval-rst}
5
- .. toctree::
6
- :maxdepth: 1
7
- :caption: For developers
8
-
9
- dev/development-notes
10
- dev/contributing
11
- ```
@@ -1,4 +0,0 @@
1
- sphinx==7.*
2
- sphinx-rtd-theme==2.*
3
- myst-parser
4
- sphinx-copybutton
@@ -1,18 +0,0 @@
1
- default: install lint test
2
-
3
- install:
4
- uv lock --upgrade
5
- uv sync --all-extras --frozen
6
-
7
- lint:
8
- uv run ruff format .
9
- uv run ruff check . --fix
10
- uv run mypy .
11
-
12
- lint-ci:
13
- uv run ruff format . --check
14
- uv run ruff check . --no-fix
15
- uv run mypy .
16
-
17
- test *args:
18
- uv run pytest {{ args }}
@@ -1,6 +0,0 @@
1
- "Modern-DI-FastAPI"
2
- ==
3
-
4
- Integration of [Modern-DI](https://github.com/modern-python/modern-di) to FastAPI
5
-
6
- 📚 [Documentation](https://modern-di.readthedocs.io)
@@ -1,9 +0,0 @@
1
- from modern_di_fastapi.main import Provide, build_request_container, fetch_di_container, setup_di
2
-
3
-
4
- __all__ = [
5
- "Provide",
6
- "build_request_container",
7
- "fetch_di_container",
8
- "setup_di",
9
- ]