Built-in sandbox SHIM: a ruff module (and vis python -m ruff CLI) for the
model's Python sandbox, backed by the SAME in-process ruff the Python
language pack's format_code/lint_code use — the com.blockether/ruff FFI
over a first-party cdylib. No pip, no ruff binary on PATH, and it survives
into the native image.
Two surfaces, one engine:
import ruff -> ruff.format_str(src), ruff.check_str(src),
ruff.format_file(path), ruff.check_file(path), ruff.config_for(path),
ruff.version().vis python -m ruff check|format [paths] -> the module's console_main
is the -m entry point (sandbox shims have no __file__, so runpy
cannot execute them; main-clj/python-module-runner-src calls
console_main(sys.argv[1:]) instead).Ruff's OWN configuration discovery is authoritative: for every file we ask
the host for the nearest .ruff.toml / ruff.toml / pyproject.toml with a
[tool.ruff] table, walking up from that file, and hand it back to ruff. A
tree with no configuration gets ruff's built-in defaults (E4, E7, E9, F,
line-length 88) — exactly what the real ruff CLI does — and check says so
on stderr so the user knows to add one.
Not supported (the FFI is a one-source-one-call linter/formatter, not the
whole CLI): --fix, --watch, --output-format, --show-settings, and
config exclude/extend-exclude walking (the shim's own walk skips the
usual noise directories instead). per-file-ignores DO apply — they are
matched by ruff itself against the path we pass.
Built-in sandbox SHIM: a `ruff` module (and `vis python -m ruff` CLI) for the
model's Python sandbox, backed by the SAME in-process ruff the Python
language pack's `format_code`/`lint_code` use — the `com.blockether/ruff` FFI
over a first-party cdylib. No pip, no `ruff` binary on PATH, and it survives
into the native image.
Two surfaces, one engine:
- `import ruff` -> `ruff.format_str(src)`, `ruff.check_str(src)`,
`ruff.format_file(path)`, `ruff.check_file(path)`, `ruff.config_for(path)`,
`ruff.version()`.
- `vis python -m ruff check|format [paths]` -> the module's `console_main`
is the `-m` entry point (sandbox shims have no `__file__`, so `runpy`
cannot execute them; `main-clj/python-module-runner-src` calls
`console_main(sys.argv[1:])` instead).
Ruff's OWN configuration discovery is authoritative: for every file we ask
the host for the nearest `.ruff.toml` / `ruff.toml` / `pyproject.toml` with a
`[tool.ruff]` table, walking up from that file, and hand it back to ruff. A
tree with no configuration gets ruff's built-in defaults (E4, E7, E9, F,
line-length 88) — exactly what the real `ruff` CLI does — and `check` says so
on stderr so the user knows to add one.
Not supported (the FFI is a one-source-one-call linter/formatter, not the
whole CLI): `--fix`, `--watch`, `--output-format`, `--show-settings`, and
config `exclude`/`extend-exclude` walking (the shim's own walk skips the
usual noise directories instead). `per-file-ignores` DO apply — they are
matched by ruff itself against the path we pass.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |