consolekit
raw JSON → 1.13.0 verified Mon Apr 27 auth: no python
consolekit is a collection of utilities for Click, providing additional decorators, formatting helpers, and input/output features. Current version is 1.13.0, supports Python >=3.7. Actively maintained.
pip install consolekit Common errors
error ModuleNotFoundError: No module named 'consolekit.decorators' ↓
cause In consolekit >=1.0, the decorators submodule was removed; all decorators are now in the top-level package.
fix
Change 'from consolekit.decorators import command' to 'from consolekit import command'.
error AttributeError: module 'consolekit' has no attribute 'Colour' ↓
cause Attempting to import Colour from an older version where it was not re-exported top-level, or using a stale installation.
fix
Upgrade consolekit to >=1.0: pip install --upgrade consolekit. Then use 'from consolekit import Colour'.
error TypeError: 'Command' object is not callable ↓
cause The @command decorator is used without parentheses, or the decorated function is not returning a click.Command correctly.
fix
Use @command() with parentheses, and ensure the function logic returns None (not a Command object) unless you intend to customize the command.
Warnings
breaking In v1.0, many imports were reorganized. Symbols previously under submodules (e.g., consolekit.decorators.command) now must be imported from consolekit top-level. Direct submodule imports may break. ↓
fix Use from consolekit import command instead of from consolekit.decorators import command.
deprecated The consolekit.decorators module is deprecated; all decorators are now re-exported from the main package. ↓
fix Import decorators from consolekit directly.
gotcha The @command decorator from consolekit expects the function to return a click.Command. If you mix consolekit.option with native click.option, argument ordering may differ. ↓
fix Use consolekit.option consistently within a consolekit.command-decorated function.
gotcha Colour class uses ANSI escape sequences; ensure the output stream supports colors (e.g., not redirected to a file). Use colour.is_enabled() to check. ↓
fix Call Colour.is_enabled() before applying colors or use Colour.strip() to remove colors.
Imports
- command wrong
from consolekit.decorators import commandcorrectfrom consolekit import command - VerboseCommand wrong
from consolekit.commands import VerboseCommandcorrectfrom consolekit import VerboseCommand - Colour wrong
from consolekit.colour import Colourcorrectfrom consolekit import Colour - Screen wrong
from consolekit.screen import Screencorrectfrom consolekit import Screen
Quickstart
from consolekit import command, Colour
@command()
def greet(name: str):
print(f"{Colour.green('Hello')}, {name}!")
if __name__ == '__main__':
greet()