Registry / devops / wired
library0.4pypypi✓ verified 88d ago

An inversion-of-control (IoC) container for Python that supports dependency injection via service registration and factory functions. Current version 0.4, targeting Python >=3.8. Release cadence is low; it is a stable but rarely updated library.

pip install wired
INSTALL
IMPORT
SIG · WIRED
W
wired
devopspythonv0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ServiceRegistry
✓ from wired import ServiceRegistry
The primary class for creating a container.
injectable
✓ from wired import injectable
✗ from wired.injectable import injectable
injectable is a module, not a subpackage; the decorator is imported as 'from wired import injectable'.
dataclass
✓ from wired import dataclass
✗ from wired.dataclasses import dataclass
The dataclass decorator is in the 'wired' package directly.

Create a service registry, register an injectable class, and retrieve it from a container.

from wired import ServiceRegistry, injectable # Define a service @injectable() class Greeter: def __init__(self, greeting: str = "Hello"): self.greeting = greeting def greet(self, name: str) -> str: return f"{self.greeting}, {name}!" # Set up registry registry = ServiceRegistry() registry.register(Greeter) # Get a container and use container = registry.create_container() greeter = container.get(Greeter) print(greeter.greet("World"))
Debug
Known issues
gotchaServices registered without @injectable() will not be recognized; the decorator must be applied.
fix
Add @injectable() decorator to any class that will be injected.
affects: 0.x
deprecatedThe 'wired.injectable' submodule is not a public API; importing from it may break in future versions.
fix
Use 'from wired import injectable' and apply as a decorator.
affects: 0.3+
gotchaConstructor parameters for injectable classes must be type-annotated; otherwise, wired cannot resolve dependencies.
fix
Add type hints to all __init__ parameters.
affects: 0.x
Errors
Common errors & fixes
TypeError: can't inject type 'xyz'; no factory registered
The service class was not registered in the ServiceRegistry.
fix
Call registry.register(YourClass) before creating the container.
wired.exceptions.CannotInject: Cannot inject <class '__main__.MyService'> - no @injectable decorator
Class missing @injectable() decorator.
fix
Apply @injectable() to the class definition.
Upgrade
Version history
0.4latest on PyPI · released Feb 23, 2024
Audit
Dependencies
wiredrequiredContains the IoC container, service registry, and decorators.
Agent activity
11 hits · last 30 days
node
10
Resources
wired — pip install wired · libregistry