Zero-dependency Python task runner using pyproject.toml [tool.tasks]
- Zero dependencies: Uses only Python standard library (requires Python 3.11+ for
tomllib) - Multiple task types:
- Shell commands
- Task aliases
- Task chains
- Python module entry points
- Simple configuration: Define tasks in your
pyproject.tomlfile - Automatic discovery: Searches for
pyproject.tomlin current directory and parent directories
pip install tool-tasks# List available tasks
task --list
# Run a task
task <task-name>
# Run a task with arguments
task <task-name> arg1 arg2Define tasks in your pyproject.toml file under the [tool.tasks] section:
[tool.tasks]
# Simple shell command
hello = "echo 'Hello, World!'"
# Task alias (references another task)
greet = "hello"
# Task chain (runs multiple tasks in sequence)
ci = ["test", "lint", "build"]
# Shell command task
test = "pytest tests/"
# Dict-style task with cmd
[tool.tasks.build]
cmd = "python -m build"
# Dict-style task with chain
[tool.tasks.full-test]
chain = ["test", "lint"]
# Python entry point (calls a function from a module)
[tool.tasks.version]
call = "mypackage:print_version"Execute shell commands directly:
[tool.tasks]
test = "pytest tests/"
build = "python -m build"Reference other tasks by name:
[tool.tasks]
test = "pytest tests/"
t = "test" # Alias for test taskRun multiple tasks in sequence. Stops on first failure:
[tool.tasks]
test = "pytest tests/"
lint = "ruff check ."
ci = ["test", "lint"]Call Python functions directly:
[tool.tasks.version]
call = "mypackage:print_version"
# Can also call class methods
[tool.tasks.run-server]
call = "mypackage.server:Server.start"The function/method should:
- Return an integer exit code (0 for success, non-zero for failure)
- Return
None(treated as success) - Access command-line arguments via
sys.argv
[tool.tasks]
# Development tasks
dev = "python -m myapp --dev"
test = "pytest tests/ -v"
lint = "ruff check ."
format = "ruff format ."
# Build tasks
clean = "rm -rf dist/ build/ *.egg-info"
build = "python -m build"
# Task chains
check = ["lint", "test"]
ci = ["check", "build"]
# Python entry points
[tool.tasks.version]
call = "myapp:print_version"# Run tests
task test
# Run CI pipeline (lint + test + build)
task ci
# Run development server
task dev
# Check version
task version- Python 3.11 or higher (for
tomllibfrom standard library)
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/
# Run tests with coverage
pytest tests/ --cov=src/tool_tasks --cov-report=term-missingSee LICENSE file for details.