ruff icon indicating copy to clipboard operation
ruff copied to clipboard

Read user configuration from `~/.config/ruff/ruff.toml` on macOS

Open charliermarsh opened this issue 1 year ago • 3 comments
trafficstars

Summary

This PR moves Ruff's user-specific configuration from ~/Library/Application Support/ruff/ruff.toml to ~/.config/ruff/ruff.toml.

Many other tools do this. On my machine alone: dagger, zed, gatsby, gh, wandb, etc.

I also polled Twitter and it won in a landslide:

Screenshot 2024-04-23 at 4 07 19 PM

Let's ship this in v0.5.0, along with a deprecation warning (so we'll continue to respect ~/Library/Application Support/ruff/ruff.toml, but log a warning).

Closes https://github.com/astral-sh/ruff/issues/10739.

Test Plan

  • Created a file with an unused import.
  • Ran cargo check foo.py.
  • Verified that the deprecated configuration was loaded and respected, with a warning:
warning: Reading configuration from `~/Library/Application Support` is deprecated. Please move your configuration to `/Users/crmarsh/.config/ruff/ruff/ruff.toml`.
[2024-04-23][16:09:10][ruff::resolve][DEBUG] Using configuration file (via cwd) at: /Users/crmarsh/Library/Application Support/ruff/ruff.toml
  • Created ~/.config/ruff/ruff.toml.
  • Verified that the new configuration was loaded:
[2024-04-23][16:10:23][ruff::resolve][DEBUG] Using configuration file (via cwd) at: /Users/crmarsh/.config/ruff/ruff.toml

charliermarsh avatar Apr 23 '24 20:04 charliermarsh

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

github-actions[bot] avatar Apr 23 '24 20:04 github-actions[bot]

Sooo, we're doing twitter driven development now :joy:

MichaReiser avatar Apr 24 '24 07:04 MichaReiser

I would change the reasoning/description: Follow the XDG specification on all Unix platforms. Ruff will now use the XDG config directory to read user-level configuration (default: ~/.config/ruff/ruff.toml) over Library/Application Support/ruff/ruff.toml on macOS.

konstin avatar Apr 24 '24 11:04 konstin

CodSpeed Performance Report

Merging #11115 will degrade performances by 4.69%

Comparing charlie/xdg (c4d143a) with ruff-0.5 (9348821)

Summary

❌ 1 regressions ✅ 29 untouched benchmarks

:warning: Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark ruff-0.5 charlie/xdg Change
linter/default-rules[pydantic/types.py] 1.8 ms 1.9 ms -4.69%

codspeed-hq[bot] avatar Jun 24 '24 12:06 codspeed-hq[bot]

I ran through the test plan and verified the deprecation message.

MichaReiser avatar Jun 24 '24 13:06 MichaReiser