astral-sh / ruff-vscode

A Visual Studio Code extension with support for the Ruff linter.
Other
1.06k stars 53 forks source link

organizeImports buggy in vscode #382

Closed HenrikZabel closed 8 months ago

HenrikZabel commented 8 months ago

When using "editor.codeActionsOnSave": { "source.organizeImports": true } my whole code jumps in vscode.

Python version: 3.11.4 Ruff version: v2024.0.0 OS: Windows 10 Home

zanieb commented 8 months ago

@HenrikZabel could you provide a bit more detail about the behavior you're seeing and the behavior you'd prefer?

charliermarsh commented 8 months ago

Closing for now, can always re-open if we receive more info.

HenrikZabel commented 8 months ago

I am sorry for the delay:

Basically, the whole code always "jumps" when I save my file. It seems that Ruff needs a relatively long time to sort the imports. Also, the imports are sorted when I save once and then when I save again, all the imports are totally mixed up. Especially when I have many imports from a library, I notice that Ruff takes a relatively long time. Example:

from .serializers import (
    AccountSerializer,
    EmailSerializer,
    NameSerializer,
    RegistrationSerializer,
    UsernameSerializer,
)

If I then immediately save the file again, it looks like this:

from .serializers import (AccountSerializer, EmailSerializer, NameSerializer, RegistrationSerializer, UsernameSerializer)
charliermarsh commented 8 months ago

Is it possible that you have some other extension that's interfering? Ruff wouldn't sort imports in that style, it doesn't even support it.

HenrikZabel commented 8 months ago

I completely reinstalled Python and now the problem is gone. So I think the problem was actually not with Ruff, but with something else. I apologize

charliermarsh commented 8 months ago

Oh that's great!