Skip to content

isort not honoring setup.cfg #5840

Description

Environment data

  • VS Code version: 1.34.0
  • Extension version (available under the Extensions sidebar): 2019.5.17059 (28 May 2019)
  • OS and version: macOS 10.14.4
  • Python version: 3.6.7 (miniconda)

Issue

I added

  "editor.codeActionsOnSave": { "source.organizeImports": true }

to my user settings to sort imports with isort. I'm also using black as a code formatter. On multiline imports these two tools format imports very differently, leading to alternating formatting and jumping code from one save to the next as shown in this gif.

back-vs-isort

I was able to prevent this by configuring isort to use black's formatting by adding

[isort]
multi_line_output = 3
include_trailing_comma = True

to my setup.cfg as indicated in the comments of this black commit.

Now, the file is stable if I repeatedly save it without changes in between. But if I modify the file and then save, the imports briefly flash to isort formatting before reverting to black formatting. So unlike before, the final result is now always black formatting but there's jumping code every time I modify and save.

This seems to suggest that isort is still being run by VS Code with its default settings when the formatOnSave callbacks are triggered. Is there any way to respect the setup.cfg settings in the isort callback?

Additional Info

Related Issue: #2301

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions