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.

Applying code action 'Sort imports' hangs indefinitely

See original GitHub issue

Environment data

  • VS Code version: 1.47.3
  • Extension version (available under the Extensions sidebar): v2020.7.96456
  • OS and version: Ubuntu 20.04
  • Python version: 3.8.3 (installed by pyenv)
  • Type of virtual environment used: pyenv-virtualenv
  • Relevant/affected Python packages and their versions: XXX
  • Relevant/affected Python-related VS Code extensions and their versions: XXX
  • Value of the python.languageServer setting: doesn’t seem to matter; I have tried Jedi, Microsoft, Pylance, and None
  • isort version: 4.3.21

Expected behaviour

When I hit save on a Python file, I expect it to quickly/automatically sort my imports

Actual behaviour

It pops up a box much like this one:

Saving ‘main.py’: Applying code action ‘Sort imports’.

And that box never goes away. It hangs indefinitely. Obviously it never actually sorts my imports either, nor does it proceed to linting / auto-formatting. It just gets stuck.

Steps to reproduce:

  1. pip install black pylint isort autoflake
  2. Copy my settings.json file
  3. Save a Python file

Logs

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

> ~/.pyenv/versions/myproject/bin/python ~/.vscode/extensions/ms-python.python-2020.7.96456/pythonFiles/pyvsc-run-isolated.py ~/.vscode/extensions/ms-python.python-2020.7.96456/pythonFiles/sortImports.py - --diff
cwd: ~/src/myproject/home
> ~/.pyenv/versions/myproject/bin/python ~/.vscode/extensions/ms-python.python-2020.7.96456/pythonFiles/pyvsc-run-isolated.py ~/.vscode/extensions/ms-python.python-2020.7.96456/pythonFiles/sortImports.py - --diff
cwd: ~/src/myproject/home


Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:25
  • Comments:53 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
eldano1995commented, May 11, 2021

I think the issue came back with version 1.56.0 of VS Code, in Windows 10. Anyone else can verified that?

6reactions
dave-picommented, Aug 20, 2020

I managed to workaround the problem by adding the following to settings.json (change according to your location of isort script):

“python.sortImports.path”: “${env:HOME}/.local/bin/isort”,

Read more comments on GitHub >

github_iconTop Results From Across the Web

vscode "applying code action organize Imports" - Stack Overflow
Turns out the folder I was opening had its own custom .vscode folder with its own settings.json which had the organizeImports setting ...
Read more >
Python & VS Code: make Black and organize imports ... - Reddit
Here's a short blog post on getting Black code formatting and VS Code's "organize imports on save" to play nicely together. It fixed...
Read more >
Visual Studio Code | Metals - Scalameta
Click "Import build" to start the installation step. Import build. "Not now" disables this prompt for 2 minutes. "Don't show again" disables this...
Read more >
Python import: Advanced Techniques and Tips
In Python, you use the import keyword to make code in one module available in another. ... You can use a package to...
Read more >
Fixed issues in InDesign - Adobe Support
While applying a font via parastyle in ID and pasting it to AI, ... [Windows] InDesign intermittently crashes while working in Offline mode....
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