Skip to content

Pkg_resources namespace packages seem to be overshadowed after editable pip install #1744

Description

@MariuszBielecki288728

Environment data

  • Language Server version: v2021.8.3
  • OS and version: Ubuntu 20.04.3 LTS (within Windows Subsystem for Linux (WSL1)),
  • uname -a: Linux C-PF2SLXS7 4.4.0-18362-Microsoft #1049-Microsoft Thu Aug 14 12:01:00 PST 2020 x86_64 x86_64 x86_64 GNU/Linux)
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.8.10 distributed with Ubuntu 20.04

Reproduce steps

python3 -m venv venv
source venv/bin/activate
  • install the package in editable mode
pip install wheel
pip install -e .
  • Go to the test.py file in VS Code.

Expected behaviour

from foobar.second import script2
from foobar.first import script1

both of the above packages are found by the Pylance

Actual behaviour

foobar.second is found
foobar.first is missing:

{
	"resource": "/home/marbiele/test/foobar-second/test.py",
	"owner": "_generated_diagnostic_collection_name_#0",
	"code": {
		"value": "reportMissingImports",
		"target": {
			"$mid": 1,
			"external": "https://github.com/microsoft/pylance-release/blob/main/DIAGNOSTIC_SEVERITY_RULES.md#diagnostic-severity-rules",
			"path": "/microsoft/pylance-release/blob/main/DIAGNOSTIC_SEVERITY_RULES.md",
			"scheme": "https",
			"authority": "github.com",
			"fragment": "diagnostic-severity-rules"
		}
	},
	"severity": 4,
	"message": "Import \"foobar.first\" could not be resolved",
	"source": "Pylance",
	"startLineNumber": 2,
	"startColumn": 6,
	"endLineNumber": 2,
	"endColumn": 18
}

even though python test.py command returns no error.

Logs

[Info  - 9:52:56 PM] Pylance language server 2021.8.3 (pyright fa4194fd) starting
[Info  - 9:52:56 PM] Server root directory: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist
[Info  - 10:22:57 PM] No configuration file found.
[Info  - 10:22:57 PM] No pyproject.toml file found.
[Info  - 10:22:57 PM] Setting pythonPath for service "foobar-second": "/home/marbiele/test/foobar-second/venv/bin/python3"
[Warn  - 10:22:57 PM] stubPath /home/marbiele/test/foobar-second/typings is not a valid directory.
[Info  - 10:22:57 PM] Assuming Python version 3.8
[Info  - 10:22:57 PM] Assuming Python platform Linux
Search paths for /home/marbiele/test/foobar-second
  /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib
  /home/marbiele/test/foobar-second
  /home/marbiele/test/foobar-second/venv/lib/python3.8/site-packages/foobar
  /home/marbiele/test/foobar-second/typings
  /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stubs/...
  /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/bundled/stubs
  /usr/lib/python3.8
  /usr/lib/python3.8/lib-dynload
  /home/marbiele/test/foobar-second/venv/lib/python3.8/site-packages
  /home/marbiele/test/foobar-second/src
