snakefmt
Opinionated code formatter for Snakemake workflow files
TLDR
SYNOPSIS
snakefmt [--check] [--diff] [-l length] [options] files
DESCRIPTION
snakefmt is an opinionated code formatter for Snakemake workflow files. It enforces a consistent style across Snakefiles and associated rules files, handling both standard Python syntax and Snakemake-specific extensions like rule, checkpoint, and module blocks.The formatter is built on top of Python's black formatter, using the same default line length of 88 characters and similar formatting philosophy. It understands Snakemake's domain-specific syntax, correctly formatting rule parameters like input, output, params, and shell while preserving semantic meaning.Check mode (--check) verifies formatting without modifying files, returning a non-zero exit code if changes are needed, which is useful for CI pipelines. Diff mode (--diff) previews the exact changes that would be made before committing to them.
PARAMETERS
--check
Check only, no changes.--diff
Show changes.-l, --line-length N
Max line length.-v, --verbose
Verbose output.--include PATTERN
Regular expression for files to include when formatting directories.--exclude PATTERN
Regular expression for files to exclude when formatting directories.--config FILE
Read configuration from a pyproject.toml or .editorconfig file.-
Read from stdin.
CAVEATS
Snakemake-specific and not suitable for general Python files. Uses the same default line length (88) as black. Configuration can be set in pyproject.toml. May not handle all custom Snakemake wrappers or heavily templated rules gracefully.
HISTORY
snakefmt was created for the Snakemake workflow management system. It brings consistent formatting to bioinformatics pipelines.
