Open KotlinIsland opened 4 months ago
If you are fine with disabling autofixing imports all together, then adding the following to your pyproject.toml
will do:
[tool.ruff.lint]
select = ['I'] # warn about unsorted imports
unfixable = ['I'] # but never fix them
The problem with that solution is that it also prevents you from manually triggering the sort via the context actions inside the IDE (c.f., #249 for a proposal that would fix this).
@urob I
don't cover unused import: https://docs.astral.sh/ruff/rules/unused-import/
Unfortunately, I do want unused imports to be removed, and I find it extremely valuable. But removing them on save is a nightmare, so your solution isn't relevant to me.
@urob
I
don't cover unused import: https://docs.astral.sh/ruff/rules/unused-import/Unfortunately, I do want unused imports to be removed, and I find it extremely valuable. But removing them on save is a nightmare, so your solution isn't relevant to me.
Isn't that precisely the caveat mentioned at the end of my comment and what #249 seeks to fix?
Currently, when enabled, the plugin will run
format
andcheck --fix
on save, I wantformat
to run, but notcheck --fix
, or maybe I wantcheck --fix
but definitely not 'remove unused imports' (the absolute worst thing imaginable!)Desired
config options for:
format
on savecheck --fix
on saveAdditional