Skip to main content

pyiv

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

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.1
File Size Uploaded Provenance Actions
pyiv-0.4.1.tar.gz 162.8 kB Without provenance Details for pyiv-0.4.1.tar.gz

Built distribution (wheel)

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

Total release size: 246.7 kB

Release files / pyiv-0.4.1.tar.gz

Download URL pyiv-0.4.1.tar.gz
Size 162.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b1abc9664f76c2719c94438938140408021dfd7ca945dde2661c077a8b1bdcc7
BLAKE2b-256 checksum
How to use checksums
d3e6713e11d500616f18bfb0937fb6e072bbe0b5c40d040f4617029fed2d3605
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.1-py3-none-any.whl

Download URL pyiv-0.4.1-py3-none-any.whl
Size 83.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d2b3835641820f61f01402de6e6ff587293f3e528aa2b462a068b1f116af65b
BLAKE2b-256 checksum
How to use checksums
da552d375e8679604e359c7f0d9f17781f1843e03b270c19fd6f9e2c518798da
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.1

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