Skip to content
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

Fix realCasePath changing empty paths to . #6001

Merged
merged 3 commits into from
Sep 21, 2023

Conversation

rchiodo
Copy link
Collaborator

@rchiodo rchiodo commented Sep 21, 2023

Addresses microsoft/pylance-release#4861

The root cause of this bug is that for a loose file (no workspace), the current execution root for command line options is just ''. Normalizing this changes it to '.' for some reason and that breaks all the other logic after that point.

The fix here is to not normalize when calling realCasePath. Nodefs.realCase can normalize paths on its own, so it's not necessary to normalize them ahead of time.

@@ -536,7 +536,7 @@ export function stripFileExtension(fileName: string, multiDotExtension = false)
}

export function realCasePath(pathString: string, fileSystem: ReadOnlyFileSystem): string {
return normalizePath(fileSystem.realCasePath(pathString));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This normalizePath can change the empty string into a .. We shouldn't need to normalize since calling real case o n a path will have that same effect anyway.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@rchiodo rchiodo merged commit e0681af into microsoft:main Sep 21, 2023
12 checks passed
@rchiodo rchiodo deleted the rchiodo/fix_loose_files branch September 21, 2023 21:28
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.

3 participants