-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Set isThirdPartyImport
and isThirdPartyPyTypedPresent
for interim files
#6155
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks reasonable to me. It's touching piece of code that deals with a lot of complexity (given all of the weird edge cases of the Python import system), so I can't say with full confidence that it won't introduce regressions in some edge case. Your changes don't appear to have any impact on the core import resolution logic (i.e. the logic used to model the behavior of import
statements), so if there is a regression, it will presumably show up only in completion suggestions and the pytest fixture functionality.
This comment has been minimized.
This comment has been minimized.
when I looked it last time, this one was when we set it as so, when |
packages/pyright-internal/src/tests/importStatementUtils.test.ts
Outdated
Show resolved
Hide resolved
Yeah, I saw that code, but since |
so, currently, if you have a pyright supports this kind of if those files are marked as now question is if that file is brought into the program by either might be fine to just not mark it. I am just saying difference on if that file is loaded in program differently, it might have marked as |
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
…tc from lib .py files
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
packages/pyright-internal/src/tests/fourslash/completions.importInterimFile.fourslash.ts
Show resolved
Hide resolved
packages/pyright-internal/src/tests/fourslash/completions.importInterimFile.fourslash.ts
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
packages/pyright-internal/src/tests/fourslash/completions.importInterimFile.fourslash.ts
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Addresses microsoft/pylance-release#4059
Things I asked for comments on when initially posting this PR:
isThirdPartyImport
totrue
onSourceFile
andSourceFileInfo
only whenmoduleNameAndType.importType === ImportType.ThirdParty
? We could have done that before, so I'm not sure if I'm missing some complexity here._shouldWalkUp
ifcurrent
is outside of theroot
directory, the return value of_shouldWalkUp
is based on comparing the lengths of the two paths which seems wrong since they are unrelated. For example, ifcurrent
is%LOCALAPPDATA%\Programs\Python\Python311\Lib"
androot
is the workspace root, their relative lengths are irrelevant. ShouldpathUtils.containsPath
be getting called somewhere? Or am I using_shouldWalkUp
incorrectly?