{"id":8561,"date":"2021-07-20T14:00:55","date_gmt":"2021-07-20T22:00:55","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/python\/?p=8561"},"modified":"2021-07-20T14:00:55","modified_gmt":"2021-07-20T22:00:55","slug":"python-in-visual-studio-code-july-2021-release","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-july-2021-release\/","title":{"rendered":"Python in Visual Studio Code \u2013 July 2021 Release"},"content":{"rendered":"<p>We are pleased to announce that the July 2021 release of the Python Extension for Visual Studio Code is now available. You can\u00a0<a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-python.python\">download the Python extension<\/a> from the Marketplace, or install it directly from the extension gallery 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 \u00a0<a href=\"https:\/\/code.visualstudio.com\/docs\/python\/python-tutorial\">Python support in Visual Studio Code<\/a>\u00a0in the documentation.<\/p>\n<p>These are some of the notable changes introduced in this release:<\/p>\n<ul>\n<li>A faster way to configure project roots via a new Pylance quick fix<\/li>\n<li>Selecting a Python interpreter no longer changes settings<\/li>\n<li>New debugger features: step into targets and function breakpoints<\/li>\n<\/ul>\n<p>If you are interested, you can check the full list of improvements in our <a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/blob\/master\/CHANGELOG.md\">changelog<\/a>.<\/p>\n<h2>A faster way to configure project roots<\/h2>\n<p>We\u2019re excited to announce that we\u2019ve added a new quick fix to to allow you to more quickly configure your Python project roots!<\/p>\n<p>A common issue we\u2019ve heard developers experience in VS Code is seeing diagnostics (or yellow squiggles) under import statements when they open new projects and then not knowing what to do to resolve them.<\/p>\n<p>Previously, configuring project roots would require setting python.analysis.extraPaths to tell Pylance what search paths to use for import resolution (that is, for finding the paths of packages that are imported to get the information necessary to provide IntelliSense features). Now, you\u2019re able to skip the step of manually fiddling with your settings.json and trying to figure out the right search paths to add to extraPaths and instead have Pylance guide you via the editor.<\/p>\n<p>You can now hover over the diagnostic on the import statement and either click the lightbulb icon or \u201cQuick Fix&#8230;\u201d in the tooltip and Pylance will suggest search paths to add to python.analysis.extraPaths, where appropriate.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-ExtraPathsCodeAction.gif\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8562\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-ExtraPathsCodeAction.gif\" alt=\"Quick fix to add project root to search paths to resolve unresolved import warnings with Pylance \" width=\"800\" height=\"400\" \/><\/a><\/p>\n<h2>Selecting a Python interpreter no longer modifies workspace settings<\/h2>\n<p>Previously, selecting or changing a Python interpreter with the Python extension would update a setting called \u201cpython.pythonPath\u201d with the path to the interpreter as its value. But because the interpreter path is often very specific to a machine, that behavior was problematic for those who wanted to share their VS Code workspace settings in a GitHub repo, for example, as reported in our <a href=\"https:\/\/github.com\/microsoft\/vscode-python\/issues\/2125\">issue tracker<\/a>.<\/p>\n<p>To make the interpreter information system-agnostic, changes to the selected interpreter will no longer cause modifications to your settings.json. The Python extension will keep storing the interpreter information per workspace, but in internal storage. If you want to see the path to the selected interpreter, you can run the \u201cPython: Select Interpreter\u201c command and check the value of the \u201ccurrent\u201d field. You can also open the Python output panel to retrieve the path.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-CurrentFieldInterpreterSelection.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8563\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-CurrentFieldInterpreterSelection.png\" alt=\"Currently selected interpreter field in the interpreters list \" width=\"1157\" height=\"378\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-CurrentFieldInterpreterSelection.png 1157w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-CurrentFieldInterpreterSelection-300x98.png 300w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-CurrentFieldInterpreterSelection-1024x335.png 1024w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-CurrentFieldInterpreterSelection-768x251.png 768w\" sizes=\"(max-width: 1157px) 100vw, 1157px\" \/><\/a><\/p>\n<p>If you still want to define an interpreter path to be used by the Python extension by default in your settings.json, you can set the \u201cpython.defaultInterpreterPath\u201d instead. When set on the workspace scope, the value of this setting will define which interpreter the Python extension will select when it loads the workspace for the first time (and for the first time only). This setting will <strong>not<\/strong> be modified automatically, which means that the Python extension will not change its value when a different interpreter is specified in the setting.<\/p>\n<p>You can also set \u201cpython.defaultInterpreterPath\u201d on the User scope to define the path to an interpreter that you wish to be selected on the first time you open any workspaces.<\/p>\n<p>If you have the \u201cpython.pythonPath\u201d setting defined on your workspace, its value will be used to update the selected interpreter in the internal storage. However, that will happen only on the first time this newest version of the Python extension loads \u2013 further changes to this setting will not be picked up.<\/p>\n<h2>Two new debugger features: step into targets and function breakpoints<\/h2>\n<p>We\u2019re excited to be introducing a new feature to improve your productivity when debugging your Python code!<\/p>\n<p>The first one is the ability to choose which targets to step into when there is more than one possible option. Take the example code below:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-StepIntoTargetsPart1.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8564\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-StepIntoTargetsPart1.png\" alt=\"Example of code with four function calls in one line.\" width=\"1530\" height=\"336\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-StepIntoTargetsPart1.png 1530w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-StepIntoTargetsPart1-300x66.png 300w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-StepIntoTargetsPart1-1024x225.png 1024w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-StepIntoTargetsPart1-768x169.png 768w\" sizes=\"(max-width: 1530px) 100vw, 1530px\" \/><\/a><\/p>\n<p>Before, if all you wanted was to step into the <em>generate_wordcloud <\/em>call, you would need to step into (and then immediately step out) of the <em>parse_content<\/em>, <em>Image.open <\/em>and <em>np.array <\/em>calls.<\/p>\n<p>Now, when the debugger stops at a breakpoint on a line that has multiple function calls, you can specify which one you want to step into by right-clicking on the editor and selecting \u201cstep into targets\u201d:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-StepIntoTargetsPart2.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8565\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-StepIntoTargetsPart2.png\" alt=\"Step into targets option in the context menu\" width=\"893\" height=\"241\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-StepIntoTargetsPart2.png 893w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-StepIntoTargetsPart2-300x81.png 300w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-StepIntoTargetsPart2-768x207.png 768w\" sizes=\"(max-width: 893px) 100vw, 893px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>You can then select which target you would like to step into. In our case, that would be the <em>generate_wordcloud <\/em>method.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-StepIntoTargetsPart3.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8566\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-StepIntoTargetsPart3.png\" alt=\"Targets that could be stepped into with the debugger \" width=\"1642\" height=\"675\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-StepIntoTargetsPart3.png 1642w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-StepIntoTargetsPart3-300x123.png 300w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-StepIntoTargetsPart3-1024x421.png 1024w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-StepIntoTargetsPart3-768x316.png 768w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-StepIntoTargetsPart3-1536x631.png 1536w\" sizes=\"(max-width: 1642px) 100vw, 1642px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><figure id=\"attachment_8567\" aria-labelledby=\"figcaption_attachment_8567\" class=\"wp-caption aligncenter\" ><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-step-into-targets.gif\"><img decoding=\"async\" class=\"wp-image-8567 size-full\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-step-into-targets.gif\" alt=\"Step into targets with the debugger\" width=\"1918\" height=\"1162\" \/><\/a><figcaption id=\"figcaption_attachment_8567\" class=\"wp-caption-text\"><em>Theme: Lucy (https:\/\/marketplace.visualstudio.com\/items?itemName=juliettepretot.lucy-vscode)<\/em><\/figcaption><\/figure><\/p>\n<p>The other exciting new feature we\u2019re bringing in this release is function breakpoints. If you\u2019re interested in inspecting just a certain function\u2019s behavior, you can specify its name on the breakpoint window so that the debugger will stop its execution once it reaches the function:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-FunctionBreakpointsPart1.png\"><img decoding=\"async\" class=\"aligncenter wp-image-8569 size-medium\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-FunctionBreakpointsPart1-280x300.png\" alt=\"Adding a function breakpoint\" width=\"280\" height=\"300\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-FunctionBreakpointsPart1-280x300.png 280w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-FunctionBreakpointsPart1-768x823.png 768w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-FunctionBreakpointsPart1.png 823w\" sizes=\"(max-width: 280px) 100vw, 280px\" \/><\/a><\/p>\n<p>For example, if we wanted the debugger to stop once the execution reached the <em>parse_content<\/em> function, we would add its name in the breakpoints window. Function breakpoints are represented by a red triangle, like in the image below:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-FunctionBreakpointsPart2.png\"><img decoding=\"async\" class=\"aligncenter wp-image-8570 size-medium\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-FunctionBreakpointsPart2-272x300.png\" alt=\"Function breakpoint on the breakpoints view\" width=\"272\" height=\"300\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-FunctionBreakpointsPart2-272x300.png 272w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-FunctionBreakpointsPart2-768x846.png 768w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-FunctionBreakpointsPart2.png 881w\" sizes=\"(max-width: 272px) 100vw, 272px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-function-breakpoints.gif\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8568\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/07\/July2021-function-breakpoints.gif\" alt=\"Adding and hitting a function breakpoint\" width=\"1918\" height=\"1162\" \/><\/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 in Visual Studio Code. Some notable changes include:<\/p>\n<ul>\n<li>Make test explorer only show file\/folder names on nodes. (thanks <a href=\"https:\/\/github.com\/bobwalker99\">bobwalker99<\/a>) (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/16368\">#16368<\/a>)<\/li>\n<li>Bug fixes for Poetry support: the poetryPath setting will correctly apply system variable substitutions, and the Jupyter Notebook extension will install any missing dependencies using Poetry or Pipenv if those are the selected environments. (thanks <a href=\"https:\/\/github.com\/tonybaloney\">Anthony Shaw<\/a>) (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/16607\">#16607,<\/a> <a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/16615\">#16615<\/a>)<\/li>\n<li>Add support for renaming modules with Jedi (thanks <a href=\"https:\/\/github.com\/anu-ka\">Anupama Nadig<\/a>!) (<a href=\"https:\/\/github.com\/pappasam\/jedi-language-server\/issues\/134\">jedi-language-server\/#134<\/a>)<\/li>\n<\/ul>\n<p>Be sure to\u00a0<a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-python.python\">download the Python extension<\/a>\u00a0for Visual Studio Code now to try out the above improvements. If you run into any problems or have suggestions, <a href=\"https:\/\/github.com\/microsoft\/vscode-python\/issues\/new\/choose\">please file an issue<\/a> on the\u00a0<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\">Python VS Code GitHub<\/a>\u00a0page.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;re excited to announce the July 2021 release of the Python extension for VS Code! This release includes a  faster way to configure project roots via a new Pylance quick fix, two new debugger features and Python interpreter settings changes. Keep on reading to learn more!<\/p>\n","protected":false},"author":1064,"featured_media":8562,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,6],"tags":[],"class_list":["post-8561","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","category-visual-studio-code"],"acf":[],"blog_post_summary":"<p>We&#8217;re excited to announce the July 2021 release of the Python extension for VS Code! This release includes a  faster way to configure project roots via a new Pylance quick fix, two new debugger features and Python interpreter settings changes. Keep on reading to learn more!<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/8561","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\/1064"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/comments?post=8561"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/8561\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/media\/8562"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/media?parent=8561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/categories?post=8561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/tags?post=8561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}