{"id":8674,"date":"2021-09-02T10:52:43","date_gmt":"2021-09-02T18:52:43","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/python\/?p=8674"},"modified":"2021-09-14T10:48:05","modified_gmt":"2021-09-14T18:48:05","slug":"python-in-visual-studio-code-september-2021-release","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-september-2021-release\/","title":{"rendered":"Python in Visual Studio Code \u2013 September 2021 Release"},"content":{"rendered":"<p>We are pleased to announce that the September 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>In this release we closed <a href=\"https:\/\/github.com\/microsoft\/vscode-python\/issues?q=is%3Aissue+milestone%3A%22August+2021%22+is%3Aclosed\">80 issues<\/a>, and it includes:<\/p>\n<ul>\n<li>A rich Python editing experience in the browser<\/li>\n<li>Revamped testing interface<\/li>\n<li>New button for running and debugging files on the editor<\/li>\n<li>An update regarding the Microsoft Python Language Server\u2019s end of life, as well as for Python 2.7 IntelliSense support.<\/li>\n<\/ul>\n<p>If you\u2019re 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 rich Python editing experience (in the browser!) via github.dev<\/h2>\n<p>We are delighted to announce that as of this release you can enjoy the performant editing experience of Pylance in the browser via <a href=\"https:\/\/github.dev\/\">github.dev<\/a>. If you are unfamiliar with github.dev, you can head over to any repo, pull request, or file on GitHub and hit \u2018.\u2019 on your keyboard (or change the URL to github.dev) to give it a shot!<\/p>\n<p>We\u2019ve added support for the core editing features you might want when exploring a new codebase or making minor edits to your Python code. These features include:<\/p>\n<ul>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/python\/pylance-has-reached-stable\/#semantic-colorization\">Semantic highlighting<\/a><\/li>\n<li>Completions for built-ins, Pylance\u2019s bundled stubs, locally defined symbols in the current file, and symbols in open files<\/li>\n<li>Syntax errors<\/li>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/python\/pylance-has-reached-stable\/#code-navigation\">Code navigation<\/a><\/li>\n<li>Outline support<\/li>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/python\/pylance-has-reached-stable\/#function-signature-help-with-parameter-and-return-type-information\">Function signature help<\/a><\/li>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/python\/pylance-has-reached-stable\/#contextual-document-highlighting\">Contextual document highlighting<\/a><\/li>\n<\/ul>\n<p>You can check out Dan Taylor giving <a href=\"https:\/\/www.youtube.com\/watch?v=ujxj1YX7PWM\">a demo on the Python Bytes podcast<\/a> of this new experience if you\u2019d like!<\/p>\n<p>We\u2019re excited for you to give this new experience a try and welcome any feedback on the <a href=\"https:\/\/github.com\/microsoft\/pylance-release\">Pylance issue tracker.<\/a><\/p>\n<p>Although running Python code in the browser isn\u2019t yet supported, you can do so in a Jupyter notebook with the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=joyceerhl.vscode-pyolite\">vscode-pyolite extension<\/a> (in preview), made by one of our team members!<\/p>\n<h2>Revamped Testing Interface<\/h2>\n<p>We\u2019re excited to announce that we have revamped the look of our Python testing features by utilizing the built-in test explorer in VS Code. You can now enjoy a more stable UI experience for test discovery, navigation and status rendering, as well as new features such as test search, run a selection of tests, rerun last executed test, and more. With this change alone, <a href=\"https:\/\/github.com\/microsoft\/vscode-python\/issues?page=1&amp;q=is%3Aissue+label%3Aarea-testing+milestone%3A%22August+2021%22+is%3Aclosed\">we have closed 55 issues<\/a> on our GitHub repo!<\/p>\n<h2><span style=\"font-family: 'Segoe UI',sans-serif;\">Test configuration <\/span><\/h2>\n<p>Once the Python extension activates, you will see the Test Explorer on the activity bar. If you haven\u2019t configured the testing features, you will see an option to do so on the welcome view:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/09\/September2021-ConfigureTests.png\"><img decoding=\"async\" class=\"aligncenter wp-image-8675 size-medium\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/09\/September2021-ConfigureTests-230x300.png\" alt=\"Configure Python tests button on the test explorer view\" width=\"230\" height=\"300\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/09\/September2021-ConfigureTests-230x300.png 230w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/09\/September2021-ConfigureTests.png 607w\" sizes=\"(max-width: 230px) 100vw, 230px\" \/><\/a><\/p>\n<h2><span style=\"font-family: 'Segoe UI',sans-serif;\">Test discovery <\/span><\/h2>\n<p>Once the testing features are configured, the Python extension attempt to discover tests. Once they\u2019re discovered, you will see your tests listed on the test explorer:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/09\/September2021-TestsDiscovered.png\"><img decoding=\"async\" class=\"aligncenter wp-image-8680 size-medium\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/09\/September2021-TestsDiscovered-240x300.png\" alt=\"Tests displayed on the test explorer once they are discovered\" width=\"240\" height=\"300\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/09\/September2021-TestsDiscovered-240x300.png 240w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/09\/September2021-TestsDiscovered.png 622w\" sizes=\"(max-width: 240px) 100vw, 240px\" \/><\/a><\/p>\n<p>Tests are now discovered automatically by default whenever you add, delete, or update any python file in the workspace. You can disable that functionality by changing the &#8220;python.testing.autoTestDiscoverOnSaveEnabled&#8221; setting to \u201cfalse\u201d.<\/p>\n<h2><span style=\"font-family: 'Segoe UI',sans-serif;\">Test Navigation<\/span><\/h2>\n<p>You can navigate to test methods or files through the test explorer by clicking on \u201cGo to Test\u201d icon that shows when you hover over or click on a test item. But now you can also navigate to the test on the test explorer from the editor, by right-clicking on the gutter decoration and selecting \u201cReveal in Test Explorer\u201d.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/09\/September2021-TestNavigation.gif\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8679\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/09\/September2021-TestNavigation.gif\" alt=\"Navigating to tests from the test explorer and from the editor\" width=\"1561\" height=\"1110\" \/><\/a><\/p>\n<h2><span style=\"font-family: 'Segoe UI',sans-serif;\">Run and debug tests <\/span><\/h2>\n<p>Although we\u2019ve retired the code lenses, there are still more options for you to run and debug your tests:<\/p>\n<h3><strong>The test explorer<\/strong><\/h3>\n<p>By hovering over the test items on the test explorer and clicking on the corresponding icons, as well as through the icons on the top right of the test explorer to run and debug all of the discovered tests. And now you can also run a selection of tests by Ctrl + clicking (or Cmd + Clicking if you\u2019re on macOS) the ones you\u2019d like to run in the explorer, and then clicking on the run icon for one of the tests in the selection:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/09\/September2021-RunTestsThroughExplorer.gif\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8678\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/09\/September2021-RunTestsThroughExplorer.gif\" alt=\"Running tests through the test explorer\" width=\"1561\" height=\"1110\" \/><\/a><\/p>\n<h3><strong>The editor<\/strong><\/h3>\n<p>Although we\u2019ve retired the code lenses, you can still run and debug tests in the editor by clicking on the gutter decorations. You can also right-click on them to debug the tests instead (and you can even change the default behaviour what clicking on the decorators will do to through the &#8220;testing.defaultGutterClickAction&#8221; setting).<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/09\/September2021-RunTestsThroughEditor.gif\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8677\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/09\/September2021-RunTestsThroughEditor.gif\" alt=\"Running tests through the gutter decorations on theeditor\" width=\"1561\" height=\"1110\" \/><\/a><\/p>\n<p>To configure the debugger for tests, you can specify\u00a0&#8220;purpose&#8221;: [&#8220;debug-test&#8221;]\u00a0in the\u00a0launch.json\u00a0file in the\u00a0.vscode\u00a0folder from your workspace.<\/p>\n<p>For example, the configuration below in the\u00a0launch.json\u00a0file disables the\u00a0justMyCode\u00a0setting for debugging tests:<\/p>\n<pre class=\"prettyprint\">{\r\n\u00a0\u00a0\u00a0 \"name\": \"Python: Current File\",\r\n\u00a0\u00a0\u00a0 \"type\": \"python\",\r\n\u00a0\u00a0\u00a0 \"request\": \"launch\",\r\n\u00a0\u00a0\u00a0 \"program\": \"${file}\",\r\n\u00a0\u00a0 \u00a0\"console\": \"integratedTerminal\",\r\n\u00a0\u00a0\u00a0 \"justMyCode\": false,\r\n \u00a0\u00a0 \"purpose\": [\"debug-test\"]\r\n}<\/pre>\n<h3><strong>Commands<\/strong><\/h3>\n<p>We now have new commands that can be particularly helpful when you\u2019re creating or modifying tests. We often want to run the same test method a couple of times when we\u2019re creating it. To make that simpler and more accessible, you can use the \u201cTest: Run Test at Cursor\u201d command to run the method where you have the cursor at in the editor (and you can even <a href=\"https:\/\/code.visualstudio.com\/docs\/getstarted\/keybindings#_keyboard-shortcuts-editor\">add a keyboard shortcut<\/a> for it so you can more easily do so!). Similarly, you can run the \u201cTest: Rerun last run\u201d command if you want to run the only last test you have executed.<\/p>\n<p>Because we\u2019re leveraging VS Code\u2019s new <a href=\"https:\/\/code.visualstudio.com\/api\/extension-guides\/testing\">testing API<\/a>, a few of our testing commands have changed. If you are used to our old test commands or have key-bindings set up for them, <a href=\"https:\/\/code.visualstudio.com\/docs\/python\/testing#_test-commands\">you can reference our documentation<\/a> to see what the corresponding new commands are.<\/p>\n<h2>New button for running and debugging files on the editor<\/h2>\n<p>We improved our \u201crun button\u201d on the editor to also include debugging files as an option. When you click on the icon it will run your active Python file in the terminal by default, but you can click on the down-arrow to change the action to debug it instead:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/09\/September2021-RunAndDebugIcon.gif\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8676\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/09\/September2021-RunAndDebugIcon.gif\" alt=\"Running and debugging using the new icons on the top right of the editor\" width=\"1708\" height=\"1074\" \/><\/a><\/p>\n<p>You can also customize the action for what the debug icon does by creating a launch.json file and adding \u201cpurpose\u201d : [\u201cdebug-in-terminal\u201d] to your Python configuration.<\/p>\n<p>For example, the configuration below enables stepping into non-user code when debugging through the debug icon on the editor:<\/p>\n<pre class=\"prettyprint\">{\r\n \u00a0\u00a0 \"name\": \"Python: Current File - Editor Button\",\r\n \u00a0\u00a0 \"type\": \"python\",\r\n \u00a0\u00a0 \"request\": \"launch\",\r\n \u00a0\u00a0 \"program\": \"${file}\",\r\n \u00a0\u00a0 \"console\": \"integratedTerminal\",\r\n \u00a0\u00a0 \"justMyCode\": false,\r\n \u00a0\u00a0 \"purpose\": [\"debug-in-terminal\"]\r\n}<\/pre>\n<p>One thing to note is that this will only work for debugging files through the debug icon on the editor \u2013 it will not work when starting the debugger through the Run and Debug view or through F5.<\/p>\n<h2>Limited IntelliSense support for Python 2.7 starting in October 2021<\/h2>\n<p>Our IntelliSense support for Python 2.7 users comes from <a href=\"https:\/\/github.com\/davidhalter\/jedi\/releases\/tag\/v0.17.2\">Jedi 0.17<\/a>, which came out over a year ago and is the last release of Jedi that supported Python 2.7. \u00a0Since that time, we have begun using (and contributing to)\u00a0<a href=\"https:\/\/github.com\/pappasam\/jedi-language-server\">jedi-language-server<\/a>,\u00a0which puts Jedi behind\u00a0<a href=\"https:\/\/microsoft.github.io\/language-server-protocol\/\">LSP<\/a>. This has given Jedi users better performance, refactoring and code navigation capabilities, but is only available for Jedi 0.18.<\/p>\n<p>Starting with the 2021.10 of the Python extension, we will only offer support for Jedi 0.18 and higher, and no longer ship support for Jedi 0.17. We will also be removing support for ctags and rope at the same time.<\/p>\n<p>You can check <a href=\"https:\/\/github.com\/microsoft\/vscode-python\/wiki\/Limited-support-for-Python-2.7\">our wiki page<\/a> to learn more about the reason behind it and what you can do if you\u2019re still using Python 2.7 in VS Code.<\/p>\n<h2>Microsoft Python Language Server end of life November 2021<\/h2>\n<p>In the June 2020 release, <a href=\"https:\/\/devblogs.microsoft.com\/python\/announcing-pylance-fast-feature-rich-language-support-for-python-in-visual-studio-code\/\">we announced our team\u2019s investment in Pylance<\/a>, a new more performant and feature-rich Python language server, and the eventual deprecation of our legacy language server, the Microsoft Python Language Server Since this announcement, our team has <a href=\"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-may-2021-release\/\">worked hard to improve language server support<\/a> in both Pylance and the open-source language server, <a href=\"https:\/\/github.com\/pappasam\/jedi-language-server\">Jedi<\/a>.<\/p>\n<p>With Pylance now as the default language support for Python for Visual Studio Code, almost all of our users have switched to our new language server. <strong>As such, the Microsoft Python Language Server will reach end of life with the November <\/strong><strong>release of the Python in Visual Studio Code extension. <\/strong>After deprecation, the <a href=\"https:\/\/github.com\/microsoft\/python-language-server\">Microsoft Python Language Server repository<\/a> will be marked as archived. This will still allow you to fork and build upon the language server\u2019s codebase if you\u2019d like.<\/p>\n<p>If you are still using this language server (your python.languageServer setting is set to \u201cMicrosoft\u201d), you will now see a prompt asking you to choose a new language server \u2013 Pylance (recommended; default) or Jedi (open-source). Upon selection, your python.languageServer setting will be appropriately updated in your settings.json to reflect your choice. If at any point you want to try something new, you can do that by <a href=\"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-may-2021-release\/#configuring-your-language-server\">updating your settings.<\/a> If by the November release you have not yet selected a new language server, your language server will automatically flip to the default language support for Python in Visual Studio Code \u2013 Pylance.<\/p>\n<p>We\u2019d like to thank all our Microsoft Python Language Server users for their feedback and support over the last couple of years. Your input helped shape what we believe is the best language support for Python in Visual Studio Code ever.<\/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>Improved display of interpreters list (<a href=\"https:\/\/github.com\/microsoft\/vscode-python\/issues\/16971\">#16971<\/a>)<\/li>\n<li>Removed support for nose (<a href=\"https:\/\/github.com\/microsoft\/vscode-python\/issues\/16371\">#16371<\/a>)<\/li>\n<li>Magic cells on Python notebooks no longer cause an error in Pylance (<a href=\"https:\/\/github.com\/microsoft\/vscode-python\/issues\/17058\">#17058<\/a>)<\/li>\n<\/ul>\n<p>And huge thanks to this month\u2019s contributors:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/FiftysixTimes7\">FiftysixTimes7<\/a>: Updated Simplified Chinese translation (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/16916\">#16916<\/a>)<\/li>\n<li><a href=\"https:\/\/github.com\/bigjools\">JulianEdwards<\/a>: Fix for unittest discovery (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/16593\">#16593<\/a>)<\/li>\n<li><a href=\"https:\/\/github.com\/cdce8p\">Marc Mueller<\/a>: Fix environment sorting for the\u00a0Python: Select Interpreter (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/16893\">#16893<\/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<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;re excited to announce that the September 2021 release of the Python extension is here! We now have a rich Python editing experience in the browser with Pylance, a revamped testing interface, a new button for running and debugging files on the editor and more! <\/p>\n","protected":false},"author":33429,"featured_media":8678,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,6],"tags":[],"class_list":["post-8674","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 that the September 2021 release of the Python extension is here! We now have a rich Python editing experience in the browser with Pylance, a revamped testing interface, a new button for running and debugging files on the editor and more! <\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/8674","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\/33429"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/comments?post=8674"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/8674\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/media\/8678"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/media?parent=8674"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/categories?post=8674"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/tags?post=8674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}