pylance-release README

项目的 README,来自 github.com/microsoft/pylance-release。合并为一个 markdown 文件:README.md。

Pylance

Fast, feature-rich language support for Python

This repository is for providing feedback and documentation on the Pylance language server extension in Visual Studio Code. You can use the repository to report issues or submit feature requests. The Pylance codebase is not open-source but you can contribute to Pyright to make improvements to the core typing engine that powers the Pylance experience.

Pylance is the default language support for Python in Visual Studio Code and is shipped as part of that extension as an optional dependency.

The Pylance name is a small ode to Monty Python's Lancelot who was the first knight to answer the bridgekeeper's questions in the Holy Grail.

Quick Start

  1. Install the Python extension from the marketplace. Pylance will be installed as an optional extension.
  2. Open a Python (.py) file and the Pylance extension will activate.

Note: If you've previously set a language server and want to try Pylance, make sure you've set "python.languageServer": "Default" or "Pylance" in your settings.json file using the text editor, or using the Settings Editor UI.

Features

 features

Pylance provides some awesome features for Python 3, including:

See the changelog for the latest release.

Settings and Customization

Pylance provides users with the ability to customize their Python language support via a host of settings which can either be placed in the settings.json file in your workspace, or edited through the Settings Editor UI.

Semantic highlighting

Visual Studio Code uses TextMate grammars as the main tokenization engine. TextMate grammars work on a single file as input and break it up based on lexical rules expressed in regular expressions.

Semantic tokenization allows language servers to provide additional token information based on the language server's knowledge on how to resolve symbols in the context of a project. Themes can opt-in to use semantic tokens to improve and refine the syntax highlighting from grammars. The editor applies the highlighting from semantic tokens on top of the highlighting from grammars.

Here's an example of what semantic highlighting can add:

Without semantic highlighting:

 semantic highlighting disabled

With semantic highlighting:

 semantic highlighting enabled

Semantic colors can be customized in settings.json by associating the Pylance semantic token types and modifiers with the desired colors.

The scope inspector tool allows you to explore what semantic tokens are present in a source file and what theme rules they match to.

Example of customizing semantic colors in settings.json:

{
    "editor.semanticTokenColorCustomizations": {
        "[One Dark Pro]": { // Apply to this theme only
            "enabled": true,
            "rules": {
                "magicFunction:python": "#ee0000",
                "function.declaration:python": "#990000",
                "*.decorator:python": "#0000dd",
                "*.library:python": "#008000",
                "*.typeHint:python": "#5500aa",
                "*.typeHintComment:python": "#aaaaaa"
            }
        }
    }
}

Code Actions

Pylance provides a set of code actions that are available through the lightbulb menu (or Ctrl+. / Cmd+.). The exact titles can vary depending on context (e.g. the unresolved symbol name), but the actions below are what Pylance can offer.

Quick Fixes

Refactorings

AI-assisted code actions (require Copilot)

Source (whole-file) code actions

Troubleshooting

Known issues are documented in TROUBLESHOOTING.

Repeated crashes

In desktop VS Code, Pylance automatically restarts after an unexpected server exit. To avoid an endless crash loop, it stops restarting after five crashes unless the server has run continuously for at least 10 minutes between failures. Reaching a ready state briefly does not reset this count; time spent starting or stopped does not count toward recovery. The five-crashes-in-three-minutes limit also remains in effect.

If Pylance stops restarting, inspect the Pylance output channel for crash details and address the reported cause before reloading the VS Code window to try again. The restart limits prevent repeated failures from continuing indefinitely; they do not fix the cause of a crash.

Contributing

Pylance leverages Microsoft's open-source static type checking tool, Pyright, to provide performant language support for Python.

Code contributions are welcomed via the Pyright repo.

Pylance ships with a collection of type stubs for popular modules to provide fast and accurate auto-completions and type checking. Our type stubs are sourced from typeshed and our work-in-progress stub repository, microsoft/python-type-stubs. Type stubs in microsoft/python-type-stubs will be contributed back to typeshed or added inline to source packages once they are of high enough quality.

For information on getting started, refer to the CONTRIBUTING instructions.

Feedback

License

See Pylance's license and the pylance-release repository's license for more information.

Last content update aligned with Pylance 2026.4.100.

pylance-release (microsoft/pylance-release)

正在搜索数据库…

这是什么?Pylance 是 Visual Studio Code 默认的 Python 语言服务器,提供快速的 IntelliSense 代码提示、类型检查和代码导航。本仓库只包含它的文档和问题跟踪,不包含 Pylance 本身的代码。
这里是 Pylance 的源代码,还是只有文档和问题反馈?只有文档和问题反馈。Pylance 的代码本身是闭源的,随 Python 扩展一起发布;本仓库仅用于提交漏洞报告和查阅文档。
我该如何在 VS Code 中运行 Pylance?从 VS Code Marketplace 安装 Python 扩展即可,它会将 Pylance 作为可选依赖一并装上;然后打开任意 .py 文件,Pylance 就会启用。
Pylance 生效前,我需要做什么配置吗?如果之前选择过其他语言服务器,需要在 settings.json 中把 python.languageServer 设置为 Default 或 Pylance,VS Code 才会真正使用它。
我能自己修复 Pylance 的漏洞吗?不能。由于 Pylance 的代码是闭源的,你无法直接向它提交 PR;只能通过为开源项目 Pyright 贡献代码,来改进底层的类型检查引擎。
Pylance 提供哪些主要功能?文档字符串(Docstrings)、带类型信息的签名提示、参数建议、代码补全、自动导入、输入时实时诊断、代码大纲与导航、语义高亮,以及原生的多根工作区支持等。
我能控制 Pylance 的分析强度吗?可以。python.analysis.languageServerMode 设置提供 light、default 和 full 三种预设,用于在功能丰富度与性能之间取舍;typeCheckingMode、diagnosticMode 等单项设置也可以分别调整。
Pylance 支持 Jupyter Notebook 吗?支持。除了普通的 .py 文件,Pylance 也兼容 Jupyter Notebook。
为什么叫 Pylance?这个名字是对 Monty Python 中兰斯洛特爵士(Sir Lancelot)的小小致敬。在《巨蟒和圣杯》中,他是第一个回答桥守问题的骑士。
作者
microsoft
大小
15.5 MB
星标
2.2K
时长
6年
提交 · 90 天