Microsoft has released a new version of its Python extension for Visual Studio Code. With the May update Pylance advances to the new standard language server. As an optional extension, Pylance is now an integral part of the core bundle of the Python Extension for Visual Studio Code. Developers can also look forward to new features in the debugger and faster startup times for the extensions.
Free choice of the Language Server remains
The language server Pylance, which provides in interaction with IntelliSense in the editor among other things extensive type information including potentially available declarations, had integrated Microsoft only last year into the Python extension. Pylance also has the static type checker Pyright, which is aimed primarily at coarse Python code bases. Improvements in the communication between the Language Server and the Python Extension (via Language Server Protocol) should contribute to more performance – but also further optimize the work with open source alternatives like the Jedi Language Server and others. Because even though Pylance is now officially the default language server, developers retain the freedom to select other language servers and use them in settings.json or explicitly via the Settings UI.
The debugger in the Python Extension for Visual Studio now allows to load new modified code even during an already running investigation. This auto-load feature has been available with Django and Flask for about a year, but now it can be used for Python scripts as well. The debugger checks the freshly imported code without a restart. However, to avoid duplicate checks, only imports, constants and definitions should be used in the module if possible, and all the code in functions or "if __name__ == "__main__"-checks, like the following "Hogwarts"-example shows:
Auto Load is now also available for Python scripts in the debugger.
More details about the new features in the Python Extension for Visual Studio can be found in the Developer Blog at Microsoft. The extension can be downloaded via the Visual Studio Marketplace or alternatively loaded directly from the Extension Gallery into Visual Studio Code.