pyiv
Guice-style dependency injection for Python: type-based constructor injection, scopes, qualified keys, and built-in test doubles. Zero runtime dependencies. Python 3.8+.
Docs: https://rl337.org/pyiv/ · Changelog: https://rl337.org/pyiv/changelog.html · PyPI: https://pypi.org/project/pyiv/
Install
pip install pyiv
Requires Python 3.8 or newer. Unreleased main:
pip install git+https://github.com/rl337/pyiv.git
YAML and requests integrations are a second package (core stays stdlib-only):
pip install pyiv-common
The user guide covers Binder, Keys, scopes, the Clock / Filesystem / Console / DateTimeService test doubles, and related packages.
Quick start
from pyiv import Config, get_injector
class Database:
pass
class PostgreSQL(Database):
pass
class MyConfig(Config):
def configure(self):
self.register(Database, PostgreSQL)
injector = get_injector(MyConfig)
db = injector.inject(Database) # PostgreSQL
Development
pip install -e ".[dev,docs]"
pip install -e extras/pyiv-common
./run_checks.sh
run_checks.sh formats (black/isort), runs pytest (including doctests in
pyiv/ and pyiv-common), mypy, bandit, and a Sphinx build.
Version numbers are bumped by GitHub Actions on main. Do not edit
pyproject.toml / pyiv/__init__.py versions except for a manual major bump
(the 0.3.0 PyPI release is that exception).
License
MIT — see LICENSE.
Release files for pyiv 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyiv-0.4.0.tar.gz | 155.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyiv-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 235.2 kB
Release files / pyiv-0.4.0.tar.gz
| Download URL | pyiv-0.4.0.tar.gz |
|---|---|
| Size | 155.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1584cb17deb58c5970873277727875231266bbe3228f4e4302b0e5e3cff6bbae
|
|
BLAKE2b-256 checksum How to use checksums |
075f1de1530b1b11cee8378ca6397a3932a5c0f2af69251f31b46b7401a60e75
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pyiv-0.4.0-py3-none-any.whl
| Download URL | pyiv-0.4.0-py3-none-any.whl |
|---|---|
| Size | 79.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
46aeeb586e2eefb432f27bcab227cb3f51a177a76c56acdf59544eae28e9744e
|
|
BLAKE2b-256 checksum How to use checksums |
7d5d978eaa788e85ff0df86dd4175247ca3ea650ca597532e82484cbe8ca967e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|