microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.7k stars 767 forks source link

Pylance does not show auto import information from site-packages directory #3281

Closed rbhanot4739 closed 2 years ago

rbhanot4739 commented 2 years ago

Environment data

Code Snippet


if __name__ == "__main__":
    req: Request
    manage_request(req)

Repro Steps

  1. Create a new virtual environment and install fastapi, request and flask packages for testing purposes.
  2. Create a new python file or open any existing python file.
  3. Type Req this should trigger auto-completion popup and observe the suggestion, it does not show all the classes which have name starting with word Request

Expected behavior

When I type Req I should see all entries which have name starting with word Request in the suggestions popup, for example in my case I have these packages fastapi, request and flask in site-packages directory and so I should be able to see atleast 3 entries with Request as each of these packages have Request class.

Actual behavior

Pylance only shows the auto-complete entries from from standard lib packages only which are at this path <system_python_path>/lib/python3.10/ and does not include packages from site-packages directory.

I have also tried by adding site-packages path to python.analysis.extraPath but that did not help. Enabling the python.analysis.indexing starts to show few more entries but for larger projects it creates another issue of Workspace indexing has hit its upper limit: 2000 files and so again you don't see the expected result.

Logs

[Info  - 10:39:24 PM] (81585) Pylance language server 2022.8.51 (pyright aba41864) starting
[Info  - 10:39:24 PM] (81585) Server root directory: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist
[Info  - 10:39:24 PM] (81585) Starting service instance "dummy_projecte"
[Info  - 10:39:24 PM] (81585) Notebook support: Legacy
[Info  - 10:39:24 PM] (81585) Interactive window support: Legacy
[Info  - 10:39:24 PM] (81585) No configuration file found.
[Info  - 10:39:24 PM] (81585) No pyproject.toml file found.
[Info  - 10:39:24 PM] (81585) Setting pythonPath for service "dummy_projecte": "/Users/rbhanot/development/personal/self-learning/venv/bin/python"
[Warn  - 10:39:24 PM] (81585) stubPath /Users/rbhanot/dummy_projecte/typings is not a valid directory.
[Info  - 10:39:24 PM] (81585) Assuming Python version 3.10
[Info  - 10:39:24 PM] (81585) Assuming Python platform Darwin
[Info  - 10:39:24 PM] (81585) Search paths for /Users/rbhanot/dummy_projecte
[Info  - 10:39:24 PM] (81585)   /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/typeshed-fallback/stdlib
[Info  - 10:39:24 PM] (81585)   /Users/rbhanot/dummy_projecte
[Info  - 10:39:24 PM] (81585)   /Users/rbhanot/dummy_projecte/typings
[Info  - 10:39:24 PM] (81585)   /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/typeshed-fallback/stubs/...
[Info  - 10:39:24 PM] (81585)   /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/bundled/stubs
[Info  - 10:39:24 PM] (81585)   /usr/local/linkedin/Homebrew/Caskroom/lnkd-cleanpython310/1.1.0/3.10.2/lib/python3.10
[Info  - 10:39:24 PM] (81585)   /usr/local/linkedin/Homebrew/Caskroom/lnkd-cleanpython310/1.1.0/3.10.2/lib/python3.10/lib-dynload
[Info  - 10:39:24 PM] (81585)   /Users/rbhanot/development/personal/self-learning/venv/lib/python3.10/site-packages
[Info  - 10:39:24 PM] (81585) Adding fs watcher for library directories:
 /export/apps/python/3.10/lib/python3.10
/export/apps/python/3.10/lib/python3.10/lib-dynload
/Users/rbhanot/development/personal/self-learning/venv/lib/python3.10/site-packages
[Info  - 10:39:24 PM] (81585) Adding fs watcher for directories:
 /Users/rbhanot/dummy_projecte
