pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

reportShadowedImports is not showing up in the file that is shadowing the import

Open rchiodo opened this issue 1 year ago • 3 comments

  1. Clone pylance-release
  2. Open testing/single
  3. Open the codeactions.py file. You'll get this:

image

  1. Open the mailbox.py file.

There should be a shadowed imports warning.

rchiodo avatar Jan 25 '24 23:01 rchiodo

This is not a regression. Reproduces in 2023.12.1

rchiodo avatar Jan 25 '24 23:01 rchiodo

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.

debonte avatar Apr 30 '24 01:04 debonte

we should add a test for it to catch regression next time.

heejaechang avatar Apr 30 '24 18:04 heejaechang