Symlink leads to ValueError in internal call to pathlib
WarmongeringBeaver opened this issue · 1 comments
WarmongeringBeaver commented
Issue
Call to black formatting from the vscode extension leads to following error:
File "/<REDACTED>/lib/python3.11/site-packages/black/__init__.py", line 600, in main
sources = get_sources(
^^^^^^^^^^^^
File "/<REDACTED>/lib/python3.11/site-packages/black/__init__.py", line 687, in get_sources
root_relative_path = path.absolute().relative_to(root).as_posix()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/<REDACTED>/lib/python3.11/pathlib.py", line 730, in relative_to
raise ValueError("{!r} is not in the subpath of {!r}"
ValueError: '/projects/static2dynamic/DMSB/data.py' is not in the subpath of '/import/pr_static2dynamic/DMSB' OR one path is relative and the other is absolute.
where /projects/static2dynamic
is a symlink pointing to /import/pr_static2dynamic
.
Weirdly, calling black .
directly from the CLI does not lead to this (nor any) error, so I guess it is related in some way to the extension calls?
Extension info
Version: 2023.6.0
with "black-formatter.importStrategy": "fromEnvironment"
.
The extension does not indeed call the bundled version:
2023-12-27 11:02:40.853 [info] Version info for formatter running for /import/pr_static2dynamic/DMSB:
black, 23.11.0 (compiled: no)
Python (CPython) 3.11.7
2023-12-27 11:02:40.853 [info] SUPPORTED black>=22.3.0
FOUND black==23.11.0
but the exact same error is thrown when using the bundled version.
CLI info
From my activated Python environment:
black, 23.11.0 (compiled: no)
Python (CPython) 3.11.7
karthiknadig commented
From the call stack this looks like a error in black
. Please file it here https://github.com/psf/black/issues