-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong sorting of imports #422
Comments
I had this issue when using It seemed that somehow the lsp was not picking up (some of) the options which I set in my I had the following packages installed (managed by Poetry):
Perhaps this could give a starting point for fixing this bug. |
Thanks. As to my setup, ruff-lsp is not used. |
I'm also seeing this behaviour. @hexvolt Did you find a workaround? |
@TimChild Nope, unfortunately I have to live with yellow warning around every import block:( To me, this is clearly a pretty major bug, idk why it is not labeled as such yet |
Happens to me as well. Since my imports are now always out of order, I always have to use the command line as well to fix it before I commit any files :( |
disabling ruff-lsp option eliminated the massive warning block (thanks @jellehierck). it still organizes on save, so I can make do with that for now. |
Same issue here, saving/reformatting files changes the import order. Currently I'm just running a tiny script that does a Environments (please complete the following information): |
For me and my team this bug is currently most annoying because we have to reformat the files with the command line, and can not solely rely on the IntelliJ plugin :( |
@cm253 I feel your pain. It's a shame @JetBrains haven't implemented their own solution, they seem to have some half-assed integration of ruff, but the way everything works together is we have the entire project flooded with warnings just because of the bug in the imports check. I'm considering disabling code check tools altogether since there is no proper integration with ruff, and I need to use CLI anyway. The fact such a fundamental feature of IDE still does not work properly after ruff being around for 2 years is such a shame. |
I wonder if this format support is managed with LSP? If yes the problem comes from the ruff language server or from LSP4IJ. If it comes from LSP4IJ I could investigate the problem. |
The problem is that the plugin wrongly re-orders imports, the highlighting and detection of the errors is done correctly at all times. |
Ok thanks for your feedback, I though it was a problem from LSP4IJ and in this case I though I could investigate the problem. |
At least that's the case for me, other users might have a slightly different issue. |
@jeroenbrouwer no, for me that's not the case unfortunately, please see the screenshots ^
Correctly sorted imports are wrongly highlighted, until I disable the plugin altogether. |
Then there seem to be multiple issues related to the ordering of imports, hopefully they can all be fixed 🤞 |
Also not for me. I'm using IntelliJ 2024.2.1. |
Same issue here - everything formats + sorts correctly until you specify a config file, at which point the import order is incorrectly ordered when reformatted |
To still get the benefits of ruff integration but disabling the incorrect import checking / fix, create a seperate config file e.g. ruff_pycharm.toml that excludes (or doesn't include) It doesn't fix the problem but it makes it more pleasing visually without the nag on the imports section. Use ruff pre-commit to fix the imports. |
Describe the bug
The sorting of imports is not consistent with ruff CLI output.
The plugin is awesome but when it is enabled, it highlights the imports that are sorted properly by categories. If I reformat the code using the plugin, it rearranges the imports in some weird order (3rd party packages being mixed with the local code packages), which is totally different from what
ruff check --select I --fix
does. So if sort imports properly with the external commandruff check --select I --fix
, then the plugin complains on my imports and tries to rearrange them back.So in order to use the plugin I have to either cope with seeing yellow highlights on all (properly sorted) imports, or give up proper sorting and let plugin do the weird sorting.
To Reproduce
Steps to reproduce the behavior:
ruff check --select I --fix
Expected behavior
The plugin should yield the same results of imports sorting as the official ruff command
ruff check --select I --fix
.Screenshots
You can see how imports sorted properly by the
ruff check --select I --fix
command are highlighted by the plugin with yellow, while it shouldn't.And this is the order plugin thinks is correct but it's not.
Environments (please complete the following information):
Notes:
UPDATE
Noteworthy is that if I remove the reference to the pyproject.toml file in the plugin settings, it does sorting correctly. But in that case it ignores all other settings like line length etc.
The text was updated successfully, but these errors were encountered: