question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

isort randomly ignores its configuration from setup.cfg

See original GitHub issue

Environment data

  • VS Code version: 1.28.2 / 7f3ce96ff4729c91352ae6def877e59c561f4850 / x64
  • Extension version (available under the Extensions sidebar): 2018.10.1
  • OS and version: GNU/Linux Fedora 29 Linux 4.18.17-300.fc29.x86_64
  • Python version (& distribution if applicable, e.g. Anaconda): Python 2.7.15 (Also Python 3.7.1)
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): pipenv, version 2018.10.13, with Python 3.6.6
  • Relevant/affected Python packages and their versions: Builtin isort

Actual behavior

Isort configuration is defined in the [isort] section of the setup.cfg file in the root dir of one of folders in the workspace.

Using “Organize imports” sometimes, most notably after fresh VS Code start, acts like there is no configuration provided in the setup.cfg file. After some time, usually dozens of minutes, “Organize imports” starts to work properly.

Expected behavior

“Organize imports” should always obey the configuration provided in the setup.cfg file.

Steps to reproduce:

  1. Start VS Code with workspace automatically loaded.
  2. Open *.py file from the folder having setup.cfg with [isort] section.
  3. Type some code altering import statements in a way expected to be corrected by isort differently with and without custom configuration, i.e. provide a custom value for line_length and/or lines_after_imports options.
  4. Invoke “Organize imports”

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

No output

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

No output

Edit: see updates below

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
phwhcommented, Nov 12, 2018

I have the same issue. I tried passing the --settings-path argument to isort via the projects’ workspace settings and it seems to be working more reliable now.

"python.sortImports.args": [
        "--settings-path=/Users/..."
]

Of course this is only a workaround.

0reactions
DonJayamannecommented, Nov 12, 2018

that’s unclear that this is the actual intent at the moment.

That’s why the issue is open. We need to make a decision.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration options for isort
Too busy to build your perfect isort configuration? ... Treat project as a git repository and ignore files listed in .gitignore. NOTE: This...
Read more >
Imports are incorrectly sorted and/or formatted | VS Code
I was able to get around it by splitting up my imports so that they don't ... to ignore the error-- i.e. put...
Read more >
pylint-ignore - PyPI
pip install pylint-ignore Installing collected packages: astroid,isort,pylint ... should always be ignored, then do so via your pylintrc or setup.cfg file.
Read more >
Python and TOML: New Best Friends
If config matches, then you use pass to continue your code. Otherwise, you raise an error. This approach may not scale well if...
Read more >
Python 102: Scalable Python Project Setup - Medium
Create a setup.cfg file in your root folder and add this config. [isort] multi_line_output=3 include_trailing_comma=True force_grid_wrap=0
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found