Skip to content

Latest commit

 

History

History
44 lines (36 loc) · 1.16 KB

isort.md

File metadata and controls

44 lines (36 loc) · 1.16 KB
tags aliases cssclass
💽
isort

[[isort]]


Setting up auto import sorting in VSCode

Stack Overflow Solution

  1. First, pip install isort & install isort from VSCode extensions
  2. Then, to make isort compatible with black, create a pyproject.toml file at the root of your repo.
  3. Add the following to this file:
    [tool.isort]
    multi_line_output = 3
    include_trailing_comma = true
    force_grid_wrap = 0
    line_length = 88
    profile = "black"
  4. Edit /.vscode/settings.json and configure black and isort by adding:
{
   "[python]": {
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
       }
     },

   "python.formatting.provider": "black",
   "isort.args": ["--profile", "black"],
}
  1. source.organizeImports: true runs isort automatically upon saving document.

🔗 Links to this page: [[Python]]