-
Notifications
You must be signed in to change notification settings - Fork 1k
Pylance "Organize Imports" overrides isort force_single_line #7937
Description
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_packagesRepro Steps
- Configure isort with force_single_line = true in
pyproject.tomlor.isort.cfg. - Install the
ms-python.isort extension. - Add
"source.organizeImports": "explicit"to editor.codeActionsOnSave insettings.json. - Open a Python file with imports from the same module on separate lines (as above).
- 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 setupActual 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, setupThis 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