@codacy/tools-ruff-0
Table of Contents
Overview
Python linter using the Ruff binary. Ruff is an extremely fast Python linter written in Rust that implements rules from Flake8, isort, pyupgrade, and many other tools. Uses the CLI execution strategy.
| Property | Value |
|---|---|
| Tool ID | Ruff |
| Codacy UUID | aac6ad5e-093d-47c4-97ff-87f91d6128a2 |
| Strategy | CLI |
| Languages | Python |
| Binary | ruff |
| File patterns | **/*.py, **/*.pyi, **/*.ipynb |
| Pattern count | ~773 |
Updating patterns
# Re-fetch pattern metadata from the Codacy API
pnpm prefetch
# Commit the result
git add src/patterns.json
Pattern IDs follow the format Ruff_F401_unused-import, Ruff_E501_line-too-long, etc.
Updating the Ruff version
- Update
preferredVersioninsrc/adapter.ts - Run
pnpm prefetch— Ruff adds new rules frequently - Run
pnpm testto verify compatibility - If the major version changes, create a new adapter package (
ruff-1/)
Development
pnpm build # Build with tsup
pnpm test # Run tests (requires ruff in PATH or auto-install)
Notes for maintainers
-
Preset mappings (
src/pattern-mappings.json): prefixes are Ruff rule-code namespaces, so one short prefix covers a whole family.Ruff_ASYNC1(the checkpoint rules from flake8-async) is claimed bytrioandanyio— they implement the same cancellation model, so either is evidence;ASYNC2xx/ASYNC3xxstay universal because they flag blocking calls in anyasync def.Ruff_ICN001(conventional import aliases) is claimed by the six plotting/data libraries whose aliases it enforces.ICN002/ICN003stay universal: their banned-import lists are empty by default, so enabling them would add config that checks nothing. -
Ruff is a standalone Rust binary, downloaded from GitHub releases as a
.tar.gzarchive. -
Installation uses
downloadAndExtract()withstripComponents: 1because the archive wraps the binary in a directory (e.g.ruff-aarch64-apple-darwin/ruff). -
JSON output via
ruff check --output-format json. -
--exit-zeroensures exit code 0 even when findings exist. -
--no-cachedisables Ruff's file cache for reproducible results. -
When patterns are specified, a
ruff.tomlconfig withselect = [...]is generated. -
Config file search order:
.ruff.toml,ruff.toml,pyproject.toml. As in Ruff itself,pyproject.tomlonly counts when it has a[tool.ruff]table.