skillfed

click-compose

Composable Click callback utilities for building flexible CLI applications.

click-compose v2025.10.27.3 170.8K downloads/30d#10,386 on PyPI1
Permissive license MIT Active released

What it is and what it does

click-compose is a small utility library that adds composition patterns to Click's callback system. It provides two main functions: multi_callback chains multiple validators or transformations into a single callback that applies them in sequence, and sequence_validator applies a validator to each element in a multi-value parameter. The library sits on top of Click and beartype, requiring Python 3.10 or later.

The package addresses a common pattern in CLI development where you want to reuse validation logic across multiple parameters or combine independent validators without nesting them manually. Instead of writing wrapper callbacks or repeating validation code, you compose validators declaratively at the parameter level.

Use it for:

  • Chain multiple validation rules on a single CLI option without writing nested callback wrappers.
  • Apply the same validator to each element in a multi-value parameter using sequence_validator.
  • Build reusable validator functions that can be composed into different CLI commands.
  • Validate numeric ranges or string patterns by combining independent validator callbacks.
  • Reduce boilerplate in Click command definitions by composing validators declaratively.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides composable callback utilities for Click CLI applications, enabling you to chain multiple validators or transformations together and apply them to command parameters.

Yes, if you build Click CLIs and want to reduce callback boilerplate. The library is lightweight, has low install friction, carries no security vulnerabilities, and uses a permissive license. However, it is very new (first release in October 2025) with minimal real-world adoption, so treat it as a convenience tool rather than a critical dependency—the same patterns can be implemented manually if needed.

Install

click-compose on PyPI

pip

pip install click-compose

uv

uv add click-compose

poetry

poetry add click-compose

Installing click-compose

Before you install

Low friction install with only two runtime dependencies (beartype and click). Active maintenance with a recent commit history, though the project is young and has minimal adoption signals.

License in practice

MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects.

Quickstart

pip install click-compose

import click
from click_compose import multi_callback

def validate_positive(_ctx, _param, value):
    if value <= 0:
        raise click.BadParameter("Must be positive")
    return value

@click.command()
@click.option("--count", type=int, callback=multi_callback(callbacks=[validate_positive]))
def cmd(count):
    click.echo(f"Count: {count}")

Requires Python 3.10 or later.

Verify before relying

  • Whether beartype is used for runtime type checking or only as a development dependency.
  • Performance characteristics when chaining many validators in sequence.
  • Compatibility with Click extensions or custom parameter types beyond built-in types.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 2 — beartype, click
Maintenance actively maintained — 291 days since the last release
Last repo commit
First released
Downloads 170,828/month — #10,386 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: click_compose-2025.10.27.3-py2.py3-none-any.whl

Keywords: callbacks, cli, click, validation

Development Status :: 4 - BetaIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Software Development :: Libraries :: Python Modules

Tags

click callback compositioncli parameter validationclick multi-validatorcomposable click callbackscli argument chainingclick sequence validationreusable cli validators
click-extensioncli-validationcallback-composition

More Python Modules packages