astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
32.7k stars 1.09k forks source link

Consider `unsafe-fixes` config value for code action / command #13960

Open BarrensZeppelin opened 2 weeks ago

BarrensZeppelin commented 2 weeks ago

It would be nice to be able to configure the ruff server to also apply unsafe fixes with the ruff.applyAutoFix command and source.fixAll.ruff code action.

MichaReiser commented 2 weeks ago

Hi @BarrensZeppelin

Have you tried https://docs.astral.sh/ruff/settings/#unsafe-fixes and/or https://docs.astral.sh/ruff/settings/#lint_extend-safe-fixes?

BarrensZeppelin commented 2 weeks ago

Unsafe fixes are explicitly disabled here: https://github.com/astral-sh/ruff/blob/9f3a38d408f473df7a6b3574c5d1389bef303dd5/crates/ruff_server/src/fix.rs#L74

But I guess extend-safe-fixes could be a work-around. :thinking:

MichaReiser commented 2 weeks ago

Hmm, good call. I think we should respect the configuration here rather than just outright disabling it.