LinuxCommandLibrary

ruff-format

Format Python code with Ruff

TLDR

Format current directory

$ ruff format
copy
Format specific files
$ ruff format [file.py]
copy
Check formatting without changes
$ ruff format --check
copy
Show diff
$ ruff format --diff
copy

SYNOPSIS

ruff format [options] [files...]

DESCRIPTION

ruff format is the code formatting subcommand of Ruff, providing a Black-compatible Python formatter written in Rust. It enforces consistent code style by reformatting Python source files according to opinionated rules covering indentation, line length, string quoting, and whitespace.
The --check flag validates formatting without modifying files, returning a non-zero exit code if changes would be made, which is useful for CI pipelines. The --diff flag displays the exact changes that would be applied. Configuration options like --line-length can be set per-project in pyproject.toml or ruff.toml.

PARAMETERS

--check

Check without modifying.
--diff
Show formatting diff.
--config file
Configuration file.
--line-length n
Maximum line length.

SEE ALSO

ruff(1), ruff-check(1), black(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community