click-compose
Composable Click callback utilities for building flexible CLI applications.
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-composeuv
uv add click-composepoetry
poetry add click-composeInstalling 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
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
clickClick is a Python toolkit for building…
permissive · top 100 on PyPI
click-config-fileAdds configuration file support to Click…
permissive · top 15,000 on PyPI
cligjProvides reusable Click command-line argument…
permissive · top 5,000 on PyPI
asyncclickAsyncclick provides a fork of Click that…
permissive · top 5,000 on PyPI
click-help-colorsAdds color customization to Click command-line…
permissive · top 5,000 on PyPI
click-datetimeAdds datetime type support to Click, allowing…
permissive · top 15,000 on PyPI
rich-clickRenders Click command-line interfaces with rich…
permissive · top 1,000 on PyPI
auto-click-autoAutomatically enables tab shell completion for…
permissive · top 15,000 on PyPI
lib-cli-exit-toolsProvides portable signal handling,…
permissive · top 15,000 on PyPI
click-configfileExtends click with configuration file support,…
permissive · top 15,000 on PyPI