Skip to content

ruff format doesn't sort imports, leaves file unchanged #8926

@alexei

Description

@alexei

I'm looking into using ruff (0.1.6 on Python 3.12) for formatting and... it doesn't appear to be doing anything, at least in terms of replicating isort behaviour.

Input

from _common import foo
import dataclasses as dc
import psycopg
from typing import Any
import hashlib
from foo.bar import baz
from functools import partial
from time import monotonic
from enum import Enum, auto
from uuid import UUID

Command

$ python -m ruff format -v ./test_ruff.py
[2023-11-30][15:29:28][ruff_cli::resolve][DEBUG] Using Ruff default settings
[2023-11-30][15:29:28][ruff_cli::commands::format][DEBUG] format_path; path=.../test_ruff.py
[2023-11-30][15:29:28][tracing::span][DEBUG] Printer::print;
[2023-11-30][15:29:28][ruff_cli::commands::format][DEBUG] Formatted 1 files in 191.92µs
1 file left unchanged

Expected result

import dataclasses as dc
from enum import Enum, auto
from functools import partial
import hashlib
from time import monotonic
from typing import Any
from uuid import UUID

import psycopg

from _common import foo
from foo.bar import baz

Or something like that.

Actual result

The file is unchanged.


What am I missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionAsking for support or clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions