PyDIO 0.5.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.
Files changed (111) hide show
  1. pydio-0.5.0/.bumpify.toml +27 -0
  2. pydio-0.5.0/.circleci/config.yml +136 -0
  3. pydio-0.5.0/.gitignore +13 -0
  4. pydio-0.5.0/CHANGELOG.md +84 -0
  5. pydio-0.5.0/LICENSE.txt +19 -0
  6. pydio-0.5.0/PKG-INFO +137 -0
  7. pydio-0.5.0/README.md +118 -0
  8. pydio-0.5.0/docs/source/api/index.rst +20 -0
  9. pydio-0.5.0/docs/source/api/pydio/api.rst +5 -0
  10. pydio-0.5.0/docs/source/api/pydio/base.rst +4 -0
  11. pydio-0.5.0/docs/source/api/pydio/exc.rst +4 -0
  12. pydio-0.5.0/docs/source/api/pydio/injector.rst +4 -0
  13. pydio-0.5.0/docs/source/api/pydio/keys.rst +4 -0
  14. pydio-0.5.0/docs/source/api/pydio/provider.rst +4 -0
  15. pydio-0.5.0/docs/source/api/pydio/v1/api.rst +5 -0
  16. pydio-0.5.0/docs/source/api/pydio/v1/async_backends/asyncio.rst +4 -0
  17. pydio-0.5.0/docs/source/api/pydio/v1/async_backends.rst +4 -0
  18. pydio-0.5.0/docs/source/api/pydio/v1/exc.rst +4 -0
  19. pydio-0.5.0/docs/source/api/pydio/v1/helpers.rst +4 -0
  20. pydio-0.5.0/docs/source/api/pydio/v1/injectors.rst +4 -0
  21. pydio-0.5.0/docs/source/api/pydio/v1/interface.rst +4 -0
  22. pydio-0.5.0/docs/source/api/pydio/v1/providers.rst +4 -0
  23. pydio-0.5.0/docs/source/api/pydio/v1.rst +4 -0
  24. pydio-0.5.0/docs/source/changelog.rst +17 -0
  25. pydio-0.5.0/docs/source/conf.py +82 -0
  26. pydio-0.5.0/docs/source/index.rst +96 -0
  27. pydio-0.5.0/docs/source/installation.rst +28 -0
  28. pydio-0.5.0/docs/source/license.rst +16 -0
  29. pydio-0.5.0/docs/source/quickstart.rst +907 -0
  30. pydio-0.5.0/invoke.yml +3 -0
  31. pydio-0.5.0/pydio/__init__.py +13 -0
  32. pydio-0.5.0/pydio/_compat.py +13 -0
  33. pydio-0.5.0/pydio/_factories.py +129 -0
  34. pydio-0.5.0/pydio/_unbound_factories.py +77 -0
  35. pydio-0.5.0/pydio/api.py +30 -0
  36. pydio-0.5.0/pydio/base.py +208 -0
  37. pydio-0.5.0/pydio/exc.py +60 -0
  38. pydio-0.5.0/pydio/injector.py +228 -0
  39. pydio-0.5.0/pydio/keys.py +53 -0
  40. pydio-0.5.0/pydio/provider.py +148 -0
  41. pydio-0.5.0/pydio/v1/__init__.py +152 -0
  42. pydio-0.5.0/pydio/v1/_adapters.py +240 -0
  43. pydio-0.5.0/pydio/v1/_compat/__init__.py +14 -0
  44. pydio-0.5.0/pydio/v1/_compat/default.py +61 -0
  45. pydio-0.5.0/pydio/v1/_compat/py313.py +68 -0
  46. pydio-0.5.0/pydio/v1/_export_list.py +15 -0
  47. pydio-0.5.0/pydio/v1/_factories.py +146 -0
  48. pydio-0.5.0/pydio/v1/_utils.py +194 -0
  49. pydio-0.5.0/pydio/v1/api.py +20 -0
  50. pydio-0.5.0/pydio/v1/async_backends/__init__.py +13 -0
  51. pydio-0.5.0/pydio/v1/async_backends/asyncio.py +56 -0
  52. pydio-0.5.0/pydio/v1/exc.py +340 -0
  53. pydio-0.5.0/pydio/v1/helpers.py +290 -0
  54. pydio-0.5.0/pydio/v1/injectors.py +294 -0
  55. pydio-0.5.0/pydio/v1/interface.py +523 -0
  56. pydio-0.5.0/pydio/v1/providers.py +107 -0
  57. pydio-0.5.0/pyproject.toml +57 -0
  58. pydio-0.5.0/scripts/licenser/licenser.py +187 -0
  59. pydio-0.5.0/scripts/licenser/templates/license.txt +19 -0
  60. pydio-0.5.0/scripts/licenser/templates/preamble.py.txt +10 -0
  61. pydio-0.5.0/scripts/licenser/templates/preamble.rst.txt +11 -0
  62. pydio-0.5.0/scripts/tag.py +205 -0
  63. pydio-0.5.0/tasks.py +150 -0
  64. pydio-0.5.0/tests/__init__.py +10 -0
  65. pydio-0.5.0/tests/examples/__init__.py +10 -0
  66. pydio-0.5.0/tests/examples/test_database_session_management.py +146 -0
  67. pydio-0.5.0/tests/functional/__init__.py +10 -0
  68. pydio-0.5.0/tests/functional/conftest.py +20 -0
  69. pydio-0.5.0/tests/functional/test_async_generator_based_provider.py +126 -0
  70. pydio-0.5.0/tests/functional/test_basics.py +58 -0
  71. pydio-0.5.0/tests/functional/test_coroutine_based_provider.py +59 -0
  72. pydio-0.5.0/tests/functional/test_generator_based_provider.py +105 -0
  73. pydio-0.5.0/tests/functional/test_provider_grouping.py +40 -0
  74. pydio-0.5.0/tests/functional/test_provider_with_env.py +75 -0
  75. pydio-0.5.0/tests/functional/test_scoped_injector.py +155 -0
  76. pydio-0.5.0/tests/functional/test_using_multiple_threads.py +47 -0
  77. pydio-0.5.0/tests/functional/test_using_variant.py +48 -0
  78. pydio-0.5.0/tests/stubs.py +34 -0
  79. pydio-0.5.0/tests/unit/__init__.py +10 -0
  80. pydio-0.5.0/tests/unit/test_factories.py +137 -0
  81. pydio-0.5.0/tests/unit/test_injector.py +78 -0
  82. pydio-0.5.0/tests/unit/test_keys.py +25 -0
  83. pydio-0.5.0/tests/unit/test_provider.py +61 -0
  84. pydio-0.5.0/tests/v1/__init__.py +0 -0
  85. pydio-0.5.0/tests/v1/conftest.py +10 -0
  86. pydio-0.5.0/tests/v1/functional/__init__.py +0 -0
  87. pydio-0.5.0/tests/v1/functional/conftest.py +6 -0
  88. pydio-0.5.0/tests/v1/functional/test_async_dependency_resolving.py +68 -0
  89. pydio-0.5.0/tests/v1/functional/test_async_error_handling.py +133 -0
  90. pydio-0.5.0/tests/v1/functional/test_dependency_resolving.py +68 -0
  91. pydio-0.5.0/tests/v1/functional/test_error_handling.py +133 -0
  92. pydio-0.5.0/tests/v1/functional/test_multitask_safety.py +31 -0
  93. pydio-0.5.0/tests/v1/functional/test_multithread_safety.py +33 -0
  94. pydio-0.5.0/tests/v1/functional/test_using_annotated.py +47 -0
  95. pydio-0.5.0/tests/v1/functional/test_using_multiple_environments.py +68 -0
  96. pydio-0.5.0/tests/v1/functional/test_using_multiple_providers.py +76 -0
  97. pydio-0.5.0/tests/v1/functional/test_using_scopes.py +72 -0
  98. pydio-0.5.0/tests/v1/functional/types.py +13 -0
  99. pydio-0.5.0/tests/v1/unit/__init__.py +0 -0
  100. pydio-0.5.0/tests/v1/unit/async_backends/__init__.py +0 -0
  101. pydio-0.5.0/tests/v1/unit/async_backends/test_asyncio.py +77 -0
  102. pydio-0.5.0/tests/v1/unit/conftest.py +40 -0
  103. pydio-0.5.0/tests/v1/unit/stubs.py +53 -0
  104. pydio-0.5.0/tests/v1/unit/test_adapters.py +430 -0
  105. pydio-0.5.0/tests/v1/unit/test_exc.py +215 -0
  106. pydio-0.5.0/tests/v1/unit/test_export_list.py +46 -0
  107. pydio-0.5.0/tests/v1/unit/test_factories.py +218 -0
  108. pydio-0.5.0/tests/v1/unit/test_helpers.py +170 -0
  109. pydio-0.5.0/tests/v1/unit/test_injectors.py +629 -0
  110. pydio-0.5.0/tests/v1/unit/test_providers.py +159 -0
  111. pydio-0.5.0/uv.lock +1718 -0
@@ -0,0 +1,27 @@
1
+ [vcs]
2
+ type = "git"
3
+
4
+ [semver]
5
+ version = "0.0.1"
6
+ bump_commit_message_template = "bump: {prev_version_str} -> {version_str} [skip ci]"
7
+ version_tag_name_template = "v{version_str}"
8
+
9
+ [[semver.bump_rules]]
10
+ branch = "master"
11
+ when_breaking = "minor"
12
+ when_feat = "minor"
13
+ when_fix = "patch"
14
+
15
+ [[semver.version_files]]
16
+ path = "pyproject.toml"
17
+ prefix = "version"
18
+ encoding = "utf-8"
19
+
20
+ [[semver.version_files]]
21
+ path = "pydio/__init__.py"
22
+ prefix = "__version__"
23
+ encoding = "utf-8"
24
+
25
+ [[semver.changelog_files]]
26
+ path = "CHANGELOG.md"
27
+ encoding = "utf-8"
@@ -0,0 +1,136 @@
1
+ version: 2.1
2
+
3
+ commands:
4
+ install-deps:
5
+ parameters:
6
+ ver_major:
7
+ type: integer
8
+ ver_minor:
9
+ type: integer
10
+ steps:
11
+ - restore_cache:
12
+ name: restore dependency cache
13
+ keys:
14
+ - py<<parameters.ver_major>><<parameters.ver_minor>>-{{ checksum "uv.lock" }}
15
+ - run: uv python pin <<parameters.ver_major>>.<<parameters.ver_minor>>
16
+ - run: uv sync
17
+ - save_cache:
18
+ name: save dependency cache
19
+ key: py<<parameters.ver_major>><<parameters.ver_minor>>-{{ checksum "uv.lock" }}
20
+ paths:
21
+ - .venv
22
+ configure-git:
23
+ steps:
24
+ - run: git config user.name "CircleCI"
25
+ - run: git config user.email "noreply@circleci.com"
26
+ push-to-git:
27
+ steps:
28
+ - run: git push --set-upstream origin $CIRCLE_BRANCH
29
+ - run: git push --tags
30
+ publish-coverage:
31
+ steps:
32
+ - run: uv run inv check-coverage -f0
33
+ - run: curl -Os https://uploader.codecov.io/latest/linux/codecov
34
+ - run: chmod +x codecov
35
+ - run: ./codecov
36
+
37
+ jobs:
38
+ test:
39
+ docker:
40
+ - image: cimg/python:<<parameters.ver_major>>.<<parameters.ver_minor>>
41
+ parameters:
42
+ ver_minor:
43
+ type: integer
44
+ ver_major:
45
+ type: integer
46
+ steps:
47
+ - checkout
48
+ - install-deps:
49
+ ver_major: <<parameters.ver_major>>
50
+ ver_minor: <<parameters.ver_minor>>
51
+ - run: uv run inv check
52
+ publish-coverage:
53
+ docker:
54
+ - image: cimg/python:3.9
55
+ steps:
56
+ - checkout
57
+ - configure-git
58
+ - install-deps:
59
+ ver_major: 3
60
+ ver_minor: 9
61
+ - publish-coverage
62
+ tag:
63
+ docker:
64
+ - image: cimg/python:3.9
65
+ steps:
66
+ - checkout
67
+ - configure-git
68
+ - install-deps:
69
+ ver_major: 3
70
+ ver_minor: 9
71
+ - run: uv tool install --python 3.9 bumpify
72
+ - run: bumpify --dry-run bump
73
+ - run: bumpify bump
74
+ - push-to-git
75
+ deploy:
76
+ docker:
77
+ - image: cimg/python:3.9
78
+ steps:
79
+ - checkout
80
+ - install-deps:
81
+ ver_major: 3
82
+ ver_minor: 9
83
+ - run: uv build
84
+ - run: uv publish --token $PYPI_TOKEN --dry-run
85
+ - run: uv publish --token $PYPI_TOKEN
86
+
87
+ workflows:
88
+ test:
89
+ jobs:
90
+ - test:
91
+ name: "test-py39"
92
+ ver_major: 3
93
+ ver_minor: 9
94
+ - test:
95
+ name: "test-py310"
96
+ ver_major: 3
97
+ ver_minor: 10
98
+ - test:
99
+ name: "test-py311"
100
+ ver_major: 3
101
+ ver_minor: 11
102
+ - test:
103
+ name: "test-py312"
104
+ ver_major: 3
105
+ ver_minor: 12
106
+ - test:
107
+ name: "test-py313"
108
+ ver_major: 3
109
+ ver_minor: 13
110
+ - test:
111
+ name: "test-py314"
112
+ ver_major: 3
113
+ ver_minor: 14
114
+ - publish-coverage:
115
+ filters:
116
+ branches:
117
+ only: master
118
+ - tag:
119
+ requires:
120
+ - test-py39
121
+ - test-py310
122
+ - test-py311
123
+ - test-py312
124
+ - test-py313
125
+ - test-py314
126
+ filters:
127
+ branches:
128
+ only: master
129
+ tags:
130
+ ignore: /.*/
131
+ - deploy:
132
+ filters:
133
+ branches:
134
+ ignore: /.*/
135
+ tags:
136
+ only: /^v.*$/
pydio-0.5.0/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ *.pyc
2
+ __pycache__
3
+ .mypy_cache
4
+ .pytest_cache
5
+ .ruff_cache
6
+ .venv
7
+ .coverage
8
+ .python-version
9
+ .reports
10
+ *.egg-info
11
+ dist/
12
+ reports/
13
+ docs/build/
@@ -0,0 +1,84 @@
1
+ ## 0.5.0 (2026-10-20)
2
+
3
+ ### Fix
4
+
5
+ - when `OutOfScopeError` is raised from a child provider, collect it and raise summarized error
6
+ - make tests pass on Python 3.13
7
+ - fix package publishing
8
+ - add CI skipping postfix to bump commits
9
+ - detach closed scoped injector from its parent
10
+ - use `bumpify` but as a separately installed tool
11
+ - migrate `pyproject.toml` to PEP-621
12
+
13
+ ### Feat
14
+
15
+ - add support for Python 3.12 and 3.13
16
+ - add a new v1 `provides` decorator
17
+ - create a v1 `Injector` implementation with tests
18
+ - add v1 `AsyncInjector` implementation with tests
19
+ - add async recursive lock implementation for a default asyncio backend
20
+ - add `inject_annotated` and `async_inject_annotated` helpers
21
+ - normalize exception handling
22
+ - add support for Python 3.14
23
+
24
+ ## 0.4.1 (2023-05-12)
25
+
26
+ ### Fix
27
+
28
+ - properly close injector when exception thrown in teardown phase
29
+
30
+ ## 0.4.0 (2023-05-06)
31
+
32
+ ### Fix
33
+
34
+ - resolve issue #7
35
+
36
+ ### Feat
37
+
38
+ - extend API of IFactory.close for the purpose of solving issue #7
39
+ - add support for Python 3.11
40
+
41
+ ## 0.3.3 (2022-11-05)
42
+
43
+ ### Fix
44
+
45
+ - deploy task no longer requires test jobs
46
+
47
+ ## 0.3.2 (2022-11-05)
48
+
49
+ ### Fix
50
+
51
+ - fix config.yml so that the job is triggered once tag is pushed
52
+
53
+ ## 0.3.1 (2022-11-05)
54
+
55
+ ### Fix
56
+
57
+ - make Changelog chapter in Sphinx documentation work again
58
+
59
+ ## 0.3.0 (2022-11-05)
60
+
61
+ ### Feat
62
+
63
+ - remove compatibility layer for no longer supported Python 3.6
64
+
65
+ ## 0.2.1 (2022-11-05)
66
+
67
+ ### Fix
68
+
69
+ - fix various CI issues (#6)
70
+
71
+ ## 0.2.0 (2022-10-30)
72
+
73
+ ## 0.1.0 (2021-02-15)
74
+
75
+ ## 0.1.0 (2021-02-10)
76
+
77
+ ## 0.1.0 (2021-02-04)
78
+
79
+ ## 0.1.0 (2021-02-04)
80
+
81
+ ## 0.1.0 (2021-02-04)
82
+
83
+ Initial release.
84
+
@@ -0,0 +1,19 @@
1
+ Copyright (C) Maciej Wiatrzyk <maciej.wiatrzyk@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
pydio-0.5.0/PKG-INFO ADDED
@@ -0,0 +1,137 @@
1
+ Metadata-Version: 2.4
2
+ Name: PyDIO
3
+ Version: 0.5.0
4
+ Summary: Lightweight and functional dependency injection library for Python
5
+ Project-URL: Homepage, https://github.com/mwiatrzyk/pydio
6
+ Project-URL: Repository, https://github.com/mwiatrzyk/pydio
7
+ Project-URL: Documentation, https://pydio.readthedocs.io
8
+ Author-email: Maciej Wiatrzyk <maciej.wiatrzyk@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE.txt
11
+ Keywords: dependency,di,framework,injection,library,tool,toolkit
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Topic :: Software Development :: Libraries
16
+ Requires-Python: >=3.9
17
+ Requires-Dist: typing-extensions>=4.16.0
18
+ Description-Content-Type: text/markdown
19
+
20
+ ![PyPI](https://img.shields.io/pypi/v/pydio)
21
+ ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pydio)
22
+ ![PyPI - License](https://img.shields.io/pypi/l/pydio)
23
+ ![PyPI - Downloads](https://img.shields.io/pypi/dm/pydio)
24
+ [![codecov](https://codecov.io/gh/mwiatrzyk/pydio/branch/master/graph/badge.svg?token=Y6DJDSOR6M)](https://codecov.io/gh/mwiatrzyk/pydio)
25
+
26
+ # PyDIO
27
+
28
+ Lightweight and functional dependency injection library for Python.
29
+
30
+ ## Name
31
+
32
+ **PyDIO** (stylized as *PyDIO*, installable as `pydio`, pronounced
33
+ *"pie-dee-o"*) stands for **Python dependency injection library**.
34
+
35
+ ## About
36
+
37
+ PyDIO aims to be simple, yet still powerful, allowing you to feed dependencies
38
+ inside your application in a flexible way. PyDIO design is based on simple
39
+ assumption that dependency injection can be achieved using a straightforward
40
+ **key-to-function** mapping, where **key** specifies **type of object** you
41
+ want to inject and **function** is a **factory** function that creates
42
+ **instances** of that type.
43
+
44
+ In PyDIO, this is implemented using **providers** and **injectors**. You use
45
+ providers to configure your **key-to-function** mapping, and then you use
46
+ injectors to perform a **lookup** of a specific key and creation of the final
47
+ object.
48
+
49
+ Here's a simple example:
50
+
51
+ ```python
52
+ import abc
53
+
54
+ from pydio.api import Provider, Injector
55
+
56
+ provider = Provider()
57
+
58
+ @provider.provides('greet')
59
+ def make_greet():
60
+ return 'Hello, world!'
61
+
62
+ def main():
63
+ injector = Injector(provider)
64
+ greet_message = injector.inject('greet')
65
+ print(greet_message)
66
+
67
+ if __name__ == '__main__':
68
+ main()
69
+ ```
70
+
71
+ Now you can save the snippet from above as ``example.py`` file and execute
72
+ to see the output:
73
+
74
+ ```shell
75
+ $ python example.py
76
+ Hello, world!
77
+ ```
78
+
79
+ ## Key features
80
+
81
+ * Support for any hashable keys: class objects, strings, ints etc.
82
+ * Support for any type of object factories: function, coroutine, generator,
83
+ asynchronous generator.
84
+ * Automatic resource management via generator-based factories
85
+ (similar to pytest's fixtures)
86
+ * Multiple environment support: testing, development, production etc.
87
+ * Limiting created object's lifetime to user-defined scopes: global,
88
+ application, use-case etc.
89
+ * No singletons used, so there is no global state...
90
+ * ...but you still can create global injector on your own if you need it :-)
91
+
92
+ ## Installation
93
+
94
+ You can install PyDIO using one of following methods:
95
+
96
+ 1) From PyPI (for stable releases):
97
+
98
+ ```shell
99
+ $ pip install PyDIO
100
+ ```
101
+
102
+ 2) From test PyPI (for stable and development releases):
103
+
104
+ ```shell
105
+ $ pip install -i https://test.pypi.org/simple/ PyDIO
106
+ ```
107
+
108
+ 3) Directly from source code repository (for all releases):
109
+
110
+ ```shell
111
+ $ pip install git+https://gitlab.com/zef1r/PyDIO.git@[branch-or-tag]
112
+ ```
113
+
114
+ ## Documentation
115
+
116
+ You have two options available:
117
+
118
+ 1) Visit [PyDIO's ReadTheDocs](https://pydio.readthedocs.io/en/latest/) site.
119
+
120
+ 2) Take a tour around [functional tests](https://github.com/mwiatrzyk/pydio/tree/master/tests/functional).
121
+
122
+ ## Disclaimer
123
+
124
+ **PyDIO** is an independent open-source project in the Python ecosystem. It
125
+ is not affiliated with, sponsored by, or endorsed by any company, organization,
126
+ or product of the same or similar name. Any similarity in names is purely
127
+ coincidental and does not imply any association.
128
+
129
+ ## License
130
+
131
+ This project is released under the terms of the MIT license.
132
+
133
+ See [LICENSE.txt](https://github.com/mwiatrzyk/pydio/blob/master/LICENSE.txt) for more details.
134
+
135
+ ## Author
136
+
137
+ Maciej Wiatrzyk <maciej.wiatrzyk@gmail.com>
pydio-0.5.0/README.md ADDED
@@ -0,0 +1,118 @@
1
+ ![PyPI](https://img.shields.io/pypi/v/pydio)
2
+ ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pydio)
3
+ ![PyPI - License](https://img.shields.io/pypi/l/pydio)
4
+ ![PyPI - Downloads](https://img.shields.io/pypi/dm/pydio)
5
+ [![codecov](https://codecov.io/gh/mwiatrzyk/pydio/branch/master/graph/badge.svg?token=Y6DJDSOR6M)](https://codecov.io/gh/mwiatrzyk/pydio)
6
+
7
+ # PyDIO
8
+
9
+ Lightweight and functional dependency injection library for Python.
10
+
11
+ ## Name
12
+
13
+ **PyDIO** (stylized as *PyDIO*, installable as `pydio`, pronounced
14
+ *"pie-dee-o"*) stands for **Python dependency injection library**.
15
+
16
+ ## About
17
+
18
+ PyDIO aims to be simple, yet still powerful, allowing you to feed dependencies
19
+ inside your application in a flexible way. PyDIO design is based on simple
20
+ assumption that dependency injection can be achieved using a straightforward
21
+ **key-to-function** mapping, where **key** specifies **type of object** you
22
+ want to inject and **function** is a **factory** function that creates
23
+ **instances** of that type.
24
+
25
+ In PyDIO, this is implemented using **providers** and **injectors**. You use
26
+ providers to configure your **key-to-function** mapping, and then you use
27
+ injectors to perform a **lookup** of a specific key and creation of the final
28
+ object.
29
+
30
+ Here's a simple example:
31
+
32
+ ```python
33
+ import abc
34
+
35
+ from pydio.api import Provider, Injector
36
+
37
+ provider = Provider()
38
+
39
+ @provider.provides('greet')
40
+ def make_greet():
41
+ return 'Hello, world!'
42
+
43
+ def main():
44
+ injector = Injector(provider)
45
+ greet_message = injector.inject('greet')
46
+ print(greet_message)
47
+
48
+ if __name__ == '__main__':
49
+ main()
50
+ ```
51
+
52
+ Now you can save the snippet from above as ``example.py`` file and execute
53
+ to see the output:
54
+
55
+ ```shell
56
+ $ python example.py
57
+ Hello, world!
58
+ ```
59
+
60
+ ## Key features
61
+
62
+ * Support for any hashable keys: class objects, strings, ints etc.
63
+ * Support for any type of object factories: function, coroutine, generator,
64
+ asynchronous generator.
65
+ * Automatic resource management via generator-based factories
66
+ (similar to pytest's fixtures)
67
+ * Multiple environment support: testing, development, production etc.
68
+ * Limiting created object's lifetime to user-defined scopes: global,
69
+ application, use-case etc.
70
+ * No singletons used, so there is no global state...
71
+ * ...but you still can create global injector on your own if you need it :-)
72
+
73
+ ## Installation
74
+
75
+ You can install PyDIO using one of following methods:
76
+
77
+ 1) From PyPI (for stable releases):
78
+
79
+ ```shell
80
+ $ pip install PyDIO
81
+ ```
82
+
83
+ 2) From test PyPI (for stable and development releases):
84
+
85
+ ```shell
86
+ $ pip install -i https://test.pypi.org/simple/ PyDIO
87
+ ```
88
+
89
+ 3) Directly from source code repository (for all releases):
90
+
91
+ ```shell
92
+ $ pip install git+https://gitlab.com/zef1r/PyDIO.git@[branch-or-tag]
93
+ ```
94
+
95
+ ## Documentation
96
+
97
+ You have two options available:
98
+
99
+ 1) Visit [PyDIO's ReadTheDocs](https://pydio.readthedocs.io/en/latest/) site.
100
+
101
+ 2) Take a tour around [functional tests](https://github.com/mwiatrzyk/pydio/tree/master/tests/functional).
102
+
103
+ ## Disclaimer
104
+
105
+ **PyDIO** is an independent open-source project in the Python ecosystem. It
106
+ is not affiliated with, sponsored by, or endorsed by any company, organization,
107
+ or product of the same or similar name. Any similarity in names is purely
108
+ coincidental and does not imply any association.
109
+
110
+ ## License
111
+
112
+ This project is released under the terms of the MIT license.
113
+
114
+ See [LICENSE.txt](https://github.com/mwiatrzyk/pydio/blob/master/LICENSE.txt) for more details.
115
+
116
+ ## Author
117
+
118
+ Maciej Wiatrzyk <maciej.wiatrzyk@gmail.com>
@@ -0,0 +1,20 @@
1
+ API Reference
2
+ =============
3
+ .. toctree::
4
+ :maxdepth: 1
5
+
6
+ pydio/api
7
+ pydio/base
8
+ pydio/exc
9
+ pydio/injector
10
+ pydio/keys
11
+ pydio/provider
12
+ pydio/v1
13
+ pydio/v1/api
14
+ pydio/v1/async_backends
15
+ pydio/v1/async_backends/asyncio
16
+ pydio/v1/exc
17
+ pydio/v1/helpers
18
+ pydio/v1/injectors
19
+ pydio/v1/interface
20
+ pydio/v1/providers
@@ -0,0 +1,5 @@
1
+ **pydio.api**
2
+ =============
3
+ .. automodule:: pydio.api
4
+ :members:
5
+ :no-index:
@@ -0,0 +1,4 @@
1
+ **pydio.base**
2
+ ==============
3
+ .. automodule:: pydio.base
4
+ :members:
@@ -0,0 +1,4 @@
1
+ **pydio.exc**
2
+ =============
3
+ .. automodule:: pydio.exc
4
+ :members:
@@ -0,0 +1,4 @@
1
+ **pydio.injector**
2
+ ==================
3
+ .. automodule:: pydio.injector
4
+ :members:
@@ -0,0 +1,4 @@
1
+ **pydio.keys**
2
+ ==============
3
+ .. automodule:: pydio.keys
4
+ :members:
@@ -0,0 +1,4 @@
1
+ **pydio.provider**
2
+ ==================
3
+ .. automodule:: pydio.provider
4
+ :members:
@@ -0,0 +1,5 @@
1
+ **pydio.v1.api**
2
+ ================
3
+ .. automodule:: pydio.v1.api
4
+ :members:
5
+ :no-index:
@@ -0,0 +1,4 @@
1
+ **pydio.v1.async_backends.asyncio**
2
+ ===================================
3
+ .. automodule:: pydio.v1.async_backends.asyncio
4
+ :members:
@@ -0,0 +1,4 @@
1
+ **pydio.v1.async_backends**
2
+ ===========================
3
+ .. automodule:: pydio.v1.async_backends
4
+ :members:
@@ -0,0 +1,4 @@
1
+ **pydio.v1.exc**
2
+ ================
3
+ .. automodule:: pydio.v1.exc
4
+ :members:
@@ -0,0 +1,4 @@
1
+ **pydio.v1.helpers**
2
+ ====================
3
+ .. automodule:: pydio.v1.helpers
4
+ :members:
@@ -0,0 +1,4 @@
1
+ **pydio.v1.injectors**
2
+ ======================
3
+ .. automodule:: pydio.v1.injectors
4
+ :members:
@@ -0,0 +1,4 @@
1
+ **pydio.v1.interface**
2
+ ======================
3
+ .. automodule:: pydio.v1.interface
4
+ :members:
@@ -0,0 +1,4 @@
1
+ **pydio.v1.providers**
2
+ ======================
3
+ .. automodule:: pydio.v1.providers
4
+ :members:
@@ -0,0 +1,4 @@
1
+ **pydio.v1**
2
+ ============
3
+ .. automodule:: pydio.v1
4
+ :members:
@@ -0,0 +1,17 @@
1
+ .. ----------------------------------------------------------------------------
2
+ .. docs/source/changelog.rst
3
+ ..
4
+ .. Copyright (C) 2021 - 2025 Maciej Wiatrzyk <maciej.wiatrzyk@gmail.com>
5
+ ..
6
+ .. This file is part of PyDio library documentation
7
+ .. and is released under the terms of the MIT license:
8
+ .. http://opensource.org/licenses/mit-license.php.
9
+ ..
10
+ .. See LICENSE.txt for details.
11
+ .. ----------------------------------------------------------------------------
12
+
13
+ Changelog
14
+ =========
15
+
16
+ .. include:: ../../CHANGELOG.md
17
+ :parser: myst_parser.sphinx_