Microsoft has pulled back the drapes on Pylance, a Visual Studio Code extension for faster and more complete Python language support in that popular code editor.
Pylance doesn't replace the existing Microsoft-authored Python extension for Visual Studio Code, which has some 21 million installations to its name.
Instead, Pylance expands on the existing Python extension to provide fast, static type checking (using Microsoft's Pyright project), live type information about symbols, autocomplete, auto-imports, code outlining and navigation, and other tools for Python development.
Pylance works with Jupyter notebooks, when those are in use in a project. It can also use custom type stubs from a project directory with the
python.analysis.stubPaths option. It's also possible for workspaces, users, or projects to customise which errors get flagged on a codebase and what level of severity to assign them.
For instance, if you have a lot of code that creates variables conditionally, and which you know doesn't create issues, you can disable the
reportUnboundVariable option to avoid flagging such code.
When the auto-imports feature is enabled, it automatically inserts appropriate imports for libraries recognised in Pylance's search path. If you type
gc.disable() for instance, Pylance will infer that you are referring to the gc module in the standard library, and automatically add
import gc as needed at the top of your project.
For the most part, Pylance should work as-is with existing projects, but it may need some special configuration in a couple of cases.
For example, if Pylance flags imports in a project and claims they can't be found, you may need to customise Pylance's search path for the project by adding the
python.analysis.extraPaths attribute in