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 0.4.2

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.4.2
File Size Uploaded Provenance Actions
pyiv-0.4.2.tar.gz 166.8 kB Without provenance Details for pyiv-0.4.2.tar.gz

Built distribution (wheel)

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

Total release size: 252.9 kB

Release files / pyiv-0.4.2.tar.gz

Download URL pyiv-0.4.2.tar.gz
Size 166.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7ea6399f2965cb42c4cefa3fe689092e948b7351830536765b92eae25b939342
BLAKE2b-256 checksum
How to use checksums
7d5f8d9760124d1f5ac566f349d14b96a8fa56ad3d3a997da9ca50d2352c59ab
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.2-py3-none-any.whl

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

Security for pyiv 0.4.2

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