koxudaxi/ruff-pycharm-plugin

quick-fix for un-sorted imports not working

HansAarneLiblik opened this issue ยท 5 comments

Re-posted from ruff github:

I'm seeing an issue with ruff and quick-fixes it offers to Intellij

I have the following file

from typing import assert_type, assert_never


if __name__ == '__main__':
    assert_never("test")
    assert_type(123, int)

and ruff complains about imports

image

When I click organize imports, it breaks the code

ffrom typing import assert_never, assert_type

f __name__ == '__main__':
    assert_never("test")
    assert_type(123, int)

Executing the fix from command line works ruff . --fix

My config from pyproject.toml

[tool.isort]
profile = "black"
line_length = 120
filter_files = true


[tool.ruff]
line-length = 120
target-version = "py310"
select = [
  "E",    # pycodestyle
  "W",    # pycodestyle
  "F",    # pyflakes
  "I",    # isort
  "C4",   # flake8-comprehensions
  "TID",  # flake8-tidy-imports
]
  • IDE: PyCharm 2023.1.2
  • OS: Mac OS 13.2.1
  • Ruff version: 0.0.269
  • Plugin version: 0.0.4

@koxudaxi - Sorry for the churn, we changed the edit columns to be one-based rather than zero-based, which is probably the cause of this discrepancy. Here's the relevant PR in the LSP: astral-sh/ruff-lsp#103.

Multiple team members noticed this at work as well. Glad it looks to be a simple fix!

I'm Sorry for my slow action.
I have released the fxied version as 0.0.16
We should wait for approval from JetBrains. After that, it will be published in the JetBrains Market.
https://plugins.jetbrains.com/plugin/20574-ruff/versions/stable/339105

There are binaries on the page. We can install it manually before will be published in the JetBrains Market.
https://github.com/koxudaxi/ruff-pycharm-plugin/releases/tag/v0.0.16
https://www.jetbrains.com/help/idea/managing-plugins.html#install_plugin_from_disk

It's approved.
We can install the fixed version 0.0.16 from JetBrains Market.

Works perfectly. Thank you !