Skip to content
Latchkey

ruff check: Lint Python Code in CI

ruff check runs the linter over the given paths and reports any rule violations it finds.

check is the linting entry point. In CI its exit code is what gates the job: zero when clean, non-zero when violations remain.

What it does

ruff check lints the files or directories you pass (default the current directory) against the enabled rule set and prints each violation as path:line:col code message. It exits 1 if any violations remain after fixes, 0 if the code is clean, and 2 on an internal error or bad configuration.

Common usage

Terminal
ruff check .
ruff check src tests
ruff check src/app.py
# show what would be flagged without changing files
ruff check --no-fix .

Flags

FlagWhat it does
<paths>Files or directories to lint (default: current directory)
--fixApply safe automatic fixes
--no-fixReport only, never modify files
--select <codes>Enable specific rules or prefixes
--ignore <codes>Disable specific rules
--quietSuppress the summary line
--exit-zeroAlways exit 0 regardless of violations

In CI

Run ruff check . as its own step before tests so lint failures surface fast. The default exit code is exactly what you want: a non-zero exit fails the GitHub Actions step. Do not add --exit-zero unless you specifically want a non-blocking informational run.

Common errors in CI

A job failing with "Found N errors" and exit code 1 means real violations remain; read the codes and fix or ignore them. Exit code 2 with "Failed to parse" points at a syntax error in a file or a malformed pyproject.toml/ruff.toml, not a lint rule. "ruff: command not found" means Ruff is not installed in the runner environment.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →