Skip to main content

pyiv

Guice-style dependency injection for Python: type-based constructor injection, scopes, qualified keys (tag sets, matched inject, Annotated constructors), 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.

Metadata

Release files for pyiv 1.0.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 1.0.0
File Size Uploaded Provenance Actions
pyiv-1.0.0.tar.gz 648.9 kB Without provenance Details for pyiv-1.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 760.6 kB

Release files / pyiv-1.0.0.tar.gz

Download URL pyiv-1.0.0.tar.gz
Size 648.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a3e29bbc6e6203232fd28102ad58893167fb3bd8a9cfa7dcba7f336469534cea
BLAKE2b-256 checksum
How to use checksums
d605490349856aa1f8514b81dcbc35549057eb2e8260070401948091e4221b6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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

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

Security for pyiv 1.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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