{"id":9015,"date":"2022-08-04T12:56:53","date_gmt":"2022-08-04T20:56:53","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/python\/?p=9015"},"modified":"2022-08-05T09:34:49","modified_gmt":"2022-08-05T17:34:49","slug":"python-in-visual-studio-code-august-2022-release","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-august-2022-release\/","title":{"rendered":"Python in Visual Studio Code \u2013 August 2022 Release"},"content":{"rendered":"<p>We\u2019re excited to announce that the August 2022 release of the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-python.python\">Python<\/a> and <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-toolsai.jupyter\">Jupyter<\/a> extensions for Visual Studio Code are now available!<\/p>\n<p>This release includes the following improvements:<\/p>\n<ul>\n<li>Automatic debug configurations for web apps<\/li>\n<li>Improvements to the Getting Started Experience<\/li>\n<li>Setting to configure the display of the interpreter information on the status bar<\/li>\n<li>A new Python Tools extension template<\/li>\n<li>Remove all unused imports with Pylance<\/li>\n<li>Double click to accept type hints with Pylance<\/li>\n<li>Copy output image in Jupyter cells<\/li>\n<li>Go to most recently failed cell<\/li>\n<\/ul>\n<p>If you\u2019re interested, you can check the full list of improvements in our changelogs for the <a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/releases\">Python<\/a>, <a href=\"https:\/\/github.com\/microsoft\/vscode-jupyter\/blob\/main\/CHANGELOG.md\">Jupyter<\/a> and <a href=\"https:\/\/github.com\/microsoft\/pylance-release\/blob\/main\/CHANGELOG.md\">Pylance<\/a> extensions.<\/p>\n<h2>Automatic debug configurations for web apps<\/h2>\n<p>To simplify the process of setting up VS Code to run and\/or debug your web applications, this release includes new automatic debug configurations for projects that use <a href=\"https:\/\/code.visualstudio.com\/docs\/python\/tutorial-flask\">Flask<\/a>, <a href=\"https:\/\/code.visualstudio.com\/docs\/python\/tutorial-django\">Django<\/a> or <a href=\"https:\/\/fastapi.tiangolo.com\/tutorial\/\">FastAPI<\/a>.<\/p>\n<p>When you open the Run and Debug view in VS Code (Ctrl + Shift + D or \u2318+ \u21e7 + D) and there is no debugger configuration (i.e., no launch.json file) on your workspace, you will see an \u201cshow all automatic debug configurations\u201d option. If your project is a web application that follows the format expected by Flask, Django or FastAPI, once you click on that option you will be able to see debug configurations that were dynamically created to execute and debug your project. Now you can just select it to start catching all the bugs!<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-fastapidebugconfig.gif\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-9017\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-fastapidebugconfig.gif\" alt=\"Debugging a FastAPI application by selecting an dynamically created debug configuration for FastAPI. \" width=\"1804\" height=\"1194\" \/><\/a><em>Theme: <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ftsamoyed.theme-pink-cat-boo\">Pink-Cat-Book<\/a><\/em><\/p>\n<h2>Improvements to the Getting Started Experience<\/h2>\n<p>The\u00a0<a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-python.python\">Python extension<\/a> walkthrough has been improved to more easily guide users to installing Python when needed, and selecting it in VS Code. When Python is not installed on a Windows machine, selecting the \u201cInstall Python\u201d button from the walkthrough will open the Python app in the Microsoft Store. When on Linux or macOS, the displayed installation instructions will be automatically run in the terminal.<\/p>\n<p>Another improvement related to the getting started experience is that notifications for selecting the interpreter are now only shown when an interpreter is required (e.g. when running or debugging a file, or a tool such as a linter or formatter), and no longer on start-up. Other notification prompts have also been improved to be more precise about errors and suggested changes.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-GSWalkthrough.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-9018\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-GSWalkthrough.png\" alt=\"Python extension walkthrough with a create Python file button.\" width=\"1394\" height=\"707\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-GSWalkthrough.png 1394w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-GSWalkthrough-300x152.png 300w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-GSWalkthrough-1024x519.png 1024w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-GSWalkthrough-768x390.png 768w\" sizes=\"(max-width: 1394px) 100vw, 1394px\" \/><\/a><\/p>\n<h2>Python interpreter display on the status bar<\/h2>\n<p>We introduced a new User setting called <code>\u201cpython.interpreter.infoVisibility\u201d<\/code>, which controls when the selected interpreter information is displayed in the status bar. You can set <code>\"python.interpreter.infoVisibility\": \u201calways\u201d<\/code> on your User settings (<strong>Preferences &gt; Command Palette\u2026 &gt; Open User Settings (JSON)<\/strong>) to always display it regardless of what file is opened. By default, it\u2019s only displayed when Python-related files are open on the editor (<code>\"python.interpreter.infoVisibility\": \u201conPythonRelated\u201d<\/code>). If you\u2019d like to hide it completely, set <code>\"python.interpreter.infoVisibility\": \u201cnever\u201d<\/code>.<\/p>\n<p>A warning status was also added to indicate situations when the selected interpreter is invalid:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-SelectInterpreterStatusBarWarning.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-9019\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-SelectInterpreterStatusBarWarning.png\" alt=\"A warning icon and a different background color is displayed on the status bar when the selected Python interpreter is invalid.\" width=\"1296\" height=\"156\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-SelectInterpreterStatusBarWarning.png 1296w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-SelectInterpreterStatusBarWarning-300x36.png 300w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-SelectInterpreterStatusBarWarning-1024x123.png 1024w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-SelectInterpreterStatusBarWarning-768x92.png 768w\" sizes=\"(max-width: 1296px) 100vw, 1296px\" \/><\/a><\/p>\n<h2>Python Tools extension template<\/h2>\n<p>With <a href=\"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-april-2022-release\/#pylint-extension\">all the work we have been doing<\/a> to enable formatting and linting with <a href=\"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-may-2022-release\/#black-extension\">Black<\/a>, <a href=\"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-april-2022-release\/#pylint-extension\">pylint<\/a>, and <a href=\"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-may-2022-release\/#isort-extension\">isort<\/a> to work behind the Language Server Protocol, we realized how simple we could make it to create an extension for mostly any Python linter or formatter without the need to require TypeScript knowledge (which is the language VS Code and its extensions are written in).<\/p>\n<p>To that end, our team has created a <a href=\"https:\/\/github.com\/microsoft\/vscode-python-tools-extension-template\">template<\/a> that allows you to create a VS Code extension for your favorite Python linter or formatter by changing mostly Python code (unless you\u2019re planning to add more settings or custom logic to it \u2013 then you\u2019ll need to work with a bit of TypeScript).<\/p>\n<p>To try it out, you can follow the <a href=\"https:\/\/github.com\/microsoft\/vscode-python-tools-extension-template#template-for-vs-code-python-tools-extensions\">instructions in the repository<\/a>. If at the end you\u2019d like to publish your new extension (and maintain it, after all with great power comes great responsibility), you can follow the steps on <a href=\"https:\/\/code.visualstudio.com\/api\/working-with-extensions\/publishing-extension\">the \u201cPublishing Extensions\u201d documentation<\/a>.<\/p>\n<p>And If you have any feedback on this new template, please <a href=\"https:\/\/github.com\/microsoft\/vscode-python-tools-extension-template\/issues\">file an issue on the GitHub repo<\/a>!<\/p>\n<h2>Remove all unused imports<\/h2>\n<p><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-python.vscode-pylance\">Pylance<\/a> now offers a code action for removing all unused imports when there is more than one library that is being imported but not used or called anywhere in the code. To try it out, open a Python file with such statements and trigger the code action called \u201cRemove all unused imports\u201d:\n<a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-RemoveAllImports.gif\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-9020\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-RemoveAllImports.gif\" alt=\"Code action for removing all unused imports displayed when more than one library is imported but not used in the code.\" width=\"1861\" height=\"1160\" \/><\/a><em>Theme: <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ftsamoyed.theme-pink-cat-boo\">Pink-Cat-Book<\/a><\/em><\/p>\n<p>You can also <a href=\"https:\/\/code.visualstudio.com\/updates\/v1_23#_run-code-actions-on-save\">configure VS Code<\/a> to run <a href=\"https:\/\/github.com\/microsoft\/pylance-release\/blob\/main\/README.md#source-code-actions\">all available \u201cfix all\u201d code actions<\/a> when you save your Python files by adding the following configuration to your User settings:<\/p>\n<pre class=\"prettyprint\">\"[python]\": {\r\n    \"editor.codeActionsOnSave\": {\r\n        \"source.fixAll\": true\r\n    }\r\n}\r\n<\/pre>\n<h2>Double click to accept Type Hints<\/h2>\n<p>In the <a href=\"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-july-2022-release\/\">July release<\/a>, we have added support for variable types and return types inlay hints when using <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-python.vscode-pylance\">Pylance<\/a>. In this release, we\u2019re introducing support to accepting the suggested annotations to your code. You can now double click on a hint to add the suggestion to your code:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-DoubleClickTypeHints.gif\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-9030\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-DoubleClickTypeHints.gif\" alt=\"Adding type suggestions given by Pylance on the editor by double clicking on them.\" width=\"1813\" height=\"1196\" \/><\/a><\/p>\n<p>To learn more about Inlay Type hints and for some tips on how you can best leverage this feature, check out Jay Miller\u2019s <a href=\"https:\/\/www.youtube.com\/watch?v=hHBp0r4w86g\">explanatory video<\/a> and blog post on how to <a href=\"https:\/\/dev.to\/kjaymiller\/make-inlay-type-hints-in-python-appeardisappear-njk\">\u201cMake Inlay Type Hints in Python Appear\/Disappear\u201d<\/a>.<\/p>\n<h2>Copy images to clipboard from Jupyter Notebooks<\/h2>\n<p>The new release of the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-toolsai.jupyter\">Jupyter extension<\/a> allows you to copy images from Jupyter notebooks output cells to the clipboard so you can more easily share them outside of VS Code!<\/p>\n<p>To try it out, make sure you change the output presentation to png, by clicking on the icon on the left side of the image you\u2019re trying to copy:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-NotebookImageRendered.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-9021\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-NotebookImageRendered.png\" alt=\"Selecting image\/png as the rendered for a Jupyter notebook output image.\" width=\"1369\" height=\"575\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-NotebookImageRendered.png 1369w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-NotebookImageRendered-300x126.png 300w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-NotebookImageRendered-1024x430.png 1024w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-NotebookImageRendered-768x323.png 768w\" sizes=\"(max-width: 1369px) 100vw, 1369px\" \/><\/a><\/p>\n<p>Then hover over the image and select the copy button that shows up to the right:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-CopyIconOnOutput.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-9022\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-CopyIconOnOutput.png\" alt=\"Copy icon displayed on the right of the Jupyter notebook image output \" width=\"1444\" height=\"467\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-CopyIconOnOutput.png 1444w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-CopyIconOnOutput-300x97.png 300w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-CopyIconOnOutput-1024x331.png 1024w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-CopyIconOnOutput-768x248.png 768w\" sizes=\"(max-width: 1444px) 100vw, 1444px\" \/><\/a><\/p>\n<p>And now you can paste it into your e-mails, documents, reports and even <a href=\"https:\/\/www.microsoft.com\/en-ca\/search\/explore?q=paint\">Paint<\/a>!<\/p>\n<h2>Go to most recently failed cell<\/h2>\n<p>Another improvement introduced in the latest Jupyter extension release is the ability to navigate to the most recently failed cell. When you run all your cells and one fails, you can click on the \u201cGo To\u201d button on the top of the editor and you will be taken to the one that halted the group execution.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-go-to-most-recently-failed-cell.gif\"><img decoding=\"async\" class=\"aligncenter wp-image-9024 size-full\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2022\/08\/Aug2022-go-to-most-recently-failed-cell.gif\" alt=\"Go to failed cell button displayed on the Jupyter Notebook toolbar. \" width=\"1985\" height=\"766\" \/><\/a><\/p>\n<h2>Other Changes and Enhancements<\/h2>\n<p>We have also added small enhancements and fixed issues requested by users that should improve your experience working with Python and Jupyter Notebooks in Visual Studio Code. Some notable changes include:<\/p>\n<ul>\n<li>There\u2019s a new setting in the Pylint and Black extensions that allow you to specify a interpreter command to launch the LSP server (<a href=\"https:\/\/github.com\/microsoft\/vscode-python\/issues\/19303\">vscode-python#19303<\/a>).<\/li>\n<li>We now have a new command (python.triggerEnvSelection) that other extensions can use to trigger an error notification to select a valid Python interpreter (<a href=\"https:\/\/github.com\/microsoft\/vscode-python\/issues\/19450\">vscode-python#19450<\/a>).<\/li>\n<li>We improved support for magic commands in the interactive window when using Pylance (<a href=\"https:\/\/github.com\/microsoft\/pylance-release\/issues\/2894\">pylance-release#2894<\/a>).<\/li>\n<li>Type analysis performance has been improved with Pylance(<a href=\"https:\/\/github.com\/microsoft\/pylance-release\/issues\/2881\" data-hovercard-type=\"issue\" data-hovercard-url=\"\/microsoft\/pylance-release\/issues\/2881\/hovercard\">pylance-release#2881<\/a>).<\/li>\n<li>The Jupyter extension now has diagnostic messages with code actions for files that could interfere with execution of Python Kernels (<a href=\"https:\/\/github.com\/microsoft\/vscode-jupyter\/issues\/10924\">vscode-jupyter#10924<\/a>).<\/li>\n<li>Interactive Window sessions can now be restored across VS Code window reloads by turning on the setting\u00a0restore (<a href=\"https:\/\/github.com\/microsoft\/vscode-jupyter\/issues\/6420\">vscode-jupyter#6420<\/a>).<\/li>\n<\/ul>\n<p>We would also like to extend special thanks to this month\u2019s contributors:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/dazfuller\">dazfuller<\/a>: Add support for unittest top-level directory option (<a href=\"https:\/\/github.com\/microsoft\/vscode-python\/pull\/19398\">vscode-python#19398<\/a>).<\/li>\n<li><a href=\"https:\/\/github.com\/Lakshmikanth2001\">Lakshmikanth2001<\/a>:\u00a0 Fix URLs in changelog (<a href=\"https:\/\/github.com\/microsoft\/vscode-python\/pull\/19414\">vscode-python#19414<\/a>).<\/li>\n<li><a href=\"https:\/\/github.com\/scottshambaugh\">scottshambaugh<\/a>: Improve error message when using invalid debug configuration for tests (<a href=\"https:\/\/github.com\/microsoft\/vscode-python\/pull\/19436\">vscode-python#19436<\/a>).<\/li>\n<li><a href=\"https:\/\/github.com\/BlueskyFR\">BlueskyFR<\/a>: Remove Gym stubs (<a href=\"https:\/\/github.com\/microsoft\/python-type-stubs\/issues\/215\">vscode-python#218<\/a>).<\/li>\n<\/ul>\n<p>Try out these new improvements by\u00a0<a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-python.python\">downloading the Python extension<\/a>\u00a0and the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-toolsai.jupyter\">Jupyter extension<\/a> from the Marketplace, or install them directly from the extensions view in Visual Studio Code (Ctrl\u00a0+\u00a0Shift\u00a0+\u00a0X\u00a0or\u00a0\u2318\u00a0+\u00a0\u21e7\u00a0+\u00a0X). You can learn more about\u00a0<a href=\"https:\/\/code.visualstudio.com\/docs\/python\/python-tutorial\">Python support in Visual Studio Code<\/a>\u00a0in the documentation. If you run into any problems or have suggestions,\u00a0<a href=\"https:\/\/github.com\/microsoft\/vscode-python\/issues\/new\/choose\">please file an issue<\/a>\u00a0on the\u00a0<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\">Python VS Code GitHub<\/a>\u00a0page.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We\u2019re excited to announce that the August 2022 release of the Python and Jupyter extensions for Visual Studio Code are now available! This release includes the following improvements: Automatic debug configurations for web apps Improvements to the Getting Started Experience Setting to configure the display of the interpreter information on the status bar A new [&hellip;]<\/p>\n","protected":false},"author":67892,"featured_media":9017,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,6],"tags":[],"class_list":["post-9015","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","category-visual-studio-code"],"acf":[],"blog_post_summary":"<p>We\u2019re excited to announce that the August 2022 release of the Python and Jupyter extensions for Visual Studio Code are now available! This release includes the following improvements: Automatic debug configurations for web apps Improvements to the Getting Started Experience Setting to configure the display of the interpreter information on the status bar A new [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/9015","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/users\/67892"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/comments?post=9015"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/9015\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/media\/9017"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/media?parent=9015"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/categories?post=9015"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/tags?post=9015"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}