Serdar Yegulalp
Senior Writer

Microsoft unveils Pylance, its new Python extension for Visual Studio Code

news
Jul 02, 20202 mins
Development ToolsOpen SourcePython

Pylance works with the existing Microsoft Python extension to bring faster type checking and program analysis to Python devs

python programming language snake
Credit: Thinkstock

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 customize 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 recognized 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 customize Pylance’s search path for the project by adding the python.analysis.extraPaths attribute in settings.json.

Serdar Yegulalp
Senior Writer

Serdar Yegulalp is a senior writer at InfoWorld, covering software development and operations tools, machine learning, containerization, and reviews of products in those categories. Before joining InfoWorld, Serdar wrote for the original Windows Magazine, InformationWeek, the briefly resurrected Byte, and a slew of other publications. When he's not covering IT, he's writing SF and fantasy published under his own personal imprint, Infinimata Press.

More from this author