Skip to content

Handle cross-mount paths in find_parents#714

Open
lin-hongkuan wants to merge 1 commit into
python-lsp:developfrom
lin-hongkuan:codex/find-parents-cross-mount
Open

Handle cross-mount paths in find_parents#714
lin-hongkuan wants to merge 1 commit into
python-lsp:developfrom
lin-hongkuan:codex/find-parents-cross-mount

Conversation

@lin-hongkuan

Copy link
Copy Markdown

find_parents() uses os.path.commonprefix() as a guard before calling os.path.relpath(), but commonprefix() is character-based. On Windows UNC paths such as \\server\share1 and \\server\share2\path.py, the prefix check passes even though the paths are on different mounts, and relpath() raises ValueError.

This catches that ValueError and returns [], matching the existing behavior for paths outside the root. The regression test uses ntpath directly so it covers the Windows UNC behavior on any platform.

fixes #705

Tests:

  • python -m pytest -o addopts="" test/test_utils.py::test_find_parents_handles_cross_mount_paths test/test_utils.py::test_find_parents -q
  • python -m pytest -o addopts="" test/test_utils.py -q
  • py -3 -m ruff check pylsp/_utils.py test/test_utils.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant