Skip to content

ruff server first-party libraries get categorized as third-party #11214

@bluthej

Description

@bluthej

Keywords: I001, Organize imports, first-party

Ruff version : 0.4.2

If I'm not mistaken, ruff server currently treats first-party libraries like they're third-party libraries, which is not the case for ruff-lsp.

Here is a minimal setup to reproduce this:

  • Create a new project with the following layout:
.
├── pyproject.toml
└── src
     └── hello_world
         ├── __init__.py
         ├── module.py
         └── other_module.py

with these contents:

pyproject.toml

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "hello-world"
version = "0.0.1"
dependencies = [
  "numpy"
]

[tool.ruff]
lint.extend-select = ["I"]

module.py

hello = "hello world"

other_module.py

from pathlib import Path

from numpy.linalg import norm

from hello_world.module import hello

  • Then run ruff-lsp in an editor => this should not lint the import order, just like doing ruff check . doesn't say anything about import order
  • Then run ruff server in an editor => now there should be an Organize import lint, and if you apply it, it should bring the hello_world import just above the numpy import, which is not the expected behavior

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingserverRelated to the LSP server

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions