Python in Visual Studio Code – June 2021 Release

We are pleased to announce that the June 2021 release of the Python Extension for Visual Studio Code is now available. You can download the Python extension from the Marketplace, or install it directly from the Extensions View in Visual Studio Code. If you already have the Python extension installed, you can also get the latest update by restarting Visual Studio Code. You can learn more about Python support in Visual Studio Code in the documentation.

This release includes support for VS Code’s Workspace Trust, Jump-To-Source code with the PyTorch Profiler and completions for dictionary keys with Pylance.

If you’re interested, you can check the full list of improvements in our changelog.

Workspace Trust

The newest release of VS Code introduced a Workspace Trust feature, that allows you to decide if you trust the project folders you open it in VS Code or not. If you don’t trust a folder or workspace, you are still able to browse your files in restricted mode.

When in a trusted workspace, the Python extension will automatically search for Python environments in your machine so you can select one for your project, and it will provide all of its features such as auto completions, code navigation, linting, formatting, testing, etc.

When opening folders that you don’t trust, you can browse the files in restricted mode. In this case, the Python extension will not load – and that is to prevent automatic, potentially malicious code execution.

Because you can always enable trust later, we recommend you open folders in restricted mode when in doubt. That way you can always inspect the files and content in the folder before you make a decision.

To manage Workspace Trust, you can run the “Workspace: Manage Workspace Trust” command in the command palette (View > Command Palette…).

Out of an abundance of caution, we strongly advise you to upgrade VS Code to version 1.57 for the protections provided by workspace trust. You can learn more about the Workspace Trust feature in the documentation.

PyTorch Profiler Jump-To-Source Code

One of the great benefits of having both TensorBoard and the PyTorch Profiler integrated directly in VS Code is having both your code and data science productivity tooling in the same space.

With the latest release of the Python extension, along with the latest PyTorch Profiling Plugin 0.2.0, we’ve added the ability to directly jump back to the source code (file and line) from the profiler stack traces.  When you click on a stack trace from the PyTorch Profiler, VS Code will automatically open the corresponding file side by side and highlight/focus directly on the line of code of interest. This allows you to quickly make actionable optimizations and changes to your code based on the Profiler results and suggestions.

Completions for Dictionary Keys with Pylance

As of this release, Pylance now supports dictionary key completions. These completions will be provided for dictionaries created using dict() or literal syntax, {}.

Other Changes and Enhancements

We have also added small enhancements and fixed issues requested by users that should improve your experience working with Python in Visual Studio Code. Some notable changes include:

The Jupyter extension is now an optional dependency, which means you can keep using the Python extension if you uninstall or disable the Jupyter one. (#16102)
Fix for bandit linter bug where messages weren’t being propagated to the editor. (thanks Anthony Shaw) (#15561)
Fix for bug causing blank TensorBoard panes on Windows. (#16072)
Enable controlled rollout for deprecating python.pythonPath and adding python.defaultInterpreterPath to the workspace level.  (#2125).

Be sure to download the Python extension for Visual Studio Code now to try out the above improvements. If you run into any problems or have suggestions, please file an issue on the Python VS Code GitHub page.

The post Python in Visual Studio Code – June 2021 Release appeared first on Python.

Flatlogic Admin Templates banner

Leave a Reply

Your email address will not be published. Required fields are marked *