pylance-release
pylance-release copied to clipboard
reportShadowedImports is not showing up in the file that is shadowing the import
- Clone pylance-release
- Open testing/single
- Open the codeactions.py file. You'll get this:
- Open the mailbox.py file.
There should be a shadowed imports warning.
This is not a regression. Reproduces in 2023.12.1
It works properly if the files are in the root of the workspace rather than in src.
The problem is that the moduleName value used by SourceFile._buildFileInfo is supplied when the SourceFile is constructed, and that value ("src.mailbox") is based on the root of the default exec env. When _buildFileInfo is called later, we calculate the file's exec env via configOptions.findExecEnvironment (whose root is the src subdir) but the cached module name is not refreshed.
we should add a test for it to catch regression next time.