hdmi 0.2.1__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
+ [![PyPI version](https://img.shields.io/pypi/v/hdmi.svg)](https://pypi.python.org/pypi/hdmi)
53
+ [![Python versions](https://img.shields.io/pypi/pyversions/hdmi.svg)](https://pypi.python.org/pypi/hdmi)
54
+ [![CI](https://github.com/msqd/hdmi/actions/workflows/cicd.yml/badge.svg)](https://github.com/msqd/hdmi/actions/workflows/cicd.yml)
55
+ [![Documentation](https://readthedocs.org/projects/hdmi/badge/?version=latest)](https://hdmi.readthedocs.io/)
56
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](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=bUVZmkoCG1PgkbS7XrwwXylowF56s7aS_mCA-yHDWu4,748
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.1.dist-info/WHEEL,sha256=iHtWm8nRfs0VRdCYVXocAWFW8ppjHL-uTJkAdZJKOBM,80
15
- hdmi-0.2.1.dist-info/METADATA,sha256=8Jl9RTu2ZvO9i1RT9PHSILu913By6m6TdUeUay50Tso,6154
16
- hdmi-0.2.1.dist-info/RECORD,,
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,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: uv 0.9.30
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -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.
@@ -1,188 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: hdmi
3
- Version: 0.2.1
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
- Project-URL: Homepage, https://github.com/msqd/hdmi
40
- Project-URL: Documentation, https://hdmi.readthedocs.io/
41
- Project-URL: Repository, https://github.com/msqd/hdmi
42
- Project-URL: Issues, https://github.com/msqd/hdmi/issues
43
- Project-URL: Changelog, https://github.com/msqd/hdmi/blob/main/CHANGELOG.md
44
- Provides-Extra: dev
45
- Description-Content-Type: text/markdown
46
-
47
- # hdmi - Dependency Management Interface
48
-
49
- > **Warning: Pre-Alpha Software**
50
- >
51
- > hdmi is experimental software in active development. Breaking changes may occur
52
- > until version 1.0. Use with care in production environments.
53
-
54
- A lightweight dependency injection framework for Python 3.13+ with:
55
-
56
- - **Type-driven dependency discovery** - Uses Python's standard type annotations
57
- - **Scope-aware validation** - Prevents lifetime bugs at build time
58
- - **Lazy instantiation** - Services created just-in-time
59
- - **Early error detection** - Configuration errors caught at build time
60
-
61
- ## Quick Example
62
-
63
- ### Simple Example (Singleton Services)
64
-
65
- ```python
66
- import asyncio
67
- from hdmi import ContainerBuilder
68
-
69
- # Define your services
70
- class DatabaseConnection:
71
- def __init__(self):
72
- self.connected = True
73
-
74
- class UserRepository:
75
- def __init__(self, db: DatabaseConnection):
76
- self.db = db
77
-
78
- class UserService:
79
- def __init__(self, repo: UserRepository):
80
- self.repo = repo
81
-
82
- async def main():
83
- # Configure the container (all singletons by default)
84
- builder = ContainerBuilder()
85
- builder.register(DatabaseConnection)
86
- builder.register(UserRepository)
87
- builder.register(UserService)
88
-
89
- # Build validates the dependency graph
90
- container = builder.build()
91
-
92
- # Resolve services lazily - dependencies are auto-wired!
93
- user_service = await container.get(UserService)
94
-
95
- asyncio.run(main())
96
- ```
97
-
98
- ### Using Scoped Services
99
-
100
- ```python
101
- import asyncio
102
- from hdmi import ContainerBuilder
103
-
104
- async def main():
105
- # For request-scoped services (e.g., web requests)
106
- builder = ContainerBuilder()
107
- builder.register(DatabaseConnection) # singleton (default)
108
- builder.register(UserRepository, scoped=True) # One per request
109
- builder.register(UserService, transient=True) # New each time
110
-
111
- container = builder.build()
112
-
113
- # Scoped services must be resolved within a scope context
114
- async with container.scope() as scoped:
115
- user_service = await scoped.get(UserService)
116
- # All scoped dependencies share the same instance within this scope
117
-
118
- asyncio.run(main())
119
- ```
120
-
121
- ## Key Features
122
-
123
- ### Two-Phase Architecture
124
-
125
- 1. **ContainerBuilder** (Configuration): Register services and define scopes
126
- 2. **Container** (Runtime): Validated, immutable graph for lazy resolution
127
-
128
- ### Scope Safety
129
-
130
- Services have four lifecycles that are validated at build time:
131
-
132
- - **Singleton** (default): One instance per container
133
- - **Scoped**: One instance per scope (e.g., per request)
134
- - **Transient**: New instance every time
135
- - **Scoped Transient**: New instance every time, requires scope
136
-
137
- **Validation Rules (Simplified):**
138
- The only invalid dependency is when a non-scoped service (singleton or transient) depends on a scoped service.
139
-
140
- ```python
141
- # Valid: Scoped -> Singleton
142
- builder = ContainerBuilder()
143
- builder.register(DatabaseConnection) # singleton (default)
144
- builder.register(UserRepository, scoped=True)
145
-
146
- # Invalid: Singleton -> Scoped (raises ScopeViolationError)
147
- builder = ContainerBuilder()
148
- builder.register(RequestHandler, scoped=True)
149
- builder.register(SingletonService) # singleton depends on scoped!
150
- container = builder.build() # ScopeViolationError!
151
- ```
152
-
153
- ### Type-Driven Dependencies
154
-
155
- Dependencies are automatically discovered from type annotations:
156
-
157
- ```python
158
- class ServiceA:
159
- def __init__(self, dep: DependencyType):
160
- self.dep = dep
161
- ```
162
-
163
- No decorators or manual wiring required!
164
-
165
- ## Installation
166
-
167
- ```bash
168
- pip install hdmi # Coming soon
169
- ```
170
-
171
- ## Development
172
-
173
- This project uses [uv](https://github.com/astral-sh/uv) for dependency management and follows strict TDD methodology.
174
-
175
- ```bash
176
- # Run all checks (linting, type checking, tests)
177
- make test
178
-
179
- # Build documentation
180
- make docs
181
-
182
- # See all available commands
183
- make help
184
- ```
185
-
186
- ## License
187
-
188
- MIT License - see LICENSE file for details.