Skip to content

Location.relativePath to use None value if rel path is not available #85 #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2025

Conversation

Andrej730
Copy link
Contributor

No description provided.

@Andrej730 Andrej730 force-pushed the optional_relative_path branch from f41e8b4 to 2b65f8a Compare March 26, 2025 05:10
@Andrej730 Andrej730 force-pushed the optional_relative_path branch from 2b65f8a to ef9ad63 Compare March 28, 2025 04:32
@LakshyAAAgrawal
Copy link
Collaborator

I am wondering, did you find this bug due to a crash?

@Andrej730
Copy link
Contributor Author

I am wondering, did you find this bug due to a crash?

Yeah, was doing tests with multilspy and when I used request_definition on any symbol that comes from "site-packages" I got the error trying to get relative path - in my case script was on the disk "L:" and Python and "site-packages" were on disk "C:", system drive.

@LakshyAAAgrawal
Copy link
Collaborator

I think this is good to merge, but also, is there any way we could try to test this functionality, in such a manner that it fails without this change?

@Andrej730
Copy link
Contributor Author

I think this is good to merge, but also, is there any way we could try to test this functionality, in such a manner that it fails without this change?

It is possible but it has system requirements - test can be only performed on Windows, since on Unix .drive is always the same and it's '', and it will need to have 2 different drives set up.

We can add a test for get_relative_path to make sure it checks that .drive is the same but I don't know how we can ensure with a test that request_ functions call get_relative_path, any ideas?

@Andrej730
Copy link
Contributor Author

Got an idea for a test using unittest.mock (see sommit above). What do you think? @LakshyAAAgrawal

@Andrej730
Copy link
Contributor Author

Okay, I guess even this kind of test only would work on Windows as PurePath.drive seems to always return "" on unix.

from pathlib import PurePath
path = "C:/test.py"
path = PurePath(path)
print(path) # C:\test.py

# prints "" on unix and "C:" on windows
print(repr(path.drive))

@LakshyAAAgrawal
Copy link
Collaborator

I think it is okay to skip this test. You can undo the testfile, and we can proceed with merge!

@Andrej730 Andrej730 force-pushed the optional_relative_path branch from 6dc9dec to ef9ad63 Compare March 31, 2025 07:04
@Andrej730
Copy link
Contributor Author

Removed the test.

@LakshyAAAgrawal LakshyAAAgrawal merged commit 127de62 into microsoft:main Mar 31, 2025
6 checks passed
@LakshyAAAgrawal
Copy link
Collaborator

Thanks a lot for the PR @Andrej730

@Andrej730 Andrej730 deleted the optional_relative_path branch March 31, 2025 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants