Skip to content

task: migrate infrahubctl CLI from Typer to Cyclopts #1141

Description

@dgarros

Component

  • infrahubctl CLI

Need

The infrahubctl CLI is built on Typer, which has
no native support for async command handlers. To work around this we maintain our own
AsyncTyper subclass (infrahub_sdk/async_typer.py) that wraps every async command in
asyncio.run. This is a local shim we have to keep working across Typer releases, and
Typer itself has seen limited maintenance activity.

The ask is to migrate the CLI to Cyclopts so
that:

  • The locally-maintained AsyncTyper shim can be removed — Cyclopts supports async
    command handlers natively.
  • The project depends on a more actively maintained CLI framework for better long-term
    support.
  • Startup can benefit from Cyclopts' lazy import of subcommands, reducing CLI overhead.

Context

  • The local shim lives in infrahub_sdk/async_typer.py (AsyncTyper(Typer)).
  • Typer / AsyncTyper is used broadly across the CLI — roughly two dozen modules under
    infrahub_sdk/ctl/ import typer or AsyncTyper (commands, parameters, parsers,
    and the object/ subcommands), so this is a wide surface, not a single entry point.
  • typer>=0.15.0 is currently pinned in pyproject.toml (declared in two dependency
    groups).
  • Ruff carve-outs exist specifically for Typer patterns (B008 for typer.Option in
    defaults, DOC501 for typer.Exit/Abort as control flow) — these will need
    revisiting as part of the migration.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/highThis issue should be completed in more than a daytype/tech-debtItem we know we need to improve way it is implemented

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions