Skip to main content

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

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

The user guide covers Binder, Keys, scopes, and the Clock / Filesystem / Console / DateTimeService test doubles.

Development

pip install -e ".[dev,docs]"
./run_checks.sh

run_checks.sh formats (black/isort), runs pytest (including doctests in pyiv/), 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.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyiv 0.3.0
File Size Uploaded
pyiv-0.3.0.tar.gz 134.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyiv 0.3.0
File Interpreter ABI Platform
pyiv-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 203.4 kB

Release files / pyiv-0.3.0.tar.gz

Download URL pyiv-0.3.0.tar.gz
Size 134.6 kB
Tags Source
SHA-256 checksum
How to use checksums
385eeef6818c9a51ea393ae8b6f609a9a3b332625d2a83a8193fe3db883f4aff
BLAKE2b-256 checksum
How to use checksums
88a95f8519f3bf0d83cd3eec0dc15212df1c7e57816fa79b72403cd480f41134
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / pyiv-0.3.0-py3-none-any.whl

Download URL pyiv-0.3.0-py3-none-any.whl
Size 68.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e55f3f4675297bdc11f52c31b33215d2814d094722e7a232c2f2305277f6d788
BLAKE2b-256 checksum
How to use checksums
61b2c696efa6fea264287375779ff3aab34f2e4c230683575a5528e2b88c844b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page