ruff-pycharm-plugin
ruff-pycharm-plugin copied to clipboard
(🎁) "organize imports" integration
the vscode extension has options/commands for:
- organize imports on save
- fix all on save
- a fix all command
- format code
I think that it would be beneficial if this plugin had a separate "organise imports" option like the vscode extensions does.
See com.intellij.lang.ImportOptimizer
Funding
- You can sponsor this specific effort via a Polar.sh pledge below
- We receive the pledge once the issue is completed & verified
This would be awesome.
My current work around is to run
$PyInterpreterDirectory$/python -m ruff check --select I --fix $FilePath$
as part of a File Watcher
- https://github.com/johnthagen/python-blueprint#import-sorting
Having this be a simple option to "sort imports on save" built into the plugin would be save a lot of manual configuration for each user.
Isn't this already possible? For me the following combination of options achieves this:
Run ruff when the python file is savedUse ruff format (Experimental) for version 0.0.289 or later- Enabling auto-fixing imports in the projects'
pyproject.tomlfile:[tool.ruff.lint] select = ['I'] # add more rules here as desired fixable = ['I'] # add more rules here as desired
@urob that would lead to fixing everything, which is not desirable.
@urob that would lead to fixing everything, which is not desirable.
Not sure I follow. The I rules are just for organizing the imports. You could be even more specific and only specify I001.
I'm using something very similar to this and there aren't any additional linter fixes that are automatically applied for me.
Oh right, yeah, read that backwards.
Your solution would lead to nothing else being fixed, which is not desirable.
@koxudaxi Did you complete this issue in
- #570