Skip to main content

format or run checks on files by running tools on them

Project description

toolbelt

Format or run checks on files by running tools on them

NOTE: This is a work in progress. Documentation is being updated to reflect the latest changes.

What Makes Toolbelt Natural

Toolbelt abstracts away the complexity of different tool behaviors into a unified interface. Once a tool is configured, developers don't need to remember:

  • Does this tool take directories or files?
  • Does it discover files itself or need them listed?
  • Does it edit in-place or output to stdout?
  • What are the right flags for this specific tool?

Instead, you just run tb check python or tb format yaml and toolbelt figures out how to orchestrate everything properly.

The Three Execution Modes

Toolbelt handles any file-processing tool through three fundamental approaches:

  • Discovery Mode: Tools like ruff check . or prettier --check . that naturally discover and process files based on their own logic
  • Per-file Mode: Tools that work best when given explicit file lists, where toolbelt discovers the files and passes them to the tool
  • File Rewriting: Tools that output formatted content that needs to be written back to files

This creates a seamless developer experience - toolbelt becomes the universal interface to all your development tools, and you don't have to context-switch between different tool syntaxes and behaviors.

Offline tools

  • pnpm dlx => env NPM_CONFIG_OFFLINE=true tb check prettier.
  • uvx => env UV_OFFLINE=1 tb check python.

Configuration Presets and Environment Variables

Toolbelt provides configuration presets that you can include and customize rather than writing tool configurations from scratch. This approach promotes reuse and consistency across projects.

Python Development Preset (python-dev.yaml)

The python-dev.yaml preset includes a coverage profile that runs pytest with coverage reporting. Instead of overriding the entire configuration, you can customize it using environment variables:

Coverage Environment Variables

  • TB_PROJECT_SOURCE (default: src) - Primary source directory to measure coverage for
  • TB_COVERAGE_TARGET (default: tests) - Directory containing test files to run
  • TB_COVERAGE_EXTRA_ARGS (default: empty) - Additional arguments to pass to pytest

Usage Examples

# Basic usage with defaults
tb check coverage
# Runs: pytest -v --tb=short --cov=src --cov-report=term-missing --cov-report=html:.coverage-files/htmlcov tests

# Cover a different source directory
TB_PROJECT_SOURCE=toolbelt tb check coverage
# Runs: pytest -v --tb=short --cov=toolbelt --cov-report=term-missing --cov-report=html:.coverage-files/htmlcov tests

# Add extra coverage directories and options
TB_COVERAGE_EXTRA_ARGS="--cov=tests --cov-fail-under=90 --cov-branch" tb check coverage
# Runs: pytest -v --tb=short --cov=src --cov=tests --cov-fail-under=90 --cov-branch --cov-report=term-missing --cov-report=html:.coverage-files/htmlcov tests

# Combine multiple customizations
TB_PROJECT_SOURCE=myapp TB_COVERAGE_TARGET=test_suite TB_COVERAGE_EXTRA_ARGS="--cov=scripts --cov-fail-under=80" tb check coverage

Dynamic Argument Expansion

The TB_COVERAGE_EXTRA_ARGS variable supports automatic argument splitting - if you provide multiple space-separated arguments, they will be properly split into separate command arguments:

# This single environment variable:
TB_COVERAGE_EXTRA_ARGS="--cov=lib --cov=scripts --cov-fail-under=85"

# Automatically becomes these separate arguments:
# --cov=lib --cov=scripts --cov-fail-under=85

This makes it easy to add multiple coverage directories, set thresholds, enable branch coverage, or add any other pytest/coverage options without needing to override the entire tool configuration.

Tab Completion (argcomplete)

Toolbelt supports tab completion for its CLI using argcomplete.

Bash / Zsh

Add this to your shell or .bashrc / .zshrc:

eval "$(register-python-argcomplete tb)"

After setup, you can use tab completion for all CLI options and arguments.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tbelt-0.0.3.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tbelt-0.0.3-py3-none-any.whl (40.5 kB view details)

Uploaded Python 3

File details

Details for the file tbelt-0.0.3.tar.gz.

File metadata

  • Download URL: tbelt-0.0.3.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.20

File hashes

Hashes for tbelt-0.0.3.tar.gz
Algorithm Hash digest
SHA256 cb46bfbcc181f411dcc6805fd6f331de2c21a7d3719b06ad33581d5d5aa371f5
MD5 7ebee907554eb481030594197131831e
BLAKE2b-256 dfd8f7aa880e1facb042f16ed30e79f1761f5bbbd94b3f576658ec3e6faae5b2

See more details on using hashes here.

File details

Details for the file tbelt-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: tbelt-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 40.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.20

File hashes

Hashes for tbelt-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 31fc482ee727be09b1fd2f185eaae9c102eb6bcf6c7be9979b6896fb71278e0c
MD5 6823a860169d5a47ebafbd8bd0a9d539
BLAKE2b-256 e78956b288c39c46748d07f1fe9804958bd72bd610d902ed318ccfbc3c9ba793

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page