[Info  - 10:39:24 PM] (81585) Searching for source files
[Info  - 10:39:24 PM] (81585) Found 1 source file
(81585) [IDX(FG)] index libraries /Users/rbhanot/dummy_projecte (index) ...
(81585) [IDX(FG)]   read stdlib indices (30ms)
(81585) [IDX(FG)] index libraries /Users/rbhanot/dummy_projecte (index) [succeed] (30ms)
(81585) [FG] parsing: /Users/rbhanot/dummy_projecte/main.py (15ms)
(81585) [FG] parsing: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/typeshed-fallback/stdlib/builtins.pyi [fs read 2ms] (72ms)
(81585) [FG] binding: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/typeshed-fallback/stdlib/builtins.pyi (31ms)
(81585) [FG] binding: /Users/rbhanot/dummy_projecte/main.py (0ms)
[Info  - 10:39:24 PM] (81585) Background analysis(1) root directory: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist
[Info  - 10:39:24 PM] (81585) Background analysis(1) started
(81585) Background analysis message: setConfigOptions
(81585) Background analysis message: setImportResolver
(81585) Background analysis message: ensurePartialStubPackages
(81585) Background analysis message: setTrackedFiles
(81585) Background analysis message: markAllFilesDirty
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: getDiagnosticsForRange
(81585) Background analysis message: analyze
(81585) [BG(1)] analyzing: /Users/rbhanot/dummy_projecte/main.py ...
(81585) [BG(1)]   parsing: /Users/rbhanot/dummy_projecte/main.py (15ms)
(81585) [BG(1)]   parsing: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/typeshed-fallback/stdlib/builtins.pyi [fs read 3ms] (70ms)
(81585) [BG(1)]   binding: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/typeshed-fallback/stdlib/builtins.pyi (25ms)
(81585) [BG(1)]   binding: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [BG(1)]   checking: /Users/rbhanot/dummy_projecte/main.py ...
(81585) [BG(1)]     parsing: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/typeshed-fallback/stdlib/typing.pyi [fs read 2ms] (22ms)
(81585) [BG(1)]     binding: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/typeshed-fallback/stdlib/typing.pyi (7ms)
(81585) [BG(1)]     parsing: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/typeshed-fallback/stdlib/typing_extensions.pyi [fs read 0ms] (3ms)
(81585) [BG(1)]     binding: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/typeshed-fallback/stdlib/typing_extensions.pyi (1ms)
(81585) [BG(1)]     parsing: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi [fs read 0ms] (9ms)
(81585) [BG(1)]     binding: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi (2ms)
(81585) [BG(1)]     parsing: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/typeshed-fallback/stdlib/types.pyi [fs read 0ms] (9ms)
(81585) [BG(1)]     binding: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/typeshed-fallback/stdlib/types.pyi (11ms)
(81585) [BG(1)]     parsing: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/typeshed-fallback/stdlib/abc.pyi [fs read 1ms] (1ms)
(81585) [BG(1)]     binding: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/typeshed-fallback/stdlib/abc.pyi (0ms)
(81585) [BG(1)]   checking: /Users/rbhanot/dummy_projecte/main.py (106ms)
(81585) [BG(1)] analyzing: /Users/rbhanot/dummy_projecte/main.py (217ms)
(81585) Background analysis message: getSemanticTokens full
(81585) [BG(1)] getSemanticTokens full at /Users/rbhanot/dummy_projecte/main.py (2ms)
(81585) Background analysis message: getDiagnosticsForRange
(81585) Background analysis message: getSemanticTokens range
(81585) [BG(1)] getSemanticTokens range 0:0 - 5:0 at /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) Background analysis message: resumeAnalysis
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: markFilesDirty
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:13 ...
(81585) [FG]   parsing: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG]   binding: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:13 [found 15 items] (16ms)
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: markFilesDirty
(81585) [FG] parsing: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG] binding: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:14 [found 14 items] (9ms)
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:15 ...
(81585) [FG]   parsing: /Users/rbhanot/dummy_projecte/main.py (1ms)
(81585) [FG]   binding: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:15 [found 12 items] (9ms)
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: markFilesDirty
(81585) IntelliCode model /Users/rbhanot/.vscode/extensions/visualstudioexptteam.vscodeintellicode-1.2.24/cache/E61945A9A512ED5E1A3EE3F1A2365B88F8FE_E4E9EADA96734F01970E616FAB2FAC19
(81585) [FG] parsing: /Users/rbhanot/dummy_projecte/main.py (1ms)
(81585) [FG] binding: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) Background analysis message: getSemanticTokens delta
(81585) [BG(1)] getSemanticTokens delta previousResultId:1662224964613 at /Users/rbhanot/dummy_projecte/main.py ...
(81585) [BG(1)]   parsing: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [BG(1)]   binding: /Users/rbhanot/dummy_projecte/main.py (1ms)
(81585) [BG(1)] getSemanticTokens delta previousResultId:1662224964613 at /Users/rbhanot/dummy_projecte/main.py (15ms)
(81585) Background analysis message: analyze
(81585) [BG(1)] analyzing: /Users/rbhanot/dummy_projecte/main.py ...
(81585) [BG(1)]   checking: /Users/rbhanot/dummy_projecte/main.py (2ms)
(81585) [BG(1)] analyzing: /Users/rbhanot/dummy_projecte/main.py (2ms)
(81585) Background analysis message: getDiagnosticsForRange
(81585) Background analysis message: resumeAnalysis
(81585) Background analysis message: getDiagnosticsForRange
[Info  - 10:39:25 PM] (81585) SourceFile: Received fs event 'change' for path '/Users/rbhanot/dummy_projecte/main.py'
[Info  - 10:39:25 PM] (81585) SourceFile: Received fs event 'change' for path '/Users/rbhanot/dummy_projecte/main.py'
[Info  - 10:39:25 PM] (81585) SourceFile: Received fs event 'change' for path '/Users/rbhanot/dummy_projecte/main.py'
[Info  - 10:39:25 PM] (81585) SourceFile: Received fs event 'change' for path '/Users/rbhanot/dummy_projecte/main.py'
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: analyze
(81585) Background analysis message: getDiagnosticsForRange
(81585) Background analysis message: getDiagnosticsForRange
(81585) Loading ONNX runtime...
(81585) Loaded ONNX runtime. Creating IntelliCode session...
(81585) Created IntelliCode session.
(81585) Initialize deeplearning succeeded
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: markFilesDirty
(81585) [FG] parsing: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG] binding: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: markFilesDirty
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:14 ...
(81585) [FG]   parsing: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG]   binding: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:14 [found 14 items] (7ms)
(81585) IntelliCode: current invocation did not produce any meaningful tokens.
(81585) Time taken to get recommendations: 2 ms, Memory increase: 157 KB.
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: markFilesDirty
(81585) [FG] parsing: /Users/rbhanot/dummy_projecte/main.py (1ms)
(81585) [FG] binding: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:13 [found 15 items] (7ms)
(81585) IntelliCode: current invocation did not produce any meaningful tokens.
(81585) Time taken to get recommendations: 1 ms, Memory increase: 84 KB.
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:12 ...
(81585) [FG]   parsing: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG]   binding: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:12 [found 20 items] (14ms)
(81585) IntelliCode: current invocation did not produce any meaningful tokens.
(81585) Time taken to get recommendations: 0 ms, Memory increase: 84 KB.
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: markFilesDirty
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:11 ...
(81585) [FG]   parsing: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG]   binding: /Users/rbhanot/dummy_projecte/main.py (1ms)
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:11 [found 382 items] (23ms)
(81585) IntelliCode: current invocation did not produce any meaningful tokens.
(81585) Time taken to get recommendations: 2 ms, Memory increase: 123 KB.
(81585) Background analysis message: getSemanticTokens delta
(81585) [BG(1)] getSemanticTokens delta previousResultId:1662224965641 at /Users/rbhanot/dummy_projecte/main.py ...
(81585) [BG(1)]   parsing: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [BG(1)]   binding: /Users/rbhanot/dummy_projecte/main.py (1ms)
(81585) [BG(1)] getSemanticTokens delta previousResultId:1662224965641 at /Users/rbhanot/dummy_projecte/main.py (15ms)
(81585) Background analysis message: analyze
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:10 ...
(81585) [FG]   parsing: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG]   binding: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:10 [found 526 items] (10ms)
(81585) IntelliCode: current invocation did not produce any meaningful tokens.
(81585) Time taken to get recommendations: 1 ms, Memory increase: 139 KB.
(81585) [BG(1)] analyzing: /Users/rbhanot/dummy_projecte/main.py ...
(81585) [BG(1)]   checking: /Users/rbhanot/dummy_projecte/main.py (1ms)
(81585) [BG(1)] analyzing: /Users/rbhanot/dummy_projecte/main.py (1ms)
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: resumeAnalysis
(81585) Background analysis message: getSemanticTokens delta
(81585) [BG(1)] getSemanticTokens delta previousResultId:1662224973725 at /Users/rbhanot/dummy_projecte/main.py ...
(81585) [BG(1)]   parsing: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [BG(1)]   binding: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [BG(1)] getSemanticTokens delta previousResultId:1662224973725 at /Users/rbhanot/dummy_projecte/main.py (9ms)
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: markFilesDirty
(81585) [FG] parsing: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG] binding: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) Background analysis message: analyze
(81585) [BG(1)] analyzing: /Users/rbhanot/dummy_projecte/main.py ...
(81585) [BG(1)]   parsing: /Users/rbhanot/dummy_projecte/main.py (1ms)
(81585) [BG(1)]   binding: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [BG(1)]   checking: /Users/rbhanot/dummy_projecte/main.py (9ms)
(81585) [BG(1)] analyzing: /Users/rbhanot/dummy_projecte/main.py (11ms)
(81585) Background analysis message: resumeAnalysis
(81585) Background analysis message: getSemanticTokens delta
(81585) [BG(1)] getSemanticTokens delta previousResultId:1662224974006 at /Users/rbhanot/dummy_projecte/main.py (0ms)
[Info  - 10:39:34 PM] (81585) SourceFile: Received fs event 'change' for path '/Users/rbhanot/dummy_projecte/main.py'
[Info  - 10:39:34 PM] (81585) SourceFile: Received fs event 'change' for path '/Users/rbhanot/dummy_projecte/main.py'
[Info  - 10:39:34 PM] (81585) SourceFile: Received fs event 'change' for path '/Users/rbhanot/dummy_projecte/main.py'
[Info  - 10:39:34 PM] (81585) SourceFile: Received fs event 'change' for path '/Users/rbhanot/dummy_projecte/main.py'
[Info  - 10:39:34 PM] (81585) SourceFile: Received fs event 'change' for path '/Users/rbhanot/dummy_projecte/main.py'
[Info  - 10:39:34 PM] (81585) SourceFile: Received fs event 'change' for path '/Users/rbhanot/dummy_projecte/main.py'
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: analyze
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: markFilesDirty
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:10 ...
(81585) [FG]   parsing: /Users/rbhanot/dummy_projecte/main.py (1ms)
(81585) [FG]   binding: /Users/rbhanot/dummy_projecte/main.py (1ms)
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:10 [found 526 items] (14ms)
(81585) IntelliCode: current invocation did not produce any meaningful tokens.
(81585) Time taken to get recommendations: 1 ms, Memory increase: -593 KB.
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: markFilesDirty
(81585) [FG] parsing: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG] binding: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:11 [found 382 items] (9ms)
(81585) IntelliCode: current invocation did not produce any meaningful tokens.
(81585) Time taken to get recommendations: 1 ms, Memory increase: 131 KB.
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:12 ...
(81585) [FG]   parsing: /Users/rbhanot/dummy_projecte/main.py (1ms)
(81585) [FG]   binding: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG] completion at /Users/rbhanot/dummy_projecte/main.py:3:12 [found 20 items] (7ms)
(81585) IntelliCode: current invocation did not produce any meaningful tokens.
(81585) Time taken to get recommendations: 1 ms, Memory increase: 83 KB.
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: getSemanticTokens delta
(81585) [BG(1)] getSemanticTokens delta previousResultId:1662224974424 at /Users/rbhanot/dummy_projecte/main.py ...
(81585) [BG(1)]   parsing: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [BG(1)]   binding: /Users/rbhanot/dummy_projecte/main.py (1ms)
(81585) [BG(1)] getSemanticTokens delta previousResultId:1662224974424 at /Users/rbhanot/dummy_projecte/main.py (8ms)
(81585) Background analysis message: getDiagnosticsForRange
(81585) Background analysis message: getDiagnosticsForRange
[Info  - 10:39:36 PM] (81585) SourceFile: Received fs event 'change' for path '/Users/rbhanot/dummy_projecte/main.py'
[Info  - 10:39:36 PM] (81585) SourceFile: Received fs event 'change' for path '/Users/rbhanot/dummy_projecte/main.py'
[Info  - 10:39:36 PM] (81585) SourceFile: Received fs event 'change' for path '/Users/rbhanot/dummy_projecte/main.py'
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: getSemanticTokens delta
(81585) [BG(1)] getSemanticTokens delta previousResultId:1662224975720 at /Users/rbhanot/dummy_projecte/main.py ...
(81585) [BG(1)]   parsing: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [BG(1)]   binding: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [BG(1)] getSemanticTokens delta previousResultId:1662224975720 at /Users/rbhanot/dummy_projecte/main.py (7ms)
(81585) Background analysis message: setFileOpened
(81585) Background analysis message: markFilesDirty
(81585) [FG] parsing: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [FG] binding: /Users/rbhanot/dummy_projecte/main.py (1ms)
(81585) Background analysis message: getDiagnosticsForRange
(81585) Background analysis message: getDiagnosticsForRange
(81585) Background analysis message: getSemanticTokens delta
(81585) [BG(1)] getSemanticTokens delta previousResultId:1662224976360 at /Users/rbhanot/dummy_projecte/main.py ...
(81585) [BG(1)]   parsing: /Users/rbhanot/dummy_projecte/main.py (1ms)
(81585) [BG(1)]   binding: /Users/rbhanot/dummy_projecte/main.py (0ms)
(81585) [BG(1)] getSemanticTokens delta previousResultId:1662224976360 at /Users/rbhanot/dummy_projecte/main.py (8ms)
[Info  - 10:39:36 PM] (81585) SourceFile: Received fs event 'change' for path '/Users/rbhanot/dummy_projecte/main.py'
[Info  - 10:39:36 PM] (81585) SourceFile: Received fs event 'change' for path '/Users/rbhanot/dummy_projecte/main.py'
[Info  - 10:39:36 PM] (81585) SourceFile: Received fs event 'change' for path '/Users/rbhanot/dummy_projecte/main.py'
[Info  - 10:39:36 PM] (81585) SourceFile: Received fs event 'change' for path '/Users/rbhanot/dummy_projecte/main.py'
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: markFilesDirty
(81585) Background analysis message: getDiagnosticsForRange
(81585) Background analysis message: getDiagnosticsForRange
(81585) Background analysis message: analyze
(81585) [BG(1)] analyzing: /Users/rbhanot/dummy_projecte/main.py ...
(81585) [BG(1)]   checking: /Users/rbhanot/dummy_projecte/main.py (2ms)
(81585) [BG(1)] analyzing: /Users/rbhanot/dummy_projecte/main.py (2ms)
(81585) Background analysis message: resumeAnalysis
(81585) Background analysis message: getDiagnosticsForRange
(81585) Background analysis message: getDiagnosticsForRange
heejaechang commented 2 years ago

