hdmi 0.2.0__py3-none-any.whl → 0.2.2__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.
hdmi/__init__.py
CHANGED
|
@@ -7,6 +7,8 @@ A lightweight dependency injection framework with:
|
|
|
7
7
|
- Early error detection
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
|
+
__version__ = "0.2.2"
|
|
11
|
+
|
|
10
12
|
from hdmi.builders import ContainerBuilder
|
|
11
13
|
from hdmi.containers import Container, ScopedContainer
|
|
12
14
|
from hdmi.types import IContainer, ServiceDefinition
|
|
@@ -18,12 +20,12 @@ from hdmi.exceptions import (
|
|
|
18
20
|
)
|
|
19
21
|
|
|
20
22
|
__all__ = [
|
|
23
|
+
"__version__",
|
|
21
24
|
"CircularDependencyError",
|
|
22
25
|
"Container",
|
|
23
26
|
"ContainerBuilder",
|
|
24
27
|
"HDMIError",
|
|
25
28
|
"IContainer",
|
|
26
|
-
"IContainer",
|
|
27
29
|
"ScopeViolationError",
|
|
28
30
|
"ScopedContainer",
|
|
29
31
|
"ServiceDefinition",
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hdmi
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: A dependency injection framework for Python with dynamic late-binding resolution
|
|
5
|
+
Project-URL: Homepage, https://github.com/msqd/hdmi
|
|
6
|
+
Project-URL: Documentation, https://hdmi.readthedocs.io/
|
|
7
|
+
Project-URL: Repository, https://github.com/msqd/hdmi
|
|
8
|
+
Project-URL: Issues, https://github.com/msqd/hdmi/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/msqd/hdmi/blob/main/CHANGELOG.md
|
|
10
|
+
Author-email: Romain Dorgueil <romain@makersquad.fr>
|
|
11
|
+
License: MIT License
|
|
12
|
+
|
|
13
|
+
Copyright (c) 2025 Romain Dorgueil
|
|
14
|
+
|
|
15
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
in the Software without restriction, including without limitation the rights
|
|
18
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
furnished to do so, subject to the following conditions:
|
|
21
|
+
|
|
22
|
+
The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
copies or substantial portions of the Software.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
SOFTWARE.
|
|
32
|
+
License-File: LICENSE
|
|
33
|
+
Requires-Python: >=3.13
|
|
34
|
+
Requires-Dist: anyio>=4.0.0
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: basedpyright>=1.21.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: furo>=2024.0.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: hatch>=1.16.2; extra == 'dev'
|
|
39
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
|
|
40
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
41
|
+
Requires-Dist: ruff>=0.8.0; extra == 'dev'
|
|
42
|
+
Requires-Dist: sphinx-autobuild>=2024.0.0; extra == 'dev'
|
|
43
|
+
Requires-Dist: sphinx>=8.0.0; extra == 'dev'
|
|
44
|
+
Requires-Dist: sphinxcontrib-mermaid>=1.0.0; extra == 'dev'
|
|
45
|
+
Requires-Dist: twine>=6.0.0; extra == 'dev'
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
47
|
+
|
|
48
|
+
# hdmi
|
|
49
|
+
|
|
50
|
+
**A lightweight dependency injection framework for Python 3.13+ with type-driven discovery and scope validation.**
|
|
51
|
+
|
|
52
|
+
[](https://pypi.python.org/pypi/hdmi)
|
|
53
|
+
[](https://pypi.python.org/pypi/hdmi)
|
|
54
|
+
[](https://github.com/msqd/hdmi/actions/workflows/cicd.yml)
|
|
55
|
+
[](https://hdmi.readthedocs.io/)
|
|
56
|
+
[](LICENSE)
|
|
57
|
+
|
|
58
|
+
> **Warning: Pre-Alpha Software**
|
|
59
|
+
>
|
|
60
|
+
> hdmi is experimental software in active development. Breaking changes may occur until version 1.0.
|
|
61
|
+
|
|
62
|
+
**Documentation:** [Full Docs](https://hdmi.readthedocs.io/) | [Getting Started](https://hdmi.readthedocs.io/en/latest/tutorials/) | [API Reference](https://hdmi.readthedocs.io/en/latest/reference/)
|
|
63
|
+
|
|
64
|
+
## Features
|
|
65
|
+
|
|
66
|
+
- **Type-driven dependency discovery** — Uses Python's standard type annotations, no decorators needed
|
|
67
|
+
- **Scope-aware validation** — Prevents lifetime bugs at container build time
|
|
68
|
+
- **Lazy instantiation** — Services created just-in-time when first resolved
|
|
69
|
+
- **Two-phase architecture** — Configuration separated from runtime for immutable, validated graphs
|
|
70
|
+
|
|
71
|
+
## Quick Start
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install hdmi
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
import asyncio
|
|
79
|
+
from hdmi import ContainerBuilder
|
|
80
|
+
|
|
81
|
+
class DatabaseConnection:
|
|
82
|
+
def __init__(self):
|
|
83
|
+
self.connected = True
|
|
84
|
+
|
|
85
|
+
class UserRepository:
|
|
86
|
+
def __init__(self, db: DatabaseConnection):
|
|
87
|
+
self.db = db
|
|
88
|
+
|
|
89
|
+
class UserService:
|
|
90
|
+
def __init__(self, repo: UserRepository):
|
|
91
|
+
self.repo = repo
|
|
92
|
+
|
|
93
|
+
async def main():
|
|
94
|
+
builder = ContainerBuilder()
|
|
95
|
+
builder.register(DatabaseConnection)
|
|
96
|
+
builder.register(UserRepository)
|
|
97
|
+
builder.register(UserService)
|
|
98
|
+
|
|
99
|
+
container = builder.build() # Validates the dependency graph
|
|
100
|
+
user_service = await container.get(UserService) # Auto-wired!
|
|
101
|
+
|
|
102
|
+
asyncio.run(main())
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
For scoped services (per-request lifecycles), transient services, and scope validation rules, see the [documentation](https://hdmi.readthedocs.io/).
|
|
106
|
+
|
|
107
|
+
## Development
|
|
108
|
+
|
|
109
|
+
This project follows strict TDD methodology. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
make test # Run all tests
|
|
113
|
+
make docs # Build documentation
|
|
114
|
+
make help # Show all available commands
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
|
|
119
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
hdmi/__init__.py,sha256=
|
|
1
|
+
hdmi/__init__.py,sha256=zK867wD6DvDWZ2Bn4_NnGg1x1teQSZj6M2PsHvf3XDQ,772
|
|
2
|
+
hdmi/exceptions.py,sha256=lAaqSapQHzxuNXFJDuoFtAyDZYLIEAqdMGEp5xugmW8,1293
|
|
3
|
+
hdmi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
4
|
hdmi/builders/__init__.py,sha256=uN2EzCY9iFzmcxWrqikw5WDFvr_HuD2PxxYV3C43eKs,293
|
|
3
5
|
hdmi/builders/default.py,sha256=Oyiz23IZs0Ks1rLYDZw2D6Sl-pQVxkJpcTwThIu7qHQ,10140
|
|
4
6
|
hdmi/containers/__init__.py,sha256=TD8ReZks3E8CRaThWUzbZmZ4TleSmfMok_5njgNmyew,429
|
|
5
7
|
hdmi/containers/default.py,sha256=jGbOU7a11p2NkWVja6tgBPb_Ngd3DOV-TP0GzhSs7Ds,9782
|
|
6
8
|
hdmi/containers/scoped.py,sha256=c8OlWzQ2oiUxB1fQoB3kcSrGBX8pOw7l_Cg8QfaWzto,4415
|
|
7
|
-
hdmi/exceptions.py,sha256=lAaqSapQHzxuNXFJDuoFtAyDZYLIEAqdMGEp5xugmW8,1293
|
|
8
|
-
hdmi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
hdmi/types/__init__.py,sha256=uD9C8RExERfag1oq1JfiiHc88N54qvg4Lw6idV7pvMA,136
|
|
10
10
|
hdmi/types/containers.py,sha256=pdEdu1QynRUDYhYz7h5EyGpB0H2FD8eCP0dXTKaLu5c,906
|
|
11
11
|
hdmi/types/definitions.py,sha256=gqyhBneTex1efrAdBzn7R3bBU8YrOtoZE15cdmQFMTE,1802
|
|
12
12
|
hdmi/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
hdmi/utils/typing.py,sha256=1JdUYZoE0SdX1jci0iGQLJkvBYodImoCQV8S_JcJvyw,1384
|
|
14
|
-
hdmi-0.2.
|
|
15
|
-
hdmi-0.2.
|
|
16
|
-
hdmi-0.2.
|
|
14
|
+
hdmi-0.2.2.dist-info/METADATA,sha256=EZ5JkvquUcb8xJmLq2DAtnwkBDDGdxbnvVzz2BDrnqY,4852
|
|
15
|
+
hdmi-0.2.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
16
|
+
hdmi-0.2.2.dist-info/licenses/LICENSE,sha256=quAaDhvG1hdVv2ldCegF0EM_dZGLLmv9NT9RPIcMCmM,1072
|
|
17
|
+
hdmi-0.2.2.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Romain Dorgueil
|
|
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.
|
hdmi-0.2.0.dist-info/METADATA
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: hdmi
|
|
3
|
-
Version: 0.2.0
|
|
4
|
-
Summary: A dependency injection framework for Python with dynamic late-binding resolution
|
|
5
|
-
Author: Romain Dorgueil
|
|
6
|
-
Author-email: Romain Dorgueil <romain@makersquad.fr>
|
|
7
|
-
License: MIT License
|
|
8
|
-
|
|
9
|
-
Copyright (c) 2025 Romain Dorgueil
|
|
10
|
-
|
|
11
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
-
in the Software without restriction, including without limitation the rights
|
|
14
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
-
furnished to do so, subject to the following conditions:
|
|
17
|
-
|
|
18
|
-
The above copyright notice and this permission notice shall be included in all
|
|
19
|
-
copies or substantial portions of the Software.
|
|
20
|
-
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
-
SOFTWARE.
|
|
28
|
-
Requires-Dist: anyio>=4.0.0
|
|
29
|
-
Requires-Dist: pytest>=8.0.0 ; extra == 'dev'
|
|
30
|
-
Requires-Dist: pytest-cov>=4.1.0 ; extra == 'dev'
|
|
31
|
-
Requires-Dist: ruff>=0.8.0 ; extra == 'dev'
|
|
32
|
-
Requires-Dist: basedpyright>=1.21.0 ; extra == 'dev'
|
|
33
|
-
Requires-Dist: sphinx>=8.0.0 ; extra == 'dev'
|
|
34
|
-
Requires-Dist: sphinx-autobuild>=2024.0.0 ; extra == 'dev'
|
|
35
|
-
Requires-Dist: furo>=2024.0.0 ; extra == 'dev'
|
|
36
|
-
Requires-Dist: sphinxcontrib-mermaid>=1.0.0 ; extra == 'dev'
|
|
37
|
-
Requires-Dist: twine>=6.0.0 ; extra == 'dev'
|
|
38
|
-
Requires-Python: >=3.13
|
|
39
|
-
Provides-Extra: dev
|
|
40
|
-
Description-Content-Type: text/markdown
|
|
41
|
-
|
|
42
|
-
# hdmi - Dependency Management Interface
|
|
43
|
-
|
|
44
|
-
> **Warning: Pre-Alpha Software**
|
|
45
|
-
>
|
|
46
|
-
> hdmi is experimental software in active development. Breaking changes may occur
|
|
47
|
-
> until version 1.0. Use with care in production environments.
|
|
48
|
-
|
|
49
|
-
A lightweight dependency injection framework for Python 3.13+ with:
|
|
50
|
-
|
|
51
|
-
- **Type-driven dependency discovery** - Uses Python's standard type annotations
|
|
52
|
-
- **Scope-aware validation** - Prevents lifetime bugs at build time
|
|
53
|
-
- **Lazy instantiation** - Services created just-in-time
|
|
54
|
-
- **Early error detection** - Configuration errors caught at build time
|
|
55
|
-
|
|
56
|
-
## Quick Example
|
|
57
|
-
|
|
58
|
-
### Simple Example (Singleton Services)
|
|
59
|
-
|
|
60
|
-
```python
|
|
61
|
-
import asyncio
|
|
62
|
-
from hdmi import ContainerBuilder
|
|
63
|
-
|
|
64
|
-
# Define your services
|
|
65
|
-
class DatabaseConnection:
|
|
66
|
-
def __init__(self):
|
|
67
|
-
self.connected = True
|
|
68
|
-
|
|
69
|
-
class UserRepository:
|
|
70
|
-
def __init__(self, db: DatabaseConnection):
|
|
71
|
-
self.db = db
|
|
72
|
-
|
|
73
|
-
class UserService:
|
|
74
|
-
def __init__(self, repo: UserRepository):
|
|
75
|
-
self.repo = repo
|
|
76
|
-
|
|
77
|
-
async def main():
|
|
78
|
-
# Configure the container (all singletons by default)
|
|
79
|
-
builder = ContainerBuilder()
|
|
80
|
-
builder.register(DatabaseConnection)
|
|
81
|
-
builder.register(UserRepository)
|
|
82
|
-
builder.register(UserService)
|
|
83
|
-
|
|
84
|
-
# Build validates the dependency graph
|
|
85
|
-
container = builder.build()
|
|
86
|
-
|
|
87
|
-
# Resolve services lazily - dependencies are auto-wired!
|
|
88
|
-
user_service = await container.get(UserService)
|
|
89
|
-
|
|
90
|
-
asyncio.run(main())
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### Using Scoped Services
|
|
94
|
-
|
|
95
|
-
```python
|
|
96
|
-
import asyncio
|
|
97
|
-
from hdmi import ContainerBuilder
|
|
98
|
-
|
|
99
|
-
async def main():
|
|
100
|
-
# For request-scoped services (e.g., web requests)
|
|
101
|
-
builder = ContainerBuilder()
|
|
102
|
-
builder.register(DatabaseConnection) # singleton (default)
|
|
103
|
-
builder.register(UserRepository, scoped=True) # One per request
|
|
104
|
-
builder.register(UserService, transient=True) # New each time
|
|
105
|
-
|
|
106
|
-
container = builder.build()
|
|
107
|
-
|
|
108
|
-
# Scoped services must be resolved within a scope context
|
|
109
|
-
async with container.scope() as scoped:
|
|
110
|
-
user_service = await scoped.get(UserService)
|
|
111
|
-
# All scoped dependencies share the same instance within this scope
|
|
112
|
-
|
|
113
|
-
asyncio.run(main())
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
## Key Features
|
|
117
|
-
|
|
118
|
-
### Two-Phase Architecture
|
|
119
|
-
|
|
120
|
-
1. **ContainerBuilder** (Configuration): Register services and define scopes
|
|
121
|
-
2. **Container** (Runtime): Validated, immutable graph for lazy resolution
|
|
122
|
-
|
|
123
|
-
### Scope Safety
|
|
124
|
-
|
|
125
|
-
Services have four lifecycles that are validated at build time:
|
|
126
|
-
|
|
127
|
-
- **Singleton** (default): One instance per container
|
|
128
|
-
- **Scoped**: One instance per scope (e.g., per request)
|
|
129
|
-
- **Transient**: New instance every time
|
|
130
|
-
- **Scoped Transient**: New instance every time, requires scope
|
|
131
|
-
|
|
132
|
-
**Validation Rules (Simplified):**
|
|
133
|
-
The only invalid dependency is when a non-scoped service (singleton or transient) depends on a scoped service.
|
|
134
|
-
|
|
135
|
-
```python
|
|
136
|
-
# Valid: Scoped -> Singleton
|
|
137
|
-
builder = ContainerBuilder()
|
|
138
|
-
builder.register(DatabaseConnection) # singleton (default)
|
|
139
|
-
builder.register(UserRepository, scoped=True)
|
|
140
|
-
|
|
141
|
-
# Invalid: Singleton -> Scoped (raises ScopeViolationError)
|
|
142
|
-
builder = ContainerBuilder()
|
|
143
|
-
builder.register(RequestHandler, scoped=True)
|
|
144
|
-
builder.register(SingletonService) # singleton depends on scoped!
|
|
145
|
-
container = builder.build() # ScopeViolationError!
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### Type-Driven Dependencies
|
|
149
|
-
|
|
150
|
-
Dependencies are automatically discovered from type annotations:
|
|
151
|
-
|
|
152
|
-
```python
|
|
153
|
-
class ServiceA:
|
|
154
|
-
def __init__(self, dep: DependencyType):
|
|
155
|
-
self.dep = dep
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
No decorators or manual wiring required!
|
|
159
|
-
|
|
160
|
-
## Installation
|
|
161
|
-
|
|
162
|
-
```bash
|
|
163
|
-
pip install hdmi # Coming soon
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
## Development
|
|
167
|
-
|
|
168
|
-
This project uses [uv](https://github.com/astral-sh/uv) for dependency management and follows strict TDD methodology.
|
|
169
|
-
|
|
170
|
-
```bash
|
|
171
|
-
# Run all checks (linting, type checking, tests)
|
|
172
|
-
make test
|
|
173
|
-
|
|
174
|
-
# Build documentation
|
|
175
|
-
make docs
|
|
176
|
-
|
|
177
|
-
# See all available commands
|
|
178
|
-
make help
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
## License
|
|
182
|
-
|
|
183
|
-
MIT License - see LICENSE file for details.
|