ruff-pycharm-plugin
ruff-pycharm-plugin copied to clipboard
Allow specific ignore during --fix
Is your feature request related to a problem? Please describe.
I tend to press "reformat" a lot out of habit and sometimes I've written a line where I create a new variable but haven't used it yet. ruff --fix removes that variable (rule F841):
x = fun()
gets turned into
fun()
Describe the solution you'd like
I would like to disable the rule responsible for this (F841), but keep it on the cli where I want to run ruff via pre-commit which should remove any unused code/variables. E.g. by running it via ruff check --fix --unfixable F841.
Describe alternatives you've considered
Not running ruff on reformat. Add another config in the project which has these rules disabled and configure this in the editor config.
I have a similar use case. My primary use of ruff in PyCharm is the formatter and while I have many linter options enabled in the config, I don't want them to be applied while developing. E.g. I uncomment parts of the code just as an experiment and press Ctrl+Alt+L to format the code, but I don't want ruff to remove unused imports as I will need them again in a second. When I want to remove unused imports, I use Optimize imports Ctrl+Alt+O.
My suggestion is to add another option to the plugin to allow passing any cmd line option to ruff. In my case I would put --ignore I and it would solve all my needs.