Skip to content

How can I get Pylance to "assume" the version of Python I am running? #22191

@philosofool

Description

@philosofool

The Python Langauge Server Output in VSCode reports "Assuming Python 3.8" but I would like it to detect the current version of Python or, at least, be configured to run with the version of Python that I am using.
Sample Output:

2023-10-10 17:03:44.967 [info] [Info  - 5:03:44 PM] (112106) Pylance language server 2023.10.10 (pyright 45942a15) starting
2023-10-10 17:03:44.967 [info] [Info  - 5:03:44 PM] (112106) Server root directory: /home/jovyan/.vscode-server/extensions/ms-python.vscode-pylance-2023.10.10/dist
2023-10-10 17:03:44.968 [info] [Info  - 5:03:44 PM] (112106) Starting service instance "code"
2023-10-10 17:03:44.973 [info] [Info  - 5:03:44 PM] (112106) Auto format for strings enabled
2023-10-10 17:03:45.013 [info] [Info  - 5:03:45 PM] (112106) Setting pythonPath for service "code": "/bin/python3"
2023-10-10 17:03:45.013 [info] [Info  - 5:03:45 PM] (112106) Setting environmentName for service "code": "3.8.10 (global)"
2023-10-10 17:03:45.023 [info] [Warn  - 5:03:45 PM] (112106) stubPath /code/typings is not a valid directory.
2023-10-10 17:03:45.044 [info] [Info  - 5:03:45 PM] (112106) Assuming Python version 3.8
2023-10-10 17:03:45.829 [info] [Info  - 5:03:45 PM] (112106) Found 388 source files

From terminal, python --version outputs python 3.9.10. However, Pylance language server is "assuming Python 3.8" according to the Python Language Server output. I believe this is the cause of a Pylance false positive when type hinting with indexed classes, e.g. def flatten(list[list]): I get an error Subscript for class "list" will generate runtime exception; enclose type annotation in quotes (Perhaps this isn't really a false positive, if it's using Python 3.8, which did not support that typing syntax, but I think you see my point.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage-neededNeeds assignment to the proper sub-team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions