Skip to main content

wireme

wireme - tiny, typed dependency injection for Python

Tiny, typed dependency injection for Python.

CI Coverage: 100% PyPI version Supported Python versions License


Documentation: wireme.mghalix.com


Declare how a dependency is created once, then inject it into functions, methods, constructors, or FastAPI endpoints without turning the dependency container into an application framework.

Wireme resolves the graph and touches nothing else. It never validates, coerces, or serializes arguments, dependency results, or return values.

Installation

uv add wireme

With the optional FastAPI integration:

uv add 'wireme[fastapi]'

Wireme requires Python 3.12 or newer.

Sixty-second tour

Declare a factory, wire an entry point, and keep the dependency fully typed:

from typing import Annotated

from wireme import Wired, wire, wired


class Database:
    def write(self, value: str) -> None:
        print(f"writing: {value}")


def get_database() -> Database:
    return Database()


type DatabaseDep = Annotated[Database, wired(get_database)]


@wire
def create_user(username: str, *, database: DatabaseDep = Wired()) -> None:
    database.write(username)


create_user("mo")

Injected parameters are keyword-only and disappear from the public runtime signature. Callers see application inputs; Wireme resolves the rest.

Classes wire their constructors, and tests replace factories without monkeypatching consumers:

from wireme import override_dependency


@wire
class UserService:
    def __init__(self, *, database: DatabaseDep = Wired()) -> None:
        self._database = database

    def list_users(self) -> list[str]:
        return []


def get_test_database() -> Database:
    return Database()


with override_dependency(get_database, get_test_database):
    service = UserService()

The optional FastAPI integration lets FastAPI retain ownership of the request lifecycle while Wireme resolves the internal graph:

from fastapi import FastAPI

from wireme.fastapi import FromWeb


app = FastAPI()


@app.get("/users")
def list_users(*, service: FromWeb[UserService]) -> list[str]:
    return service.list_users()

Why Wireme

  • Four core names. wire, wired, Wired, and override_dependency.
  • Typed end to end. Reusable Annotated aliases keep declarations and static types together.
  • Hidden wiring. Injected parameters stay out of public signatures, editor call hints, and OpenAPI schemas.
  • Complete lifecycles. Sync, async, generator, and async-generator factories compose with deterministic cleanup.
  • Predictable values. Dependency injection never becomes implicit validation or coercion.
  • Clean tests. Overrides are nested-safe and restored after exceptions.

Learn more

The documentation contains the full guide, production recipes, and Wireme way. Every public capability also has a runnable entry in the example index.

Implementation

Wireme currently uses FastDepends internally for graph execution, caching, async dispatch, and resource lifecycles. That engine is an implementation detail: application code uses Wireme's API and does not need to learn or import FastDepends.

Versioning

Wireme follows SemVer with the strict 0.x mapping: below 1.0.0, a breaking change bumps minor and features or fixes bump patch. Published artifacts are immutable; a broken release is fixed by publishing a new version. See the release notes.

License

MIT

Metadata

Release files for wireme 0.2.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 wireme 0.2.2
File Size Uploaded Provenance Actions
wireme-0.2.2.tar.gz 11.8 kB Without provenance Details for wireme-0.2.2.tar.gz

Built distribution (wheel)

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

Total release size: 26.1 kB

Release files / wireme-0.2.2.tar.gz

Download URL wireme-0.2.2.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b954873d64b7c72040c01ae896c78b6c7eab643580d82f8a44d122ba0703aa42
BLAKE2b-256 checksum
How to use checksums
64595911018ca45879968dec980cefa57f341c2631a14e712e4e0832df20993e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / wireme-0.2.2-py3-none-any.whl

Download URL wireme-0.2.2-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ae7c0fde15e31317ee79ecf23247b0768c8411674da4511921c44a8314e3e11
BLAKE2b-256 checksum
How to use checksums
5193ad7374a06200ae5e930f1c39a63860417dabe6ae5ab07fa5e5afe40cf644
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for wireme 0.2.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