isort runs in wrong cwd, also cannot configure settings file
See original GitHub issueBehaviour
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:
- Created 2 years ago
- Comments:17 (8 by maintainers)
Top GitHub Comments
I guess the issue is that both rely on the
section…
Closing this in favor of https://github.com/microsoft/vscode-python/issues/18714