Description
openedon Oct 13, 2022
Environment data
- Language Server version: 2022.10.20
- OS and version: darwin x64
- Python version (and distribution if applicable, e.g. Anaconda): 3.8.15
- python.analysis.indexing: false
- python.analysis.typeCheckingMode: off
Code Snippet
I'm currently trying to get static analysis working for a project with a nonstandard directory structure (more at #3454). Turning it into an editable install seem like the best option so far.
https://github.com/rzats/setuptools-repro is a small repo that mirrors the structure of that project. It contains this pyproject.toml
:
[build-system]
requires = ["setuptools>=65", "wheel"]
build-backend = "setuptools.build_meta"
setup.cfg
:
[metadata]
name = Local Package
[options]
packages =
root.package
package_dir =
root.package = root/package/src
as well as a Python file at root/package/src/test.py
, and a main.py
that tries to import test.py
.
Repro Steps
git clone https://github.com/rzats/setuptools-repro.git
cd setuptools-repro
python -m venv .venv
.venv/bin/python -m pip install -U pip
.venv/bin/python -m pip install -e .
.venv/bin/python -c 'import root.package.test; print(root.package.test)'
<module 'root.package.test' from '/Users/work/Documents/setuptools-repro/root/package/src/test.py'>
Expected behavior
root.package.test
should show up as a valid import in VSCode too.
Actual behavior
That doesn't happen:
Unfortunately, reverting to legacy editable packages as suggested by #3265 (comment) does not work for me, since that has an unrelated issue where advanced package_dir
bindings don't work at all - the newer PEP-660 implementation does support that.
Logs
Python
LSP Notebooks experiment is enabled
LSP Notebooks interactive window support is enabled
Python interpreter path: ./.venv/bin/python
> conda info --json
> ./.venv/bin/python ~/.vscode/extensions/ms-python.python-2022.16.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.16.0/pythonFiles/interpreterInfo.py
> /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2022.16.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.16.0/pythonFiles/interpreterInfo.py
> /usr/local/bin/python3.8 ~/.vscode/extensions/ms-python.python-2022.16.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.16.0/pythonFiles/interpreterInfo.py
> . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2022.16.0/pythonFiles/printEnvVariables.py
Starting Pylance language server.
Python Language Server
[Info - 6:15:09 PM] (17998) Pylance language server 2022.10.20 (pyright e2d13ab1) starting
[Info - 6:15:09 PM] (17998) Server root directory: /Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist
[Info - 6:15:09 PM] (17998) Starting service instance "setuptools-repro"
[Info - 6:15:09 PM] (17998) Notebook support: LSP
[Info - 6:15:09 PM] (17998) Interactive window support: LSP
[Info - 6:15:09 PM] (17998) No configuration file found.
[Info - 6:15:09 PM] (17998) pyproject.toml file found at /Users/work/Documents/setuptools-repro.
[Info - 6:15:09 PM] (17998) Setting pythonPath for service "setuptools-repro": "/Users/work/Documents/setuptools-repro/.venv/bin/python"
[Info - 6:15:09 PM] (17998) Loading pyproject.toml file at /Users/work/Documents/setuptools-repro/pyproject.toml
[Error - 6:15:09 PM] (17998) Pyproject file "/Users/work/Documents/setuptools-repro/pyproject.toml" is missing "[tool.pyright]" section.
[Warn - 6:15:09 PM] (17998) stubPath /Users/work/Documents/setuptools-repro/typings is not a valid directory.
[Info - 6:15:09 PM] (17998) Assuming Python version 3.8
[Info - 6:15:09 PM] (17998) Assuming Python platform Darwin
[Info - 6:15:09 PM] (17998) Search paths for /Users/work/Documents/setuptools-repro
[Info - 6:15:09 PM] (17998) /Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/typeshed-fallback/stdlib
[Info - 6:15:09 PM] (17998) /Users/work/Documents/setuptools-repro
[Info - 6:15:09 PM] (17998) /Users/work/Documents/setuptools-repro/typings
[Info - 6:15:09 PM] (17998) /Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/typeshed-fallback/stubs/...
[Info - 6:15:09 PM] (17998) /Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/bundled/stubs
[Info - 6:15:09 PM] (17998) /usr/local/Cellar/python@3.8/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8
[Info - 6:15:09 PM] (17998) /usr/local/Cellar/python@3.8/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload
[Info - 6:15:09 PM] (17998) /Users/work/Documents/setuptools-repro/.venv/lib/python3.8/site-packages
[Info - 6:15:09 PM] (17998) Adding fs watcher for library directories:
/usr/local/Cellar/python@3.8/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8
/usr/local/Cellar/python@3.8/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload
/Users/work/Documents/setuptools-repro/.venv/lib/python3.8/site-packages
[Info - 6:15:09 PM] (17998) Adding fs watcher for directories:
/Users/work/Documents/setuptools-repro
[Info - 6:15:09 PM] (17998) Searching for source files
[Info - 6:15:09 PM] (17998) Found 2 source files
(17998) [IDX(FG)] index libraries /Users/work/Documents/setuptools-repro (index) ...
(17998) [IDX(FG)] read stdlib indices (27ms)
(17998) [IDX(FG)] index libraries /Users/work/Documents/setuptools-repro (index) [succeed] (29ms)
(17998) [FG] parsing: /Users/work/Documents/setuptools-repro/main.py (13ms)
[Info - 6:15:09 PM] (17998) Could not import 'root.package.test' in file '/Users/work/Documents/setuptools-repro/main.py'
[Info - 6:15:09 PM] (17998) Looking in stubPath '/Users/work/Documents/setuptools-repro/typings'
[Info - 6:15:09 PM] (17998) Attempting to resolve stub package using root path '/Users/work/Documents/setuptools-repro/typings'
[Info - 6:15:09 PM] (17998) Attempting to resolve using root path '/Users/work/Documents/setuptools-repro/typings'
[Info - 6:15:09 PM] (17998) Looking in root directory of execution environment '/Users/work/Documents/setuptools-repro'
[Info - 6:15:09 PM] (17998) Attempting to resolve stub package using root path '/Users/work/Documents/setuptools-repro'
[Info - 6:15:09 PM] (17998) Attempting to resolve using root path '/Users/work/Documents/setuptools-repro'
[Info - 6:15:09 PM] (17998) Looking in python search path '/usr/local/Cellar/python@3.8/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8'
[Info - 6:15:09 PM] (17998) Attempting to resolve stub package using root path '/usr/local/Cellar/python@3.8/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8'
[Info - 6:15:09 PM] (17998) Attempting to resolve using root path '/usr/local/Cellar/python@3.8/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8'
[Info - 6:15:09 PM] (17998) Looking in python search path '/usr/local/Cellar/python@3.8/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload'
[Info - 6:15:09 PM] (17998) Attempting to resolve stub package using root path '/usr/local/Cellar/python@3.8/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload'
[Info - 6:15:09 PM] (17998) Attempting to resolve using root path '/usr/local/Cellar/python@3.8/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload'
[Info - 6:15:09 PM] (17998) Looking in python search path '/Users/work/Documents/setuptools-repro/.venv/lib/python3.8/site-packages'
[Info - 6:15:09 PM] (17998) Attempting to resolve stub package using root path '/Users/work/Documents/setuptools-repro/.venv/lib/python3.8/site-packages'
[Info - 6:15:09 PM] (17998) Attempting to resolve using root path '/Users/work/Documents/setuptools-repro/.venv/lib/python3.8/site-packages'
[Info - 6:15:09 PM] (17998) Looking in bundled stubs path '/Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/bundled/stubs'
[Info - 6:15:09 PM] (17998) Attempting to resolve stub package using root path '/Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/bundled/stubs'
[Info - 6:15:09 PM] (17998) Attempting to resolve using root path '/Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/bundled/stubs'
[Info - 6:15:09 PM] (17998) Looking for typeshed stdlib path
[Info - 6:15:09 PM] (17998) Looking for typeshed stdlib path
[Info - 6:15:09 PM] (17998) Attempting to resolve using root path '/Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/typeshed-fallback/stdlib'
[Info - 6:15:09 PM] (17998) Typeshed path not found
[Info - 6:15:09 PM] (17998) Looking for typeshed third-party path
[Info - 6:15:09 PM] (17998) Looking for typeshed stubs path
[Info - 6:15:09 PM] (17998) Typeshed path not found
(17998) [FG] parsing: /Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/typeshed-fallback/stdlib/builtins.pyi [fs read 3ms] (70ms)
(17998) [FG] binding: /Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/typeshed-fallback/stdlib/builtins.pyi (24ms)
(17998) [FG] binding: /Users/work/Documents/setuptools-repro/main.py (2ms)
[Info - 6:15:10 PM] (17998) Background analysis(1) root directory: /Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist
[Info - 6:15:10 PM] (17998) Background analysis(1) started
(17998) Background analysis message: setConfigOptions
(17998) Background analysis message: setImportResolver
(17998) Background analysis message: ensurePartialStubPackages
(17998) Background analysis message: setTrackedFiles
(17998) Background analysis message: markAllFilesDirty
(17998) Background analysis message: setFileOpened
(17998) Background analysis message: getDiagnosticsForRange
(17998) Background analysis message: getSemanticTokens full
(17998) [BG(1)] getSemanticTokens full at /Users/work/Documents/setuptools-repro/main.py ...
(17998) [BG(1)] parsing: /Users/work/Documents/setuptools-repro/main.py (12ms)
[Info - 6:15:10 PM] (17998) Could not import 'root.package.test' in file '/Users/work/Documents/setuptools-repro/main.py'
[Info - 6:15:10 PM] (17998) Looking in stubPath '/Users/work/Documents/setuptools-repro/typings'
[Info - 6:15:10 PM] (17998) Attempting to resolve stub package using root path '/Users/work/Documents/setuptools-repro/typings'
[Info - 6:15:10 PM] (17998) Attempting to resolve using root path '/Users/work/Documents/setuptools-repro/typings'
[Info - 6:15:10 PM] (17998) Looking in root directory of execution environment '/Users/work/Documents/setuptools-repro'
[Info - 6:15:10 PM] (17998) Attempting to resolve stub package using root path '/Users/work/Documents/setuptools-repro'
[Info - 6:15:10 PM] (17998) Attempting to resolve using root path '/Users/work/Documents/setuptools-repro'
[Info - 6:15:10 PM] (17998) Looking in python search path '/usr/local/Cellar/python@3.8/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8'
[Info - 6:15:10 PM] (17998) Attempting to resolve stub package using root path '/usr/local/Cellar/python@3.8/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8'
[Info - 6:15:10 PM] (17998) Attempting to resolve using root path '/usr/local/Cellar/python@3.8/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8'
[Info - 6:15:10 PM] (17998) Looking in python search path '/usr/local/Cellar/python@3.8/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload'
[Info - 6:15:10 PM] (17998) Attempting to resolve stub package using root path '/usr/local/Cellar/python@3.8/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload'
[Info - 6:15:10 PM] (17998) Attempting to resolve using root path '/usr/local/Cellar/python@3.8/3.8.15/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload'
[Info - 6:15:10 PM] (17998) Looking in python search path '/Users/work/Documents/setuptools-repro/.venv/lib/python3.8/site-packages'
[Info - 6:15:10 PM] (17998) Attempting to resolve stub package using root path '/Users/work/Documents/setuptools-repro/.venv/lib/python3.8/site-packages'
[Info - 6:15:10 PM] (17998) Attempting to resolve using root path '/Users/work/Documents/setuptools-repro/.venv/lib/python3.8/site-packages'
[Info - 6:15:10 PM] (17998) Looking in bundled stubs path '/Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/bundled/stubs'
[Info - 6:15:10 PM] (17998) Attempting to resolve stub package using root path '/Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/bundled/stubs'
[Info - 6:15:10 PM] (17998) Attempting to resolve using root path '/Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/bundled/stubs'
[Info - 6:15:10 PM] (17998) Looking for typeshed stdlib path
[Info - 6:15:10 PM] (17998) Looking for typeshed stdlib path
[Info - 6:15:10 PM] (17998) Attempting to resolve using root path '/Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/typeshed-fallback/stdlib'
[Info - 6:15:10 PM] (17998) Typeshed path not found
[Info - 6:15:10 PM] (17998) Looking for typeshed third-party path
[Info - 6:15:10 PM] (17998) Looking for typeshed stubs path
[Info - 6:15:10 PM] (17998) Typeshed path not found
(17998) [BG(1)] parsing: /Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/typeshed-fallback/stdlib/builtins.pyi [fs read 2ms] (79ms)
(17998) [BG(1)] binding: /Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/typeshed-fallback/stdlib/builtins.pyi (29ms)
(17998) [BG(1)] binding: /Users/work/Documents/setuptools-repro/main.py (2ms)
(17998) [BG(1)] getSemanticTokens full at /Users/work/Documents/setuptools-repro/main.py (126ms)
(17998) Background analysis message: getDiagnosticsForRange
(17998) Background analysis message: getSemanticTokens range
(17998) [BG(1)] getSemanticTokens range 0:0 - 0:32 at /Users/work/Documents/setuptools-repro/main.py (1ms)
(17998) Background analysis message: analyze
(17998) [BG(1)] analyzing: /Users/work/Documents/setuptools-repro/main.py ...
(17998) [BG(1)] checking: /Users/work/Documents/setuptools-repro/main.py ...
(17998) [BG(1)] parsing: /Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/typeshed-fallback/stdlib/typing.pyi [fs read 0ms] (19ms)
(17998) [BG(1)] binding: /Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/typeshed-fallback/stdlib/typing.pyi (5ms)
(17998) [BG(1)] parsing: /Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/typeshed-fallback/stdlib/typing_extensions.pyi [fs read 1ms] (3ms)
(17998) [BG(1)] binding: /Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/typeshed-fallback/stdlib/typing_extensions.pyi (2ms)
(17998) [BG(1)] parsing: /Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi [fs read 0ms] (7ms)
(17998) [BG(1)] binding: /Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi (2ms)
(17998) [BG(1)] parsing: /Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/typeshed-fallback/stdlib/abc.pyi [fs read 0ms] (1ms)
(17998) [BG(1)] binding: /Users/work/.vscode/extensions/ms-python.vscode-pylance-2022.10.20/dist/typeshed-fallback/stdlib/abc.pyi (1ms)
(17998) [BG(1)] checking: /Users/work/Documents/setuptools-repro/main.py (73ms)
(17998) [BG(1)] analyzing: /Users/work/Documents/setuptools-repro/main.py (73ms)
(17998) Background analysis message: resumeAnalysis
(17998) Background analysis message: getDiagnosticsForRange
(17998) Background analysis message: getDiagnosticsForRange
(17998) Background analysis message: getDiagnosticsForRange
(17998) Background analysis message: getDiagnosticsForRange