Some formatting rules are only active in preview mode, so `ruff server --preview` (used by the LSP in your editor) and `ruff format` (used by `pre-commit`) can silently produce different output for the same file.

One example is `hug_parens_with_braces_and_square_brackets`: it is enabled by default under `--preview` but off in stable `ruff format`. The editor reformats the file one way; the pre-commit hook then rejects it.

The quickest fix while waiting for a rule to stabilise is to disable `--preview` in the editor config, or explicitly opt-out of the offending rule in `ruff.toml`:

```toml
[format]
preview = false
```

If you do want preview everywhere, pass `--preview` to the `ruff format` hook as well so both sides agree.

<p class="til-source"><a href="https://x.com/alvarobartt/status/2008831087041269814">Find the original post on X</a></p>
