koxudaxi / ruff-pycharm-plugin

PyCharm plugin for ruff. This plugin provides reformat code using ruff.
MIT License
174 stars 7 forks source link

(🎁) Config options for specifying what gets run 'on save' #386

Open KotlinIsland opened 4 months ago

KotlinIsland commented 4 months ago

Currently, when enabled, the plugin will run format and check --fix on save, I want format to run, but not check --fix, or maybe I want check --fix but definitely not 'remove unused imports' (the absolute worst thing imaginable!)

Desired

config options for:

Additional

urob commented 1 month 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).

KotlinIsland commented 1 month ago

@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 commented 1 month ago

@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?