pico-ioc 1.1.0__py3-none-any.whl → 1.3.0__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.
- pico_ioc/__init__.py +18 -4
- pico_ioc/_state.py +30 -0
- pico_ioc/_version.py +1 -1
- pico_ioc/api.py +206 -106
- pico_ioc/builder.py +242 -0
- pico_ioc/container.py +62 -34
- pico_ioc/decorators.py +76 -18
- pico_ioc/interceptors.py +50 -0
- pico_ioc/plugins.py +17 -1
- pico_ioc/policy.py +332 -0
- pico_ioc/proxy.py +41 -1
- pico_ioc/resolver.py +52 -33
- pico_ioc/scanner.py +76 -111
- pico_ioc/utils.py +25 -0
- pico_ioc-1.3.0.dist-info/METADATA +235 -0
- pico_ioc-1.3.0.dist-info/RECORD +20 -0
- pico_ioc/typing_utils.py +0 -29
- pico_ioc-1.1.0.dist-info/METADATA +0 -166
- pico_ioc-1.1.0.dist-info/RECORD +0 -17
- {pico_ioc-1.1.0.dist-info → pico_ioc-1.3.0.dist-info}/WHEEL +0 -0
- {pico_ioc-1.1.0.dist-info → pico_ioc-1.3.0.dist-info}/licenses/LICENSE +0 -0
- {pico_ioc-1.1.0.dist-info → pico_ioc-1.3.0.dist-info}/top_level.txt +0 -0
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: pico-ioc
|
|
3
|
-
Version: 1.1.0
|
|
4
|
-
Summary: A minimalist, zero-dependency Inversion of Control (IoC) container for Python.
|
|
5
|
-
Author-email: David Perez Cabrera <dperezcabrera@gmail.com>
|
|
6
|
-
License: MIT License
|
|
7
|
-
|
|
8
|
-
Copyright (c) 2025 David Pérez Cabrera
|
|
9
|
-
|
|
10
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
-
in the Software without restriction, including without limitation the rights
|
|
13
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
-
furnished to do so, subject to the following conditions:
|
|
16
|
-
|
|
17
|
-
The above copyright notice and this permission notice shall be included in all
|
|
18
|
-
copies or substantial portions of the Software.
|
|
19
|
-
|
|
20
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
-
SOFTWARE.
|
|
27
|
-
|
|
28
|
-
Project-URL: Homepage, https://github.com/dperezcabrera/pico-ioc
|
|
29
|
-
Project-URL: Repository, https://github.com/dperezcabrera/pico-ioc
|
|
30
|
-
Project-URL: Issue Tracker, https://github.com/dperezcabrera/pico-ioc/issues
|
|
31
|
-
Keywords: ioc,di,dependency injection,inversion of control,decorator
|
|
32
|
-
Classifier: Development Status :: 4 - Beta
|
|
33
|
-
Classifier: Programming Language :: Python :: 3
|
|
34
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
35
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
36
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
37
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
38
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
39
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
40
|
-
Classifier: Operating System :: OS Independent
|
|
41
|
-
Requires-Python: >=3.8
|
|
42
|
-
Description-Content-Type: text/markdown
|
|
43
|
-
License-File: LICENSE
|
|
44
|
-
Dynamic: license-file
|
|
45
|
-
|
|
46
|
-
# 📦 Pico-IoC: A Minimalist IoC Container for Python
|
|
47
|
-
|
|
48
|
-
[](https://pypi.org/project/pico-ioc/)
|
|
49
|
-
[](https://deepwiki.com/dperezcabrera/pico-ioc)
|
|
50
|
-
[](https://opensource.org/licenses/MIT)
|
|
51
|
-

|
|
52
|
-
[](https://codecov.io/gh/dperezcabrera/pico-ioc)
|
|
53
|
-
[](https://sonarcloud.io/summary/new_code?id=dperezcabrera_pico-ioc)
|
|
54
|
-
[](https://sonarcloud.io/summary/new_code?id=dperezcabrera_pico-ioc)
|
|
55
|
-
[](https://sonarcloud.io/summary/new_code?id=dperezcabrera_pico-ioc)
|
|
56
|
-
|
|
57
|
-
**pico-ioc** is a **tiny, zero-dependency, decorator-based IoC container for Python**.
|
|
58
|
-
It helps you build loosely-coupled, testable apps without manual wiring. Inspired by the Spring ecosystem, but minimal.
|
|
59
|
-
|
|
60
|
-
> ⚠️ **Requires Python 3.10+** (uses `typing.Annotated` and `include_extras=True`).
|
|
61
|
-
|
|
62
|
-
---
|
|
63
|
-
|
|
64
|
-
## ✨ Features
|
|
65
|
-
|
|
66
|
-
- **Zero dependencies** — pure Python, framework-agnostic.
|
|
67
|
-
- **Decorator API** — `@component`, `@factory_component`, `@provides`, `@plugin`.
|
|
68
|
-
- **Fail-fast bootstrap** — eager by default; missing deps surface at startup.
|
|
69
|
-
- **Opt-in lazy** — `lazy=True` wraps with `ComponentProxy`.
|
|
70
|
-
- **Smart resolution order** — parameter name → type annotation → MRO → string.
|
|
71
|
-
- **Qualifiers & collections** — `list[Annotated[T, Q]]` filters by qualifier.
|
|
72
|
-
- **Plugins** — lifecycle hooks (`before_scan`, `after_ready`).
|
|
73
|
-
- **Public API helper** — auto-export decorated symbols in `__init__.py`.
|
|
74
|
-
- **Thread/async safe** — isolation via `ContextVar`.
|
|
75
|
-
- **Overrides for testing** — inject mocks/fakes directly via `init(overrides={...})`.
|
|
76
|
-
|
|
77
|
-
---
|
|
78
|
-
|
|
79
|
-
## 📦 Installation
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
# Requires Python 3.10+
|
|
83
|
-
pip install pico-ioc
|
|
84
|
-
````
|
|
85
|
-
|
|
86
|
-
---
|
|
87
|
-
|
|
88
|
-
## 🚀 Quick start
|
|
89
|
-
|
|
90
|
-
```python
|
|
91
|
-
from pico_ioc import component, init
|
|
92
|
-
|
|
93
|
-
@component
|
|
94
|
-
class Config:
|
|
95
|
-
url = "sqlite:///demo.db"
|
|
96
|
-
|
|
97
|
-
@component
|
|
98
|
-
class Repo:
|
|
99
|
-
def __init__(self, cfg: Config):
|
|
100
|
-
self.url = cfg.url
|
|
101
|
-
def fetch(self): return f"fetching from {self.url}"
|
|
102
|
-
|
|
103
|
-
@component
|
|
104
|
-
class Service:
|
|
105
|
-
def __init__(self, repo: Repo):
|
|
106
|
-
self.repo = repo
|
|
107
|
-
def run(self): return self.repo.fetch()
|
|
108
|
-
|
|
109
|
-
# bootstrap
|
|
110
|
-
import myapp
|
|
111
|
-
c = init(myapp)
|
|
112
|
-
svc = c.get(Service)
|
|
113
|
-
print(svc.run())
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
**Output:**
|
|
117
|
-
|
|
118
|
-
```
|
|
119
|
-
fetching from sqlite:///demo.db
|
|
120
|
-
```
|
|
121
|
-
---
|
|
122
|
-
|
|
123
|
-
### Quick overrides for testing
|
|
124
|
-
|
|
125
|
-
```python
|
|
126
|
-
from pico_ioc import init
|
|
127
|
-
import myapp
|
|
128
|
-
|
|
129
|
-
fake = {"repo": "fake-data"}
|
|
130
|
-
c = init(myapp, overrides={
|
|
131
|
-
"fast_model": fake, # constant instance
|
|
132
|
-
"user_service": lambda: {"id": 1}, # provider
|
|
133
|
-
})
|
|
134
|
-
assert c.get("fast_model") == {"repo": "fake-data"}
|
|
135
|
-
```
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
## 📖 Documentation
|
|
139
|
-
|
|
140
|
-
* [Overview](.llm/OVERVIEW.md) — mission & concepts
|
|
141
|
-
* [Guide](.llm/GUIDE.md) — practical usage & recipes
|
|
142
|
-
* [Architecture](.llm/ARCHITECTURE.md) — internals & design rationale
|
|
143
|
-
|
|
144
|
-
---
|
|
145
|
-
|
|
146
|
-
## 🧪 Development
|
|
147
|
-
|
|
148
|
-
```bash
|
|
149
|
-
pip install tox
|
|
150
|
-
tox
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
---
|
|
154
|
-
|
|
155
|
-
## 📜 Changelog
|
|
156
|
-
|
|
157
|
-
See [CHANGELOG.md](./CHANGELOG.md) for version history.
|
|
158
|
-
|
|
159
|
-
---
|
|
160
|
-
|
|
161
|
-
## 📜 License
|
|
162
|
-
|
|
163
|
-
MIT — see [LICENSE](https://opensource.org/licenses/MIT)
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
pico_ioc-1.1.0.dist-info/RECORD
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
pico_ioc/__init__.py,sha256=7EyifZ02LFfhkAR6zzAaQJvByyMI2_-qNrw49gPoJkA,633
|
|
2
|
-
pico_ioc/_state.py,sha256=KHNtdPrv1s-uynfot2IsNkWotBPyORPCcM2xe9qMMPo,286
|
|
3
|
-
pico_ioc/_version.py,sha256=b6-WiVk0Li5MaV2rBnHYl104TsouINojSWKqHDas0js,22
|
|
4
|
-
pico_ioc/api.py,sha256=pInjKJ1oi8bM4N0u4T3XLFa2qmYiHpQ7omcdXFFkGmE,3928
|
|
5
|
-
pico_ioc/container.py,sha256=oyCCeiPFVx7qw51IR9_ReuccInnpYMNuYhKxOKsioYE,5193
|
|
6
|
-
pico_ioc/decorators.py,sha256=gNPxLFNEdFUFYlxILKjU76XyoPohediK0DNiv-RpK3I,1902
|
|
7
|
-
pico_ioc/plugins.py,sha256=JbI-28VLGJaik7ysXi3L-YGTGxhqwJH4W5QYuWSruDE,589
|
|
8
|
-
pico_ioc/proxy.py,sha256=-e3Z9z7Bc_2wxswwUJI_s8AfvCTps8f8RWUJ9RuEp7E,4606
|
|
9
|
-
pico_ioc/public_api.py,sha256=E3sArCoI1xxkIw7xQBvLYAWcIoVJjcq1s0kH-0qIVDE,2383
|
|
10
|
-
pico_ioc/resolver.py,sha256=PN5uq2dFEStAzzTEl0n4AEyC-k7TowqCu7-uwIDDgEk,3897
|
|
11
|
-
pico_ioc/scanner.py,sha256=-iOj_qX15IBFmOAFQlP_1rIkBfamGzdqYdvIPOvq7sY,7709
|
|
12
|
-
pico_ioc/typing_utils.py,sha256=JQ4bkR60pKxFs3f8JlEz41ruKDsWj-SmkKv3DLJriec,950
|
|
13
|
-
pico_ioc-1.1.0.dist-info/licenses/LICENSE,sha256=N1_nOvHTM6BobYnOTNXiQkroDqCEi6EzfGBv8lWtyZ0,1077
|
|
14
|
-
pico_ioc-1.1.0.dist-info/METADATA,sha256=9tZ6dAnCgwLxD2GinaNb3U0FsCTPHTmicJxk9YsFY18,5920
|
|
15
|
-
pico_ioc-1.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
16
|
-
pico_ioc-1.1.0.dist-info/top_level.txt,sha256=_7_RLu616z_dtRw16impXn4Mw8IXe2J4BeX5912m5dQ,9
|
|
17
|
-
pico_ioc-1.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|