Liking cljdoc? Tell your friends :D

com.blockether.ruff

Clojure binding to ruff (https://github.com/astral-sh/ruff) for Python code FORMATTING and LINTING, through the JDK Foreign Function & Memory API.

ruff does not publish a C-ABI library — only a CLI. So this binds a tiny first-party cdylib, ruff-c (native/ruff-c, a thin extern "C" wrapper over ruff's ruff_python_formatter + ruff_linter crates), exactly the way clj-fff binds fff-c. Both run IN-PROCESS via a downcall — no subprocess, no CLI. format takes Python source and returns it reformatted (long calls/collections wrapped multiline, black-compatible style); lint returns ruff's diagnostics as plain Clojure maps.

Ruff CONFIGURATION FILES are first class: config-file finds the nearest .ruff.toml / ruff.toml / pyproject.toml with [tool.ruff] exactly the way the CLI does, and passing it as :config makes format/lint honour that file's real options (select/ignore, line-length, target-version, preview, [format] quote/indent/line-ending/docstring settings, extend chains). Discovery is never implicit: no :config, no file lookup.

Run the JVM with --enable-native-access=ALL-UNNAMED so the foreign linker may load the library without a restricted-method warning.

The library is resolved ONCE, lazily, the first time it's needed:

  1. RUFF_NATIVE_PATH env / com.blockether.ruff.native.path system property — an explicit path to the cdylib (used verbatim).
  2. A bundled classpath resource prebuilds/<platform>/<lib>, shipped by com.blockether/ruff-native-<platform> (extracted to the cache dir). This is the native-image path.
  3. A runtime download: the ruff-native-<platform> jar resolved through clojure.tools.deps (honouring Maven repos/mirrors/settings.xml), extracted + cached. Disable with RUFF_DISABLE_DOWNLOAD=1.

<platform> ∈ { linux-x64 linux-arm64 darwin-arm64 darwin-x64 windows-x64 }.

Clojure binding to ruff (https://github.com/astral-sh/ruff) for Python code
FORMATTING and LINTING, through the JDK Foreign Function & Memory API.

ruff does not publish a C-ABI library — only a CLI. So this binds a tiny
first-party cdylib, `ruff-c` (native/ruff-c, a thin `extern "C"` wrapper over
ruff's `ruff_python_formatter` + `ruff_linter` crates), exactly the way
clj-fff binds `fff-c`. Both run IN-PROCESS via a downcall — no subprocess, no
CLI. `format` takes Python source and returns it reformatted (long
calls/collections wrapped multiline, black-compatible style); `lint` returns
ruff's diagnostics as plain Clojure maps.

Ruff CONFIGURATION FILES are first class: `config-file` finds the nearest
`.ruff.toml` / `ruff.toml` / `pyproject.toml` with `[tool.ruff]` exactly the
way the CLI does, and passing it as `:config` makes `format`/`lint` honour
that file's real options (`select`/`ignore`, `line-length`, `target-version`,
`preview`, `[format]` quote/indent/line-ending/docstring settings, `extend`
chains). Discovery is never implicit: no `:config`, no file lookup.

Run the JVM with `--enable-native-access=ALL-UNNAMED` so the foreign linker
may load the library without a restricted-method warning.

The library is resolved ONCE, lazily, the first time it's needed:
  1. RUFF_NATIVE_PATH env / `com.blockether.ruff.native.path` system property
     — an explicit path to the cdylib (used verbatim).
  2. A bundled classpath resource `prebuilds/<platform>/<lib>`, shipped by
     `com.blockether/ruff-native-<platform>` (extracted to the cache dir).
     This is the native-image path.
  3. A runtime download: the `ruff-native-<platform>` jar resolved through
     `clojure.tools.deps` (honouring Maven repos/mirrors/settings.xml),
     extracted + cached. Disable with RUFF_DISABLE_DOWNLOAD=1.

`<platform>` ∈ { linux-x64 linux-arm64 darwin-arm64 darwin-x64 windows-x64 }.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close