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 runs in wrong cwd, also cannot configure settings file

See original GitHub issue

Behaviour

Expected vs. Actual

we are in a poetry based python 3.10 virtualenv, all tool settings are in a pyproject.toml in ${workspaceFolder}

black works fine

isort is supposed to run as well on save

isort is configured like this:

"python.sortImports.path": "${workspaceFolder}/.venv/bin/isort",
		"python.sortImports.args": [
			"--settings-path",
			"${workspaceFolder}/pyproject.toml",
		]

but isort does not run properly, but produces this garbage (from the extension output console):

> ./.venv/bin/isort - --diff --settings-path ./pyproject.toml
cwd: ./cld_dfe
[ERROR 2022-2-8 22:31:19.616]: Error processing line 1 of /home/mkrause/projects/fiji-digital-2/.venv/lib/python3.10/site-packages/_virtualenv.pth:

So it ignores its settings file pyproject.toml, because the workspace root is incorrectly resolved to ‘.’, but cwd is not at workspace root, but rather cld_dfe, which is where the file is in, but obviosuly no settings file. In addition to not picking up the correct options, it also causes this stupid virtualenv bug complaining about partial imports.

What I want is SUPER simple. Run isort using pyproject.toml on the current file, with workspace root as cwd. Nothing complicated.

This is super frustrating. I read all the tickets on this and spent hours debugging, it keeps doing what it wants, ignoring everything I set.

Steps to reproduce:

create an environment like mentioned above, then configure vs code to format and sort imports on save like so:

		"[python]": {
			"editor.codeActionsOnSave": {
				"source.organizeImports": true
			},
			"editor.formatOnSave": true,
		},

Extension version: 2022.2.1924087327 VS Code version: Code 1.65.0 (b5205cc8eb4fbaa726835538cd82372cc0222d43, 2022-03-02T11:12:36.248Z) OS version: Linux x64 5.16.11-200.fc35.x86_64 Restricted Mode: No

System Info
Item Value
CPUs Intel® Core™ i7-8650U CPU @ 1.90GHz (8 x 2175)
GPU Status 2d_canvas: unavailable_software
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: disabled_off
rasterization: disabled_software
skia_renderer: enabled_on
video_decode: disabled_software
vulkan: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
Load (avg) 1, 1, 1
Memory (System) 31.22GB (4.14GB free)
Process Argv digital.code-workspace --crash-reporter-id 3833f654-6ab6-4e4e-b9c6-4a7a2278501e
Screen Reader no
VM 0%
DESKTOP_SESSION undefined
XDG_CURRENT_DESKTOP undefined
XDG_SESSION_DESKTOP undefined
XDG_SESSION_TYPE undefined
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyl392:30443607
pythontb:30283811
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscoreces:30445986
pythondataviewer:30285071
vscod805cf:30301675
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30449410
vsclayoutctrt:30448491
dsvsc008:30440022
pythonvspyt640:30442238
vsbas813:30436447
vscscmwlcmc:30438804
vscgsvid1:30447480
helix:30440343
vscaat:30438848

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
markusddcommented, Mar 15, 2022

I guess the issue is that both rely on the

"[python]": {
			"editor.codeActionsOnSave": {
				"source.organizeImports": true,
			},

section…

0reactions
karthiknadigcommented, Mar 17, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Supported Config Files - isort
When applying configurations, isort looks for the closest supported config file, in the order files are listed below. You can manually specify the...
Read more >
File not found error when launching a subprocess containing ...
You have to add shell=True to execute a shell command. check_output is trying to find an executable called: date | grep -o -w...
Read more >
Settings Reference for Python - Visual Studio Code
The Python extension uses this setting to install packages when Poetry is available and there's a poetry.lock file in the workspace folder. terminal.launchArgs ......
Read more >
What is the 'working directory' when cron executes a job?
It cannot find the template.txt but it resides in the same directory as the script. It also cannot run ssmtp , but I...
Read more >
How to set up working directory in PyCharm and package ...
2) do you have to configure your environment every time you start a project? Also, what is the idea behind project? I just...
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