Showing auto import entries in completion is expensive operation. so we won't scan and show everything. we do not want to show completion with a few thousands entries for every possible match in every possible packages installed.

so by default, we only show as small as we can. basically we only show ones user already used in some way, and nothing new. and only third party packages will be shown in completion, user types will be only in code action.

but we do provide knobs for users as long as they accept the perf hit.

First knob is the "python.analysis.indexing", if user turns it on, we will spend more time to analyze packages, user files before-hand to build indexing. that will make more items to show up in completion and code actions.

but, if that is not enough, you can add this hidden option to your settings.json. see this comment - https://github.com/microsoft/pylance-release/issues/2991#issuecomment-1176560066

after that, you should be able to see all types defined in packages.

by the way, Workspace indexing has hit its upper limit: 2000 files this is for user files. so for your case, this shouldn't matter.

heejaechang commented 2 years ago

by the way, did you select right interpreter that has all packages installed? image

rbhanot4739 commented 2 years ago

@heejaechang for the response, yeah I have selected the right interpreter and it has all the packages installed.

so by default, we only show as small as we can. basically we only show ones user already used in some way, and nothing new. and only third party packages will be shown in completion, user types will be only in code action.

The issue for me is that third party packages are not being shown in the completion list unless i turn on the indexing with python.analysis.indexing: true. And even after turning on the hidden option "python.analysis.packageIndexDepths":[["",20, true]] still I don't see all of the relevant entries in the completion, i.e. for my my specific case, I don't see Request completion entry from flask, starlette; even though you might never have these two packages in a single project but I am just trying to highlight namespace collision here.

I also checked the https://github.com/microsoft/pylance-release/issues/2991#issuecomment-1176560066 where you mentioned for library packages only the toplevel symbols are being shown in completion list, so even though the Request module in import in the __init__.py of flask package it still does not show in the completion list.

Let me know if you need more details to troubleshoot more on this.

by the way, Workspace indexing has hit its upper limit: 2000 files this is for user files. so for your case, this shouldn't matter.

Does that mean this limit is only for workspace source files only ?

heejaechang commented 2 years ago

so, it works for me as you can see below.

image

for me, flask works only with "python.analysis.indexing" on, for startlette, need hidden option to include all symbols for me.

just to be clear, if you had everything on, did you wait for indexing to actually finish? you should have something like this in "Python Language Server" output pane.

[Info  - 10:55:41 PM] (60736) Indexing(3) started
[Info  - 10:56:13 PM] (60736) [IDX(3)] Long operation: index execution environment e:\python (29964ms)
[Info  - 10:56:13 PM] (60736) [IDX(3)] Long operation: index libraries e:\python (32082ms)
[Info  - 10:56:13 PM] (60736) Indexer done(3). indexed 1450 files

Does that mean this limit is only for workspace source files only ?

It means that limitation is for files under your opened folders, not ones in site-packages (such as ones in venv).

heejaechang commented 2 years ago

by the way, if "python.analysis.packageIndexDepths":[["",20, true]] takes too long to index (for me, it took about 30 seconds to index everything in site-packages), you can put explicit package name at the hidden option and how deep you want to scan.

"python.analysis.packageIndexDepths":[["package name", number of level to scan, include all symbols]]

package name - ex) flask, starlette number of level to scan - ex) 1 will scan only starlette, 2 will scan starlette.requests and so on. include all symbols - ex) true will put every top level symbols in the module to indices, false will only put symbols that appear in __all__ to indicies.

ex) "python.analysis.packageIndexDepths":[["flask", 1, false], ["starlette", 2, true]]

rbhanot4739 commented 2 years ago

Does the indexer runs every-time I launch vscode or it indexes the packages and stores somewhere unless the sources change ?

heejaechang commented 2 years ago

it launches every time, and that is the reason we limit it by default and user has to explicitly opt-in.

we do considered caching but for now, decided not to do it due to all the complication comes from caching. but we might do it in future, but not now.

rbhanot4739 commented 2 years ago

So I have set this "python.analysis.packageIndexDepths": [["",20, true]] just to test and I still don't see flask or starlette.

image

And yes the indexer did complete

[Info  - 11:57:08 AM] (67691) Indexing(5) started
[Info  - 11:57:12 AM] (67691) [IDX(5)] Long operation: index execution environment /Users/rbhanot/dummy_projecte (2747ms)
[Info  - 11:57:12 AM] (67691) [IDX(5)] Long operation: index libraries /Users/rbhanot/dummy_projecte (3709ms)
[Info  - 11:57:12 AM] (67691) Indexer done(5). indexed 1162 files
rbhanot4739 commented 2 years ago

Okay it shows for flask now but still starlette imports won't show.

heejaechang commented 2 years ago

can you provide logs with "python.analysis.logLevel": "Trace"?

that should give us info on what files are indexed.

rbhanot4739 commented 2 years ago

Here is the log file logs.txt

heejaechang commented 2 years ago

I see this - (74407) [IDX(2)] indexing: /Users/rbhanot/development/personal/self-learning/venv/lib/python3.10/site-packages/starlette/requests.py [found 21] (1ms)

so, it is indexed. so, should be there.

can you try this "python.analysis.packageIndexDepths": [["starlette",3, true]] ? and see whether it shows up?

rbhanot4739 commented 2 years ago

No it still doesn't show up even though the file is being indexed

(2984) [IDX(2)]       parsing: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/typeshed-fallback/stdlib/http/__init__.pyi [fs read 1ms] (1ms)
(2984) [IDX(2)]       binding: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.8.51/dist/typeshed-fallback/stdlib/http/__init__.pyi (0ms)
(2984) [IDX(2)]     indexing: /Users/rbhanot/development/personal/self-learning/venv/lib/python3.10/site-packages/starlette/requests.py [found 21] (1ms)

This is what settings look "python.analysis.packageIndexDepths": [ [ "", 20, true ], [ "starlette", 3, true ] ],

