pico-ioc 1.2.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 +17 -4
- pico_ioc/_state.py +30 -0
- pico_ioc/_version.py +1 -1
- pico_ioc/api.py +186 -235
- pico_ioc/builder.py +242 -0
- pico_ioc/container.py +57 -29
- pico_ioc/decorators.py +63 -8
- 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 +45 -40
- pico_ioc/scanner.py +74 -101
- pico_ioc/utils.py +25 -0
- {pico_ioc-1.2.0.dist-info → pico_ioc-1.3.0.dist-info}/METADATA +59 -16
- pico_ioc-1.3.0.dist-info/RECORD +20 -0
- pico_ioc/typing_utils.py +0 -29
- pico_ioc-1.2.0.dist-info/RECORD +0 -17
- {pico_ioc-1.2.0.dist-info → pico_ioc-1.3.0.dist-info}/WHEEL +0 -0
- {pico_ioc-1.2.0.dist-info → pico_ioc-1.3.0.dist-info}/licenses/LICENSE +0 -0
- {pico_ioc-1.2.0.dist-info → pico_ioc-1.3.0.dist-info}/top_level.txt +0 -0
pico_ioc/scanner.py
CHANGED
|
@@ -6,6 +6,7 @@ import pkgutil
|
|
|
6
6
|
from types import ModuleType
|
|
7
7
|
from typing import Any, Callable, Optional, Tuple, List, Iterable
|
|
8
8
|
|
|
9
|
+
from .plugins import run_plugin_hook
|
|
9
10
|
from .container import PicoContainer, Binder
|
|
10
11
|
from .decorators import (
|
|
11
12
|
COMPONENT_FLAG,
|
|
@@ -14,13 +15,15 @@ from .decorators import (
|
|
|
14
15
|
FACTORY_FLAG,
|
|
15
16
|
PROVIDES_KEY,
|
|
16
17
|
PROVIDES_LAZY,
|
|
17
|
-
COMPONENT_TAGS,
|
|
18
|
+
COMPONENT_TAGS,
|
|
18
19
|
PROVIDES_TAGS,
|
|
20
|
+
INTERCEPTOR_META,
|
|
19
21
|
)
|
|
20
22
|
from .proxy import ComponentProxy
|
|
21
23
|
from .resolver import Resolver
|
|
22
24
|
from .plugins import PicoPlugin
|
|
23
25
|
from . import _state
|
|
26
|
+
from .utils import _provider_from_class, _provider_from_callable
|
|
24
27
|
|
|
25
28
|
|
|
26
29
|
def scan_and_configure(
|
|
@@ -29,15 +32,15 @@ def scan_and_configure(
|
|
|
29
32
|
*,
|
|
30
33
|
exclude: Optional[Callable[[str], bool]] = None,
|
|
31
34
|
plugins: Tuple[PicoPlugin, ...] = (),
|
|
32
|
-
) ->
|
|
35
|
+
) -> tuple[int, int, list[tuple[Any, dict]]]:
|
|
33
36
|
"""
|
|
34
|
-
Scan a package,
|
|
37
|
+
Scan a package, bind components/factories, and collect interceptor declarations.
|
|
38
|
+
Returns: (component_count, factory_count, interceptor_decls)
|
|
35
39
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
plugins: Optional lifecycle plugins that receive scan/bind events.
|
|
40
|
+
interceptor_decls contains entries of the form:
|
|
41
|
+
- (cls, meta) for class-level @interceptor on a class
|
|
42
|
+
- (fn, meta) for module-level function with @interceptor
|
|
43
|
+
- ((owner_cls, fn), meta) for methods on a class decorated with @interceptor
|
|
41
44
|
"""
|
|
42
45
|
package = _as_module(package_or_name)
|
|
43
46
|
logging.info("Scanning in '%s'...", getattr(package, "__name__", repr(package)))
|
|
@@ -45,34 +48,26 @@ def scan_and_configure(
|
|
|
45
48
|
binder = Binder(container)
|
|
46
49
|
resolver = Resolver(container)
|
|
47
50
|
|
|
48
|
-
|
|
51
|
+
run_plugin_hook(plugins, "before_scan", package, binder)
|
|
49
52
|
|
|
50
|
-
comp_classes, factory_classes =
|
|
53
|
+
comp_classes, factory_classes, interceptor_decls = _collect_decorated(
|
|
51
54
|
package=package,
|
|
52
55
|
exclude=exclude,
|
|
53
56
|
plugins=plugins,
|
|
54
57
|
binder=binder,
|
|
55
58
|
)
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
run_plugin_hook(plugins, "after_scan", package, binder)
|
|
58
61
|
|
|
59
|
-
_register_component_classes(
|
|
60
|
-
|
|
61
|
-
container=container,
|
|
62
|
-
resolver=resolver,
|
|
63
|
-
)
|
|
62
|
+
_register_component_classes(classes=comp_classes, container=container, resolver=resolver)
|
|
63
|
+
_register_factory_classes(factory_classes=factory_classes, container=container, resolver=resolver)
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
factory_classes=factory_classes,
|
|
67
|
-
container=container,
|
|
68
|
-
resolver=resolver,
|
|
69
|
-
)
|
|
65
|
+
return len(comp_classes), len(factory_classes), interceptor_decls
|
|
70
66
|
|
|
71
67
|
|
|
72
|
-
# -------------------- Helpers
|
|
68
|
+
# -------------------- Helpers --------------------
|
|
73
69
|
|
|
74
70
|
def _as_module(package_or_name: Any) -> ModuleType:
|
|
75
|
-
"""Return a module from either a module object or an importable string name."""
|
|
76
71
|
if isinstance(package_or_name, str):
|
|
77
72
|
return importlib.import_module(package_or_name)
|
|
78
73
|
if hasattr(package_or_name, "__spec__"):
|
|
@@ -80,85 +75,76 @@ def _as_module(package_or_name: Any) -> ModuleType:
|
|
|
80
75
|
raise TypeError("package_or_name must be a module or importable package name (str).")
|
|
81
76
|
|
|
82
77
|
|
|
83
|
-
def
|
|
84
|
-
|
|
85
|
-
hook_name: str,
|
|
86
|
-
*args,
|
|
87
|
-
**kwargs,
|
|
88
|
-
) -> None:
|
|
89
|
-
"""Run a lifecycle hook across all plugins, logging (but not raising) exceptions."""
|
|
90
|
-
for pl in plugins:
|
|
91
|
-
try:
|
|
92
|
-
fn = getattr(pl, hook_name, None)
|
|
93
|
-
if fn:
|
|
94
|
-
fn(*args, **kwargs)
|
|
95
|
-
except Exception:
|
|
96
|
-
logging.exception("Plugin %s failed", hook_name)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
def _iter_package_modules(
|
|
100
|
-
package: ModuleType,
|
|
101
|
-
) -> Iterable[str]:
|
|
102
|
-
"""
|
|
103
|
-
Yield fully qualified module names under the given package.
|
|
104
|
-
|
|
105
|
-
Requires the package to have a __path__ (i.e., be a package, not a single module).
|
|
106
|
-
"""
|
|
78
|
+
def _iter_package_modules(package: ModuleType) -> Iterable[str]:
|
|
79
|
+
"""Yield fully-qualified module names under a package (recursive)."""
|
|
107
80
|
try:
|
|
108
81
|
pkg_path = package.__path__ # type: ignore[attr-defined]
|
|
109
82
|
except Exception:
|
|
110
|
-
return
|
|
111
|
-
|
|
83
|
+
return
|
|
112
84
|
prefix = package.__name__ + "."
|
|
113
85
|
for _finder, name, _is_pkg in pkgutil.walk_packages(pkg_path, prefix):
|
|
114
86
|
yield name
|
|
115
87
|
|
|
116
88
|
|
|
117
|
-
def
|
|
89
|
+
def _collect_decorated(
|
|
118
90
|
*,
|
|
119
91
|
package: ModuleType,
|
|
120
92
|
exclude: Optional[Callable[[str], bool]],
|
|
121
93
|
plugins: Tuple[PicoPlugin, ...],
|
|
122
94
|
binder: Binder,
|
|
123
|
-
) -> Tuple[List[type], List[type]]:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
95
|
+
) -> Tuple[List[type], List[type], List[tuple[Any, dict]]]:
|
|
96
|
+
comps: List[type] = []
|
|
97
|
+
facts: List[type] = []
|
|
98
|
+
interceptors: List[tuple[Any, dict]] = []
|
|
99
|
+
|
|
100
|
+
def _collect_from_class(cls: type):
|
|
101
|
+
# Class decorators
|
|
102
|
+
if getattr(cls, COMPONENT_FLAG, False):
|
|
103
|
+
comps.append(cls)
|
|
104
|
+
elif getattr(cls, FACTORY_FLAG, False):
|
|
105
|
+
facts.append(cls)
|
|
106
|
+
|
|
107
|
+
# Class-level interceptor (decorated class itself)
|
|
108
|
+
meta_class = getattr(cls, INTERCEPTOR_META, None)
|
|
109
|
+
if meta_class:
|
|
110
|
+
interceptors.append((cls, dict(meta_class)))
|
|
111
|
+
|
|
112
|
+
# Method-level interceptors
|
|
113
|
+
for _nm, fn in inspect.getmembers(cls, predicate=inspect.isfunction):
|
|
114
|
+
meta_m = getattr(fn, INTERCEPTOR_META, None)
|
|
115
|
+
if meta_m:
|
|
116
|
+
# Preserve the owner to allow proper binding (self) later
|
|
117
|
+
interceptors.append(((cls, fn), dict(meta_m)))
|
|
130
118
|
|
|
131
119
|
def _visit_module(module: ModuleType):
|
|
120
|
+
# Classes
|
|
132
121
|
for _name, obj in inspect.getmembers(module, inspect.isclass):
|
|
133
|
-
|
|
134
|
-
|
|
122
|
+
run_plugin_hook(plugins, "visit_class", module, obj, binder)
|
|
123
|
+
_collect_from_class(obj)
|
|
135
124
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
125
|
+
# Module-level functions that declare interceptors
|
|
126
|
+
for _name, fn in inspect.getmembers(module, predicate=inspect.isfunction):
|
|
127
|
+
meta = getattr(fn, INTERCEPTOR_META, None)
|
|
128
|
+
if meta:
|
|
129
|
+
interceptors.append((fn, dict(meta)))
|
|
141
130
|
|
|
142
|
-
#
|
|
131
|
+
# Walk submodules
|
|
143
132
|
for mod_name in _iter_package_modules(package):
|
|
144
133
|
if exclude and exclude(mod_name):
|
|
145
134
|
logging.info("Skipping module %s (excluded)", mod_name)
|
|
146
135
|
continue
|
|
147
|
-
|
|
148
136
|
try:
|
|
149
137
|
module = importlib.import_module(mod_name)
|
|
150
138
|
except Exception as e:
|
|
151
139
|
logging.warning("Module %s not processed: %s", mod_name, e)
|
|
152
140
|
continue
|
|
153
|
-
|
|
154
141
|
_visit_module(module)
|
|
155
142
|
|
|
156
|
-
#
|
|
143
|
+
# Also visit the root module itself (in case it's a single-file module)
|
|
157
144
|
if not hasattr(package, "__path__"):
|
|
158
145
|
_visit_module(package)
|
|
159
146
|
|
|
160
|
-
return
|
|
161
|
-
|
|
147
|
+
return comps, facts, interceptors
|
|
162
148
|
|
|
163
149
|
def _register_component_classes(
|
|
164
150
|
*,
|
|
@@ -166,23 +152,12 @@ def _register_component_classes(
|
|
|
166
152
|
container: PicoContainer,
|
|
167
153
|
resolver: Resolver,
|
|
168
154
|
) -> None:
|
|
169
|
-
"""
|
|
170
|
-
Register @component classes into the container.
|
|
171
|
-
|
|
172
|
-
Binding key:
|
|
173
|
-
- If the class has COMPONENT_KEY, use it; otherwise, bind by the class itself.
|
|
174
|
-
Laziness:
|
|
175
|
-
- If COMPONENT_LAZY is True, provide a proxy that defers instantiation.
|
|
176
|
-
"""
|
|
177
155
|
for cls in classes:
|
|
178
156
|
key = getattr(cls, COMPONENT_KEY, cls)
|
|
179
157
|
is_lazy = bool(getattr(cls, COMPONENT_LAZY, False))
|
|
180
158
|
tags = tuple(getattr(cls, COMPONENT_TAGS, ()))
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return ComponentProxy(lambda: resolver.create_instance(c)) if lazy else resolver.create_instance(c)
|
|
184
|
-
return _factory
|
|
185
|
-
container.bind(key, _provider_factory(), lazy=is_lazy, tags=tags)
|
|
159
|
+
provider = _provider_from_class(cls, resolver=resolver, lazy=is_lazy)
|
|
160
|
+
container.bind(key, provider, lazy=is_lazy, tags=tags)
|
|
186
161
|
|
|
187
162
|
|
|
188
163
|
def _register_factory_classes(
|
|
@@ -191,19 +166,9 @@ def _register_factory_classes(
|
|
|
191
166
|
container: PicoContainer,
|
|
192
167
|
resolver: Resolver,
|
|
193
168
|
) -> None:
|
|
194
|
-
"""
|
|
195
|
-
Register products of @factory_component classes.
|
|
196
|
-
|
|
197
|
-
For each factory class:
|
|
198
|
-
- Instantiate the factory via the resolver.
|
|
199
|
-
- For each method with @provides:
|
|
200
|
-
- Bind the provided key to a callable that calls the factory method.
|
|
201
|
-
- If PROVIDES_LAZY is True, bind a proxy that defers the method call.
|
|
202
|
-
"""
|
|
203
169
|
for fcls in factory_classes:
|
|
204
170
|
try:
|
|
205
|
-
#
|
|
206
|
-
# elevando temporalmente el flag `_resolving` para no chocar con la guardia.
|
|
171
|
+
# Prevent accidental container access recursion while constructing factories
|
|
207
172
|
tok_res = _state._resolving.set(True)
|
|
208
173
|
try:
|
|
209
174
|
finst = resolver.create_instance(fcls)
|
|
@@ -217,14 +182,22 @@ def _register_factory_classes(
|
|
|
217
182
|
provided_key = getattr(func, PROVIDES_KEY, None)
|
|
218
183
|
if provided_key is None:
|
|
219
184
|
continue
|
|
185
|
+
|
|
220
186
|
is_lazy = bool(getattr(func, PROVIDES_LAZY, False))
|
|
221
187
|
tags = tuple(getattr(func, PROVIDES_TAGS, ()))
|
|
188
|
+
|
|
189
|
+
# bind the method to the concrete factory instance
|
|
222
190
|
bound = getattr(finst, attr_name, func.__get__(finst, fcls))
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
191
|
+
prov = _provider_from_callable(bound, owner_cls=fcls, resolver=resolver, lazy=is_lazy)
|
|
192
|
+
|
|
193
|
+
if isinstance(provided_key, type):
|
|
194
|
+
# Mark for aliasing policy pipeline and ensure uniqueness of the provider key
|
|
195
|
+
try:
|
|
196
|
+
setattr(prov, "_pico_alias_for", provided_key)
|
|
197
|
+
except Exception:
|
|
198
|
+
pass
|
|
199
|
+
unique_key = (provided_key, f"{fcls.__name__}.{attr_name}")
|
|
200
|
+
container.bind(unique_key, prov, lazy=is_lazy, tags=tags)
|
|
201
|
+
else:
|
|
202
|
+
container.bind(provided_key, prov, lazy=is_lazy, tags=tags)
|
|
230
203
|
|
pico_ioc/utils.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# src/pico_ioc/utils.py
|
|
2
|
+
from typing import Any, Callable
|
|
3
|
+
from .container import PicoContainer
|
|
4
|
+
from .proxy import ComponentProxy
|
|
5
|
+
|
|
6
|
+
def _wrap_if_lazy(provider: Callable, is_lazy: bool) -> Callable:
|
|
7
|
+
"""Wraps a provider in a ComponentProxy if it's marked as lazy."""
|
|
8
|
+
return (lambda: ComponentProxy(provider)) if is_lazy else provider
|
|
9
|
+
|
|
10
|
+
def _provider_from_class(cls: type, *, resolver, lazy: bool):
|
|
11
|
+
def _new():
|
|
12
|
+
return resolver.create_instance(cls)
|
|
13
|
+
return _wrap_if_lazy(_new, lazy)
|
|
14
|
+
|
|
15
|
+
def _provider_from_callable(fn, *, owner_cls, resolver, lazy: bool):
|
|
16
|
+
def _invoke():
|
|
17
|
+
kwargs = resolver.kwargs_for_callable(fn, owner_cls=owner_cls)
|
|
18
|
+
return fn(**kwargs)
|
|
19
|
+
return _wrap_if_lazy(_invoke, lazy)
|
|
20
|
+
|
|
21
|
+
def create_alias_provider(container: PicoContainer, target_key: Any) -> Callable[[], Any]:
|
|
22
|
+
"""Creates a provider that delegates the get() call to the container for another key."""
|
|
23
|
+
def _provider():
|
|
24
|
+
return container.get(target_key)
|
|
25
|
+
return _provider
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pico-ioc
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: A minimalist, zero-dependency Inversion of Control (IoC) container for Python.
|
|
5
5
|
Author-email: David Perez Cabrera <dperezcabrera@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -61,19 +61,55 @@ It helps you build loosely-coupled, testable apps without manual wiring. Inspire
|
|
|
61
61
|
|
|
62
62
|
---
|
|
63
63
|
|
|
64
|
-
##
|
|
64
|
+
## ⚖️ Principles
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
* **Focus & Simplicity**: A minimal core for one job: managing dependencies. It avoids accidental complexity by doing one thing well.
|
|
67
|
+
* **Predictable & Explicit**: No magic. Behavior is deterministic, relying on explicit decorators and a clear resolution order.
|
|
68
|
+
* **Unified Composition Root**: The application is assembled from a single entry point (`init`) which defines a clear, predictable boundary. This ensures a stable and understandable bootstrap process.
|
|
69
|
+
* **Fail-Fast Bootstrap**: Catches dependency graph errors at startup, not in production. If the application runs, it's wired correctly.
|
|
70
|
+
* **Testability First**: Features like `scope()` and `overrides` are first-class citizens, enabling fast and isolated testing.
|
|
71
|
+
* **Extensible by Design**: Lifecycle hooks and AOP are available through a clean Plugin and Interceptor API without altering the core.
|
|
72
|
+
* **Framework Agnostic**: Zero hard dependencies. It works with any Python application, from simple scripts to complex web servers.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## ✨ Why Pico-IoC?
|
|
77
|
+
|
|
78
|
+
`pico-ioc` exists to solve a common problem that arises as Python applications grow: managing how objects are created and connected becomes complex and brittle. This manual wiring, where a change deep in the application can cause a cascade of updates, makes the code hard to test and maintain. `pico-ioc` introduces the principle of Inversion of Control (IoC) in a simple, Pythonic way. Instead of you creating and connecting every object, you declare your components with a simple `@component` decorator, and the container automatically wires them together based on their type hints. It brings the architectural robustness and testability of mature frameworks like Spring to the Python ecosystem, but without the heavy boilerplate, allowing you to build complex, loosely-coupled applications that remain simple to manage.
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
| Feature | Manual Wiring | With Pico-IoC |
|
|
82
|
+
| :------------------ | :------------------------------------------------ | :------------------------------ |
|
|
83
|
+
| **Object Creation** | `service = Service(Repo(Config()))` | `svc = container.get(Service)` |
|
|
84
|
+
| **Testing** | Manual replacement or monkey-patching | `overrides={Repo: FakeRepo()}` |
|
|
85
|
+
| **Coupling** | High (code knows about constructors) | Low (code just asks for a type) |
|
|
86
|
+
| **Maintenance** | Brittle (changing a constructor breaks consumers) | Robust (changes are isolated) |
|
|
87
|
+
| **Learning Curve** | Ad-hoc, implicit patterns | Uniform, explicit, documented |
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 🧩 Features
|
|
93
|
+
|
|
94
|
+
### Core
|
|
95
|
+
|
|
96
|
+
* **Zero dependencies** — pure Python, framework-agnostic.
|
|
97
|
+
* **Single Entry Point (`init`)** — Robustly bootstrap your entire application from a single root package, enforcing a clean "Composition Root" pattern.
|
|
98
|
+
* **Decorator API** — `@component`, `@factory_component`, `@provides`, `@plugin`.
|
|
99
|
+
* **Fail-fast bootstrap** — eager by default; missing deps surface at startup.
|
|
100
|
+
* **Opt-in lazy** — `lazy=True` wraps with `ComponentProxy`.
|
|
101
|
+
* **Smart resolution order** — parameter name → type annotation → MRO → string.
|
|
102
|
+
* **Overrides for testing** — inject mocks/fakes directly via `init(overrides={...})`.
|
|
103
|
+
* **Public API helper** — auto-export decorated symbols in `__init__.py`.
|
|
104
|
+
* **Thread/async safe** — isolation via `ContextVar`.
|
|
105
|
+
|
|
106
|
+
### Advanced
|
|
107
|
+
|
|
108
|
+
* **Qualifiers & collections** — `list[Annotated[T, Q]]` filters by qualifier.
|
|
109
|
+
* **Flexible Scopes (`scope`)** — Create lightweight, temporary containers from multiple modules, ideal for testing, scripting, or modular tasks.
|
|
110
|
+
* **Interceptors API** — observe/modify resolution, instantiation, invocation, errors.
|
|
111
|
+
* **Conditional providers** — activate components by env vars or predicates.
|
|
112
|
+
* **Plugins** — lifecycle hooks (`before_scan`, `after_ready`).
|
|
77
113
|
|
|
78
114
|
---
|
|
79
115
|
|
|
@@ -163,10 +199,17 @@ This way you don’t need to bootstrap your entire app (`controllers`, `http`,
|
|
|
163
199
|
---
|
|
164
200
|
## 📖 Documentation
|
|
165
201
|
|
|
166
|
-
*
|
|
167
|
-
* [
|
|
168
|
-
|
|
202
|
+
* **🚀 New to pico-ioc? Start with the User Guide.**
|
|
203
|
+
* [**GUIDE.md**](.llm/GUIDE.md) — Learn with practical examples: testing, configuration, collection injection, and web framework integration.
|
|
204
|
+
|
|
205
|
+
* **🏗️ Want to understand the internals? See the Architecture.**
|
|
206
|
+
* [**ARCHITECTURE.md**](.llm/ARCHITECTURE.md) — A deep dive into the algorithms, lifecycle, and internal diagrams. Perfect for contributors.
|
|
207
|
+
|
|
208
|
+
* **🤔 Want to know *why* it's designed this way? Read the Decisions.**
|
|
209
|
+
* [**DECISIONS.md**](.llm/DECISIONS.md) — The history and rationale behind key technical decisions.
|
|
169
210
|
|
|
211
|
+
* **💡 Just need a quick summary?**
|
|
212
|
+
* [**OVERVIEW.md**](.llm/OVERVIEW.md) — What pico-ioc is and why you should use it.
|
|
170
213
|
---
|
|
171
214
|
|
|
172
215
|
## 🧪 Development
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
pico_ioc/__init__.py,sha256=Vl0nnRou3BZY1QSUOSyZ8-PFIFrz979DAzhXp0KYvIg,1014
|
|
2
|
+
pico_ioc/_state.py,sha256=XG3Q8NsRN-Di5MrWn6kLzJXg25PXp2_qAzfgytNoP-s,1021
|
|
3
|
+
pico_ioc/_version.py,sha256=zi_LaUT_OsChAtsPXbOeRpQkCohSsOyeXfavQPM0GoE,22
|
|
4
|
+
pico_ioc/api.py,sha256=PbR9_VX3ipxgv7-vKq1TyjKC75RqyDr65QUCG4i7eeI,9172
|
|
5
|
+
pico_ioc/builder.py,sha256=QPn1yC3JQYkjV08XpCAIFs95Bi0VQG5NZnSXKx4IgsI,10730
|
|
6
|
+
pico_ioc/container.py,sha256=YCrjAhChHtDcPBg1Zz0PnMbY-6x6V313nA1liPNaUaM,6306
|
|
7
|
+
pico_ioc/decorators.py,sha256=jhJxpaR9wCeBsNm1W0ziTCF3C0LGhu866-9x4IJ9-4U,3581
|
|
8
|
+
pico_ioc/interceptors.py,sha256=-ZH-AG4h_6vUgTJGbP8YESlODhOEkdC6r82GHTRrKxk,1978
|
|
9
|
+
pico_ioc/plugins.py,sha256=GP7WEMshggQ-FEjiShkcuLrSMxfueUnhbY9I8PcIyPU,1039
|
|
10
|
+
pico_ioc/policy.py,sha256=XQs8Nr7aTq0xbNPGaeFiBgJCI65r5rXK4yQdhhQuLjM,12054
|
|
11
|
+
pico_ioc/proxy.py,sha256=ZQ0g5QT32QV_v72N9oUWtQRnTh5An66GPtvaF1HtNp8,6187
|
|
12
|
+
pico_ioc/public_api.py,sha256=E3sArCoI1xxkIw7xQBvLYAWcIoVJjcq1s0kH-0qIVDE,2383
|
|
13
|
+
pico_ioc/resolver.py,sha256=qCzyjsfq59b_XEa5LNAgWzPniqoJYxyG-mXn2fzqFsk,5063
|
|
14
|
+
pico_ioc/scanner.py,sha256=VjIW6e2nsYuI1pm38RX8yIGs7SUrvuKHPN5vgTss3h4,7257
|
|
15
|
+
pico_ioc/utils.py,sha256=OyhOKnyepwGQ_uQKlQLt-fymEV1bQ6hCq4Me7h3dfco,1002
|
|
16
|
+
pico_ioc-1.3.0.dist-info/licenses/LICENSE,sha256=N1_nOvHTM6BobYnOTNXiQkroDqCEi6EzfGBv8lWtyZ0,1077
|
|
17
|
+
pico_ioc-1.3.0.dist-info/METADATA,sha256=GRIv4XBIAY8vFFXv0BVFyT4lVqryoUEQU9qF6jOlftc,10259
|
|
18
|
+
pico_ioc-1.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
19
|
+
pico_ioc-1.3.0.dist-info/top_level.txt,sha256=_7_RLu616z_dtRw16impXn4Mw8IXe2J4BeX5912m5dQ,9
|
|
20
|
+
pico_ioc-1.3.0.dist-info/RECORD,,
|
pico_ioc/typing_utils.py
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# pico_ioc/typing_utils.py
|
|
2
|
-
|
|
3
|
-
import sys
|
|
4
|
-
import typing
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def evaluated_hints(func, owner_cls=None) -> dict:
|
|
8
|
-
"""Return type hints; swallow any error and return {}."""
|
|
9
|
-
try:
|
|
10
|
-
module = sys.modules.get(func.__module__)
|
|
11
|
-
globalns = getattr(module, "__dict__", {})
|
|
12
|
-
localns = vars(owner_cls) if owner_cls is not None else None
|
|
13
|
-
return typing.get_type_hints(func, globalns=globalns, localns=localns, include_extras=True)
|
|
14
|
-
except Exception:
|
|
15
|
-
return {}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def resolve_annotation_to_type(ann, func, owner_cls=None):
|
|
19
|
-
"""Best-effort evaluation of a string annotation; return original on failure."""
|
|
20
|
-
if not isinstance(ann, str):
|
|
21
|
-
return ann
|
|
22
|
-
try:
|
|
23
|
-
module = sys.modules.get(func.__module__)
|
|
24
|
-
globalns = getattr(module, "__dict__", {})
|
|
25
|
-
localns = vars(owner_cls) if owner_cls is not None else None
|
|
26
|
-
return eval(ann, globalns, localns)
|
|
27
|
-
except Exception:
|
|
28
|
-
return ann
|
|
29
|
-
|
pico_ioc-1.2.0.dist-info/RECORD
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
pico_ioc/__init__.py,sha256=JTLiySlYUTAnWODEdilS2rUz4swaqMxrQw_p6IRu-S0,653
|
|
2
|
-
pico_ioc/_state.py,sha256=KHNtdPrv1s-uynfot2IsNkWotBPyORPCcM2xe9qMMPo,286
|
|
3
|
-
pico_ioc/_version.py,sha256=U3f_Jgr3zpgiYG2kLcvcT05TQsVzN9Kktg_f3Q9OZFA,22
|
|
4
|
-
pico_ioc/api.py,sha256=GD16DejaBW6pAH0djU8xCirvkgAla5Ags3sGuhkd7oo,9250
|
|
5
|
-
pico_ioc/container.py,sha256=akjtF9Qo09lsR65a5_8UDnEB6Vvsyuq2BloceJjWpnI,5281
|
|
6
|
-
pico_ioc/decorators.py,sha256=orVMdmGgMYCtNq6fjqEYGZxSuv5qdVqf8J6xoUiUQgs,2173
|
|
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=RVVpqnp2UqcKwkKMYBzrTetnZW-ZTY7XwDOslBAWPxI,4911
|
|
11
|
-
pico_ioc/scanner.py,sha256=cSa33lE7dKwUpj2RNpH1SC4wjiaJ9MifS5ecORtW1xM,7645
|
|
12
|
-
pico_ioc/typing_utils.py,sha256=JQ4bkR60pKxFs3f8JlEz41ruKDsWj-SmkKv3DLJriec,950
|
|
13
|
-
pico_ioc-1.2.0.dist-info/licenses/LICENSE,sha256=N1_nOvHTM6BobYnOTNXiQkroDqCEi6EzfGBv8lWtyZ0,1077
|
|
14
|
-
pico_ioc-1.2.0.dist-info/METADATA,sha256=XmSjbjeocTk7V1TIHb2irV5tzJd37zepVKEfWIsDvFM,6719
|
|
15
|
-
pico_ioc-1.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
16
|
-
pico_ioc-1.2.0.dist-info/top_level.txt,sha256=_7_RLu616z_dtRw16impXn4Mw8IXe2J4BeX5912m5dQ,9
|
|
17
|
-
pico_ioc-1.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|