typer-injector
typer-injector adds FastAPI-style dependency injection to Typer.
Table of Contents
Installation
pip install typer-injector
Usage
Example:
import socket
from typing import Annotated, TypeAlias
import typer
from typer_injector import Depends, InjectingTyper
app = InjectingTyper()
def address_dependency(
host: Annotated[str, typer.Option()],
port: Annotated[int, typer.Option()],
) -> tuple[str, int]:
return host, port
Address: TypeAlias = Annotated[tuple[str, int], Depends(address_dependency)]
@app.command()
def send_message(message: str, address: Address) -> None:
"""Send a message to the specified address."""
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.connect(address)
sock.send(message.encode())
@app.command()
def receive_message(address: Address) -> None:
"""Listen for a message at the specified address."""
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.bind(address)
sock.listen(1)
conn, _ = sock.accept()
with conn:
data = conn.recv(1024)
print(data.decode())
if __name__ == '__main__':
app()
License
typer-injector is distributed under the terms of the MIT license.
Metadata
Release files for typer-injector 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| typer_injector-0.3.0.tar.gz | 8.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| typer_injector-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.6 kB
Release files / typer_injector-0.3.0.tar.gz
| Download URL | typer_injector-0.3.0.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7fa5b411b86c31aeeb22fc180d0ebf615c2a71c8f2b1dc97ad4d06a4c235b3a5
|
|
BLAKE2b-256 checksum How to use checksums |
b3117da0c6019c26cb660acc3329b44c3247286469de3dcd94013d0793598ecb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Apr 29, 2026.
Transparency logRelease files / typer_injector-0.3.0-py3-none-any.whl
| Download URL | typer_injector-0.3.0-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
02ea50329f5e411592c5b8ef8387ffa043b58977f0431ec449f7b1f41717f90f
|
|
BLAKE2b-256 checksum How to use checksums |
f1976217b630fc5ec896dc7226a36aafa26e87ae6c106043ec505490e52459fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Apr 29, 2026.
Transparency log