Change8

0.12.0

Breaking Changes
📦 ruffView on GitHub →
4 breaking2 features🐛 10 fixes1 deprecations🔧 12 symbols

Summary

Ruff 0.12.0 introduces stricter syntax‑error detection, updates f‑string handling, drops the `rust-toolchain.toml` from distributions, deprecates the pandas‑df‑variable‑name rule, adds preview checks for pytest helpers, and includes numerous bug fixes.

⚠️ Breaking Changes

  • Ruff now detects version‑related syntax errors (e.g., use of `match` on Python <3.10 and irrefutable `match` patterns before the final `case` arm), which can cause new lint errors in code that previously passed.
  • The default Python version for syntax‑error detection is now the latest supported version (3.13) instead of the minimum supported version (3.9); projects without an explicit Python version may see different diagnostics.
  • Multi‑line f‑strings with format specifiers are now formatted without inserting a line break after the specifier to comply with Python 3.13.4 grammar changes.
  • `rust-toolchain.toml` is no longer included in source distributions, which may affect downstream builds that relied on it.

Migration Steps

  1. Read the migration guide in the blog post https://astral.sh/blog/ruff-v0.12.0.
  2. If your project does not specify a Python version, add a `--target-version` or `pyproject.toml` setting to lock the version you want, as Ruff now defaults to Python 3.13 for syntax‑error detection.
  3. Review any custom `include`, `ignore`, or `noqa` settings for rule `UP045` (formerly part of `UP007`) and adjust them if necessary.
  4. If you relied on `rust-toolchain.toml` being present in the source distribution, remove it from your package or provide your own Rust toolchain configuration.
  5. Update any CI or build scripts that expected the `rust-toolchain.toml` file to be installed automatically.

✨ New Features

  • Preview feature: Ruff can now check for non‑context‑manager use of `pytest.raises`, `pytest.warns`, and `pytest.deprecated_call` (rule `RUF061`).
  • Preview feature: Ruff raises an unsupported syntax error for template strings prior to Python 3.14.

🐛 Bug Fixes

  • Add syntax error when conversion flag does not immediately follow exclamation mark.
  • Add trailing space around `readlines`.
  • Fix `\r` and `\r\n` handling in t- and f-string debug texts.
  • Hug closing `}` when f-string expression has a format specifier.
  • `flake8-pyi`: Avoid syntax error in the case of starred and keyword arguments (`PYI059`).
  • `flake8-return`: Fix `RET504` autofix generating a syntax error.
  • `pep8-naming`: Suppress fix for `N804` and `N805` if the recommended name is already used.
  • `pycodestyle`: Avoid causing a syntax error in expressions spanning multiple lines (`E731`).
  • `pyupgrade`: Suppress `UP008` if `super` is shadowed.
  • `refurb`: Parenthesize lambda and ternary expressions (`FURB122`, `FURB142`).

🔧 Affected Symbols

RUF005FURB129SIM108RUF100S603FBT001UP007UP045S320RUF061syntax-errorsrust-toolchain.toml

⚡ Deprecations

  • Rule `pandas-df-variable-name` is deprecated.