[Warn  - 10:22:58 PM] Exception received when installing file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
[Warn  - 10:22:58 PM] Exception received when installing file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
[Info  - 10:22:58 PM] Searching for source files
[Info  - 10:22:58 PM] Auto-excluding /home/marbiele/test/foobar-second/venv
[Info  - 10:22:58 PM] Found 7 source files
Background analysis message: setConfigOptions
Background analysis message: setImportResolver
Background analysis message: ensurePartialStubPackages
Background analysis message: setTrackedFiles
Background analysis message: markAllFilesDirty
Background analysis message: analyze
[BG(1)] analyzing: /home/marbiele/test/foobar-second/setup.py ...
[BG(1)]   parsing: /home/marbiele/test/foobar-second/setup.py (376ms)
[BG(1)]   parsing: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/builtins.pyi [fs read 4ms] (320ms)
[BG(1)]   binding: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/builtins.pyi (245ms)
[BG(1)]   binding: /home/marbiele/test/foobar-second/setup.py (1ms)
[BG(1)]   checking: /home/marbiele/test/foobar-second/setup.py (2ms)
[BG(1)] analyzing: /home/marbiele/test/foobar-second/setup.py (946ms)
Background analysis message: setFileClosed
Background analysis message: analyze
[BG(1)] analyzing: /home/marbiele/test/foobar-second/setup.py ...
[BG(1)]   checking: /home/marbiele/test/foobar-second/setup.py ...
[BG(1)]     parsing: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/typing.pyi [fs read 2ms] (132ms)
[BG(1)]     binding: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/typing.pyi (68ms)
[BG(1)]     parsing: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi [fs read 3ms] (34ms)
[BG(1)]     binding: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi (6ms)
[BG(1)]     parsing: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/typing_extensions.pyi [fs read 2ms] (11ms)
[BG(1)]     binding: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/typing_extensions.pyi (8ms)
[BG(1)]     parsing: /home/marbiele/test/foobar-second/venv/lib/python3.8/site-packages/setuptools/__init__.py [fs read 1ms] (96ms)
[BG(1)]     binding: /home/marbiele/test/foobar-second/venv/lib/python3.8/site-packages/setuptools/__init__.py (9ms)
[BG(1)]     parsing: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/distutils/util.pyi [fs read 2ms] (10ms)
[BG(1)]     binding: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/distutils/util.pyi (2ms)
[BG(1)]     parsing: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/os/__init__.pyi [fs read 2ms] (82ms)
[BG(1)]     binding: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/os/__init__.pyi (23ms)
[BG(1)]     parsing: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/abc.pyi [fs read 1ms] (4ms)
[BG(1)]     binding: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/abc.pyi (2ms)
[BG(1)]     parsing: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/os/path.pyi [fs read 1ms] (4ms)
[BG(1)]     binding: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/os/path.pyi ...
[BG(1)]       parsing: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/posixpath.pyi [fs read 1ms] (8ms)
[BG(1)]       binding: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/posixpath.pyi (11ms)
[BG(1)]     binding: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/os/path.pyi (27ms)
[BG(1)]     parsing: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/fnmatch.pyi [fs read 1ms] (3ms)
[BG(1)]     binding: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/fnmatch.pyi (1ms)
[BG(1)]     parsing: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/distutils/core.pyi [fs read 2ms] (10ms)
[BG(1)]     binding: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/distutils/core.pyi (1ms)
[BG(1)]     parsing: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/distutils/filelist.pyi [fs read 1ms] (4ms)
[BG(1)]     binding: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/distutils/filelist.pyi (2ms)
[BG(1)]     parsing: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/distutils/extension.pyi [fs read 2ms] (13ms)
[BG(1)]     binding: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/distutils/extension.pyi (1ms)
[BG(1)]     parsing: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/distutils/dist.pyi [fs read 2ms] (8ms)
[BG(1)]     binding: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/distutils/dist.pyi (3ms)
[BG(1)]     parsing: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/distutils/cmd.pyi [fs read 2ms] (5ms)
[BG(1)]     binding: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/distutils/cmd.pyi (2ms)
[BG(1)]   checking: /home/marbiele/test/foobar-second/setup.py (816ms)
[BG(1)] analyzing: /home/marbiele/test/foobar-second/setup.py (816ms)
Background analysis message: resumeAnalysis
[BG(1)] analyzing: /home/marbiele/test/foobar-second/src/foobar/second/__init__.py ...
[BG(1)]   parsing: /home/marbiele/test/foobar-second/src/foobar/second/__init__.py (1ms)
[BG(1)]   binding: /home/marbiele/test/foobar-second/src/foobar/second/__init__.py (0ms)
[BG(1)]   checking: /home/marbiele/test/foobar-second/src/foobar/second/__init__.py (2ms)
[BG(1)] analyzing: /home/marbiele/test/foobar-second/src/foobar/second/__init__.py (5ms)
Background analysis message: resumeAnalysis
Background analysis message: setFileClosed
Background analysis message: analyze
Background analysis message: setFileOpened
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
[FG] parsing: /home/marbiele/test/foobar-second/test.py (78ms)
[FG] parsing: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/builtins.pyi [fs read 1ms] (257ms)
[FG] binding: /home/marbiele/.vscode-server/extensions/ms-python.vscode-pylance-2021.8.3/dist/typeshed-fallback/stdlib/builtins.pyi (119ms)
[FG] binding: /home/marbiele/test/foobar-second/test.py (1ms)
Background analysis message: analyze
[BG(1)] analyzing: /home/marbiele/test/foobar-second/test.py ...
[BG(1)]   parsing: /home/marbiele/test/foobar-second/test.py (11ms)
[BG(1)]   binding: /home/marbiele/test/foobar-second/test.py (0ms)
[BG(1)]   checking: /home/marbiele/test/foobar-second/test.py ...
[BG(1)]     parsing: /home/marbiele/test/foobar-second/src/foobar/second/script2.py [fs read 0ms] (1ms)
[BG(1)]     binding: /home/marbiele/test/foobar-second/src/foobar/second/script2.py (1ms)
[BG(1)]   checking: /home/marbiele/test/foobar-second/test.py (3ms)
[BG(1)] analyzing: /home/marbiele/test/foobar-second/test.py (16ms)
Background analysis message: getDiagnosticsForRange
Background analysis message: resumeAnalysis
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange

Code Snippet / Additional information

From my pov, it looks like local installation of foobar namespace (src/foobar) overshadows the rest of the namespace installed in venv/lib/python3.8/site-packages/foobar/. I tried adding these paths to python.analysis.extraPaths but with no luck:

"python.analysis.extraPaths": ["venv/lib/python3.8/site-packages/foobar", "venv/lib/python3.8/site-packages/foobar/first"],

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions