Skip to content

Pylance "Organize Imports" overrides isort force_single_line #7937

@wesleybl

Description

@wesleybl

Environment data

  • Pylance version: 2026.1.1
  • OS and version: Linux (Ubuntu)
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.13

Code Snippet

# pyproject.toml (isort config):
# [tool.isort]
# profile = "black"
# force_single_line = true

from setuptools import setup
from setuptools import find_packages

Repro Steps

  1. Configure isort with force_single_line = true in pyproject.toml or .isort.cfg.
  2. Install the ms-python.isort extension.
  3. Add "source.organizeImports": "explicit" to editor.codeActionsOnSave in settings.json.
  4. Open a Python file with imports from the same module on separate lines (as above).
  5. Save the file.

Expected behavior

Pylance should respect the isort configuration (force_single_line = true) and keep imports from the same module on separate lines, or at minimum not run its own organize imports after isort has already sorted them:

from setuptools import find_packages
from setuptools import setup

Actual behavior

Pylance runs its own "Organize Imports" implementation after isort, overwriting isort's result and merging imports from the same module into a single line:

from setuptools import find_packages, setup

This happens because both the ms-python.isort extension and Pylance respond to the same source.organizeImports code action kind, and Pylance always runs last, discarding the isort output.

There is currently no setting in Pylance to disable only its organize imports behavior while keeping other features active. The only workarounds are:

Setting "source.organizeImports": "never", which also disables the isort extension's action on save
Using a custom formatter wrapper that chains Black + isort, bypassing source.organizeImports entirely
Pylance should either:

Detect that another provider (isort) is registered for source.organizeImports and defer to it, or
Provide a setting like "pylance.organizeImports": false to allow users to opt out of Pylance's implementation independently

Logs

N/A

Metadata

Metadata

Assignees

Labels

ai-triage-respondedIndicate whether the AI triage agent has responded to this issue.team needs to reproduceIssue has not been reproduced yet

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions