microsoft / pylance-release

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

pyrightconfig.json assumes base directory when no entries are included, disregarding python.analysis.include #6545

Open BaconPancakes opened 1 week ago

BaconPancakes commented 1 week ago

Environment data

Code Snippet

pyrightconfig.json in base workspace

{
    "exclude": [
        "**/bazel-*/**"
    ]
}

.code-workspace file:

"python.analysis.include": [
            "my_dir_redacted1",
            "my_dir_redacted2",
        ],

The workspace above is currently open.

Repro Steps

  1. Start the Python language server.

Expected behavior

Only the directories specified in python.analysis.include via workspace settings are indexed/analyzed.

Actual behavior

The entire repo is included (as such, hits the indexing limit), because it was "assumed" due to pyrightconfig.json not specifying any includes. Errors are thrown on includes from python.analysis.include File or directory "/<default workspace root>/my_dir_redacted" does not exist

Logs

2024-10-09 18:42:05.953 [info] (Client) Pylance async client (2024.10.1) started with python extension (2024.17.2024100801)
2024-10-09 18:42:06.361 [info] [Info  - 6:42:06 PM] (1081219) Server root directory: file:///home/redacted_user/.vscode-server/extensions/ms-python.vscode-pylance-2024.10.1/dist
2024-10-09 18:42:06.361 [info] [Info  - 6:42:06 PM] (1081219) Pylance language server 2024.10.1 (pyright version 1.1.382, commit e46efc6b) starting
2024-10-09 18:42:06.368 [info] [Info  - 6:42:06 PM] (1081219) Starting service instance "redacted_project"
2024-10-09 18:42:06.431 [info] [Info  - 6:42:06 PM] (1081219) Loading configuration file at /home/redacted_user/checkouts/redacted_project/pyrightconfig.json
2024-10-09 18:42:06.435 [info] [Info  - 6:42:06 PM] (1081219) Setting pythonPath for service "redacted_project": "/home/redacted_user/checkouts/redacted_project/bazel-redacted_project/external/python3_8_x86_64/bin/python3.8"
2024-10-09 18:42:06.436 [info] [Info  - 6:42:06 PM] (1081219) No include entries specified; assuming /home/redacted_user/checkouts/redacted_project
2024-10-09 18:42:06.558 [info] [Info  - 6:42:06 PM] (1081219) Assuming Python version 3.8.10.final.0
2024-10-09 18:42:20.342 [info] [Info  - 6:42:20 PM] (1081219) Found 31669 source files
2024-10-09 18:42:20.365 [info] [Info  - 6:42:20 PM] (1081219) Background analysis(1) root directory: file:///home/redacted_user/.vscode-server/extensions/ms-python.vscode-pylance-2024.10.1/dist
2024-10-09 18:42:20.366 [info] [Info  - 6:42:20 PM] (1081219) Background analysis(1) started
2024-10-09 18:42:20.720 [info] [Info  - 6:42:20 PM] (1081219) Indexer background runner(2) root directory: file:///home/redacted_user/.vscode-server/extensions/ms-python.vscode-pylance-2024.10.1/dist (index)
2024-10-09 18:42:20.721 [info] [Info  - 6:42:20 PM] (1081219) Indexing(2) started
2024-10-09 18:42:22.856 [info] [Info  - 6:42:22 PM] (1081219) scanned(2) 295 files over 1 exec env
2024-10-09 18:42:23.222 [info] [Info  - 6:42:23 PM] (1081219) indexed(2) 295 files over 1 exec env
2024-10-09 18:42:23.318 [info] [Info  - 6:42:23 PM] (1081219) Indexing finished(2).
2024-10-09 18:44:21.969 [info] [Info  - 6:44:21 PM] (1081219) Emptying type cache to avoid heap overflow. Used 3552MB out of 4144MB.
2024-10-09 18:44:22.026 [info] [Info  - 6:44:22 PM] (1081219) Emptying type cache to avoid heap overflow. Used 3557MB out of 4144MB.
2024-10-09 18:44:22.286 [info] [Info  - 6:44:22 PM] (1081219) Emptying type cache to avoid heap overflow. Used 3568MB out of 4144MB.
2024-10-09 18:44:22.363 [info] [Info  - 6:44:22 PM] (1081219) Emptying type cache to avoid heap overflow. Used 3567MB out of 4144MB.
2024-10-09 18:44:22.450 [info] [Info  - 6:44:22 PM] (1081219) Emptying type cache to avoid heap overflow. Used 3577MB out of 4144MB.
2024-10-09 18:44:22.497 [info] [Info  - 6:44:22 PM] (1081219) Emptying type cache to avoid heap overflow. Used 3582MB out of 4144MB.
2024-10-09 18:44:22.546 [info] [Info  - 6:44:22 PM] (1081219) Emptying type cache to avoid heap overflow. Used 3588MB out of 4144MB.
2024-10-09 18:44:22.612 [info] [Info  - 6:44:22 PM] (1081219) Emptying type cache to avoid heap overflow. Used 3599MB out of 4144MB.
2024-10-09 18:44:22.702 [info] [Info  - 6:44:22 PM] (1081219) Emptying type cache to avoid heap overflow. Used 3609MB out of 4144MB.
2024-10-09 18:44:22.746 [info] [Info  - 6:44:22 PM] (1081219) Emptying type cache to avoid heap overflow. Used 3615MB out of 4144MB.
2024-10-09 18:44:22.794 [info] [Info  - 6:44:22 PM] (1081219) Emptying type cache to avoid heap overflow. Used 3621MB out of 4144MB.
2024-10-09 18:44:22.843 [info] [Info  - 6:44:22 PM] (1081219) Emptying type cache to avoid heap overflow. Used 3627MB out of 4144MB.
2024-10-09 18:44:22.895 [info] [Info  - 6:44:22 PM] (1081219) Emptying type cache to avoid heap overflow. Used 3633MB out of 4144MB.
2024-10-09 18:44:22.990 [info] [Info  - 6:44:22 PM] (1081219) Emptying type cache to avoid heap overflow. Used 3637MB out of 4144MB.
2024-10-09 18:44:23.319 [info] [Info  - 6:44:23 PM] (1081219) Emptying type cache to avoid heap overflow. Used 3644MB out of 4144MB.
2024-10-09 18:44:50.402 [info] [Info  - 6:44:50 PM] (1081219) Starting service instance "<default>"
2024-10-09 18:44:50.511 [info] [Info  - 6:44:50 PM] (1081219) Setting environmentName for service "<default>": "3.8.10 (global)"
2024-10-09 18:44:50.512 [info] [Info  - 6:44:50 PM] (1081219) Setting pythonPath for service "<default>": "/home/redacted_user/checkouts/redacted_project/bazel-redacted_project/external/python3_8_x86_64/bin/python3.8"
2024-10-09 18:44:50.512 [info] [Info  - 6:44:50 PM] (1081219) Auto-excluding **/node_modules
2024-10-09 18:44:50.512 [info] [Info  - 6:44:50 PM] (1081219) Auto-excluding **/__pycache__
2024-10-09 18:44:50.512 [info] [Info  - 6:44:50 PM] (1081219) Auto-excluding **/.*
2024-10-09 18:44:50.586 [info] [Info  - 6:44:50 PM] (1081219) Assuming Python version 3.8.10.final.0
2024-10-09 18:44:50.752 [info] [Error - 6:44:50 PM] (1081219) File or directory "/<default workspace root>/my_dir_redacted1" does not exist.
2024-10-09 18:44:50.752 [info] [Error - 6:44:50 PM] (1081219) File or directory "/<default workspace root>/my_dir_redacted2" does not exist.
2024-10-09 18:44:50.753 [info] [Info  - 6:44:50 PM] (1081219) No source files found.
2024-10-09 18:44:53.862 [info] [Info  - 6:44:53 PM] (1081219) Background analysis(3) root directory: file:///home/redacted_user/.vscode-server/extensions/ms-python.vscode-pylance-2024.10.1/dist
2024-10-09 18:44:53.863 [info] [Info  - 6:44:53 PM] (1081219) Background analysis(3) started
2024-10-09 18:45:03.947 [info] [Warn  - 6:45:03 PM] (1081219) Workspace indexing has hit its upper limit: 10000 files
BaconPancakes commented 1 week ago

This is likely related to #6446 . This behavior really ought to reverted or at least configurable.

BaconPancakes commented 1 week ago

Even without overriding pyrightconfig.json, I'm still getting these missing file errors from the python.analysis.include directories:

File or directory "/<default workspace root>/my_dir_redacted" does not exist

rchiodo commented 6 days ago

This error message is expected and can be ignored. It's for the 'default' workspace that we always create in the background. It's just some logging that we need to cleanup and has no impact on anything.

File or directory "/<default workspace root>/my_dir_redacted"

But yes, you are correct. Pyrightconfig.json now takes precedence over everything.