Skip to main content

Dishka × Cyclopts

Async Dishka integration for Cyclopts. It injects dependencies into async CLI commands using the familiar @inject decorator.

Features

  • Automatic scope management: async containers are closed after each command, so async generators/iterators are finalized.
  • Drop-in decorator: use @inject on Cyclopts commands; annotate parameters with FromDishka[...].
  • Positional-friendly: injected params can precede user arguments; binding is normalized to kwargs.

Installation

Install using pip

pip install dishka-cyclopts

Or with uv

uv add dishka-cyclopts

Usage

from cyclopts import App
from dishka import FromDishka, Provider, Scope, make_async_container, provide
from dishka_cyclopts import inject, setup_dishka


class Dependencies(Provider):
    @provide(scope=Scope.APP)
    def meaning(self) -> int:
        return 42


app = App(result_action="return_value")
setup_dishka(make_async_container(Dependencies()), app)


@app.command
@inject
async def main(value: FromDishka[int]) -> int:
    return value


if __name__ == "__main__":
    print(app())

setup_dishka patches Cyclopts to track the current app and stores the provided AsyncContainer inside app.state. After each command completes the container is closed, finalizing APP/REQUEST scoped resources (including async generators).

Requirements

  • Python 3.10+
  • Cyclopts >= 4.3.0
  • Dishka >= 1.7.2

More Examples

Check out the examples directory for more detailed examples.

Metadata

Release files for dishka-cyclopts 1.0.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 dishka-cyclopts 1.0.1
File Size Uploaded Provenance Actions
dishka_cyclopts-1.0.1.tar.gz 3.6 kB Without provenance Details for dishka_cyclopts-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dishka-cyclopts 1.0.1
File Interpreter ABI Platform Actions
dishka_cyclopts-1.0.1-py3-none-any.whl Python 3 none any Details for dishka_cyclopts-1.0.1-py3-none-any.whl

Total release size: 8.4 kB

Release files / dishka_cyclopts-1.0.1.tar.gz

Download URL dishka_cyclopts-1.0.1.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9777e61833a45d9e299bdc73a72225ea3dbdeb4c1b6c4c1c37b0d5315b4a5eb2
BLAKE2b-256 checksum
How to use checksums
785bbb3e32cb107c0825e49f29390e754edd82a636cc6c27e3b46cfbdd7b9df9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.19

Release files / dishka_cyclopts-1.0.1-py3-none-any.whl

Download URL dishka_cyclopts-1.0.1-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
733177eed82a84da7162bf78e2bffdbbb6f0b9909ba42bd67bdc89f55895fa8b
BLAKE2b-256 checksum
How to use checksums
12d03c1a4b74a8f3b81839ea9f6b4705baef27ccd59147936cc18637306084be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.19

Security for dishka-cyclopts 1.0.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.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

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