image

heejaechang commented 2 years ago

remove this [ "", 20, true ], part

rbhanot4739 commented 2 years ago

I tried that as well and still same thing, the starlette requests surely gets indexed as evident from logs

(28680) [IDX(2)]       parsing: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.9.11/dist/typeshed-fallback/stdlib/http/__init__.pyi [fs read 0ms] (1ms)
(28680) [IDX(2)]       binding: /Users/rbhanot/.vscode/extensions/ms-python.vscode-pylance-2022.9.11/dist/typeshed-fallback/stdlib/http/__init__.pyi (0ms)
(28680) [IDX(2)]     indexing: /Users/rbhanot/development/personal/self-learning/venv/lib/python3.10/site-packages/starlette/requests.py [found 21] (1ms)

And this is how "python.analysis.packageIndexDepths": [[ "starlette", 3, true ] ]` looks now and this is what I see now

image

rbhanot4739 commented 2 years ago

Any further update on this ?

heejaechang commented 2 years ago

I doesn't repro for me, can you share zip file that has python files that let me repro the issue? the log said, it is indexed, and it works for me when I try locally, so it might be something that we don't know affecting the completion, but without live repro, hard to figure out.

heejaechang commented 2 years ago

please, reopen if it still happens.

nguyenit67 commented 1 year ago

@rbhanot4739 You might want to add this line to settings.json as well:

"python.analysis.autoImportCompletions": true 
mperon commented 1 year ago

To me, these settings fix it:

    "python.analysis.autoImportCompletions": true,
    "python.autoComplete.extraPaths": ["${workspaceFolder}/src"],
    "python.analysis.extraPaths": ["${workspaceFolder}/src"],
    "python.analysis.indexing": true,
    "python.analysis.packageIndexDepths": [
        { "name": "", "depth": 20, "includeAllSymbols": true }
    ]