{"id":9699,"date":"2024-05-03T06:44:55","date_gmt":"2024-05-03T14:44:55","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/python\/?p=9699"},"modified":"2024-05-03T06:44:55","modified_gmt":"2024-05-03T14:44:55","slug":"python-in-visual-studio-code-may-2024-release","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-may-2024-release\/","title":{"rendered":"Python in Visual Studio Code &#8211; May 2024 Release"},"content":{"rendered":"<p>We\u2019re excited to announce the May 2024 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!<\/p>\n<p>This release includes the following announcements:<\/p>\n<ul>\n<li>&#8220;Implement all inherited abstract classes&#8221; code action<\/li>\n<li>New auto indentation setting<\/li>\n<li>Debugpy removed from the Python extension in favor of the Python Debugger extension<\/li>\n<li>Socket disablement now possible during testing<\/li>\n<li>Pylance performance updates<\/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:\/\/code.visualstudio.com\/updates\/\">Jupyter<\/a> and <a href=\"https:\/\/github.com\/microsoft\/pylance-release\/blob\/main\/CHANGELOG.md\">Pylance<\/a> extensions.<\/p>\n<h2>&#8220;Implement all inherited abstract classes&#8221; Code Action<\/h2>\n<p>Abstract classes serve as &#8220;blueprints&#8221; for other classes and help build modular, reusable code by promoting clear structure and requirements for subclasses to adhere to. To define an abstract class in Python, you can create a class that inherits from the <a href=\"https:\/\/docs.python.org\/3\/library\/abc.html\"><code>ABC<\/code> class in the <code>abc<\/code> module<\/a>, and annotate its methods with the <code>@abstractmethod<\/code> decorator. Then, you can create new classes that inherit from this abstract class, and define an implementation for the base methods. Implementing these classes is easier with the latest Pylance pre-release! When defining a new class that inherits from an abstract one, you can now use the &#8220;Implement all inherited abstract classes&#8221; Code Action to automatically implement all abstract methods and properties from the parent class:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2024\/05\/pylance-implement-abstract-classv2.gif\"><img decoding=\"async\" class=\"alignnone size-full wp-image-9701\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2024\/05\/pylance-implement-abstract-classv2.gif\" alt=\"Implement all inherited abstract classes code action from Pylance.\" width=\"1920\" height=\"1124\" \/><\/a><\/p>\n<h2>New auto indentation setting<\/h2>\n<p>Previously, Pylance&#8217;s auto indentation behavior was controlled through the <code>editor.formatOnType<\/code> setting, which used to be problematic if one would want to disable auto indentation, but enable format on type through other supported tools. To solve this problem, Pylance&#8217;s latest pre-release now has its own setting to control auto indentation behavior, <code>python.analysis.autoIndent<\/code>, which is enabled by default.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2024\/05\/pylance-auto-indent-setting.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-9700\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2024\/05\/pylance-auto-indent-setting.png\" alt=\"Python Analysis Auto Indent setting to control auto indentation with Pylance\" width=\"1885\" height=\"268\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2024\/05\/pylance-auto-indent-setting.png 1885w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2024\/05\/pylance-auto-indent-setting-300x43.png 300w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2024\/05\/pylance-auto-indent-setting-1024x146.png 1024w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2024\/05\/pylance-auto-indent-setting-768x109.png 768w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2024\/05\/pylance-auto-indent-setting-1536x218.png 1536w\" sizes=\"(max-width: 1885px) 100vw, 1885px\" \/><\/a><\/p>\n<h2>Debugpy removed from the Python extension in favor of the Python Debugger extension<\/h2>\n<p>In our <a href=\"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-february-2024-release\/#python-debugger-extension-installed-by-default\">February 2024 release blog<\/a>, we announced moving all debugging functionality to the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-python.debugpy\">Python Debugger<\/a> extension, which is installed by default alongside the Python extension. In this release, we have removed duplicate debugging code from the Python extension, which helps to decrease the extension download size. As part of this change, <code>\"type\": \"python\"<\/code> and <code>\"type\": \"debugpy\"<\/code> specified in your <code>launch.json<\/code> configuration file are both interpreted as references to the Python Debugger extension path. This ensures a seamless transition without requiring any modifications to existing configuration files to run and debug effectively. Moving forward, we recommend using <code>\"type\": \"debugpy\"<\/code> as this directly corresponds to the Python Debugger extension which provides support for both legacy and modern Python versions.<\/p>\n<h2>Socket disablement now possible during testing<\/h2>\n<p>You can now run tests with socket disablement from the testing UI. This is made possible by a switch in the communication between the Python extension and the test run subprocess to now use named-pipes as opposed to numbered ports. This feature is available on the <a href=\"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-june-2023-release\/#test-discovery-and-execution-rewrite\">Python Testing Rewrite<\/a>, which is rolled out to all users by default and will soon be fully adopted in the Python extension.<\/p>\n<h2>Pylance Performance<\/h2>\n<p>The Pylance team has been receiving feedback that Pylance&#8217;s performance has degraded over the past few releases. As a result, we have made several smaller improvements to memory consumption and indexing including:<\/p>\n<ul>\n<li>Improved performance for third-party packages indexing<\/li>\n<li>Skipped Python files from workspace <code>.conda<\/code> environments from being scanned (<a href=\"https:\/\/github.com\/microsoft\/pylance-release\/issues\/5191\">@pylance-release#5191<\/a>)<\/li>\n<li>Skipped index on unnecessary <code>py.typed<\/code> file checks (<a href=\"https:\/\/github.com\/microsoft\/pyright\/pull\/7652\">@pyright#7652<\/a>)<\/li>\n<li>Reduced memory consumption by refactoring tokenizer and parser output (<a href=\"https:\/\/github.com\/microsoft\/pyright\/pull\/7602\">@pyright#7602<\/a>)<\/li>\n<li>Improved memory consumption for token creation (<a href=\"https:\/\/github.com\/microsoft\/pyright\/pull\/7434\">@pyright#7434<\/a>)<\/li>\n<\/ul>\n<p>For those who may still be experiencing performance issues with Pylance, we are kindly requesting for issues to be filed through the <strong>Pylance: Report Issue<\/strong> command from the Command Palette, ideally with logs, code samples and\/or the packages that are installed in the working environment.<\/p>\n<p>Additionally, we have added a couple of features in the latest Pylance pre-release version to help identify potential performance issues and gather additional information about issues you are facing. There is a new notification that prompts you to file an issue in the Pylance repo when the extension detects there may be a performance issue. Moreover, Pylance now provides a profiling command <code>Pylance: Start Profiling<\/code> that generates <code>cpuprofile<\/code> for all worker threads. This file is generated after starting and stopping profiling by triggering the <code>Pylance: Start Profiling<\/code> and <code>Pylance: Stop Profiling<\/code> commands and can be provided as additional data in an issue.<\/p>\n<p>With these smaller improvements and additional ways to report performance issues, we hope to continue to make improvements to performance. We greatly appreciate the feedback and collaboration as we work to address issues!<\/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>Test Explorer displays projects using <code>testscenarios<\/code> with unittest and parameterized tests inside nested classes correctly (<a href=\"https:\/\/github.com\/microsoft\/vscode-python\/issues\/22870\">@vscode-python#22870<\/a>).<\/li>\n<li>Test Explorer now handles tests in workspaces with symlinks, specifically workspace roots which are children of symlink-ed paths, which is particularly helpful in WSL scenarios (<a href=\"https:\/\/github.com\/microsoft\/vscode-python\/issues\/22658\">@vscode-python#22658<\/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\/DetachHead\">@DetachHead<\/a> Support experiment configuration in workspace settings in <a href=\"https:\/\/github.com\/microsoft\/vscode-python\/pull\/23267\">@vscode-python#23267<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/DavidArchibald\">@DavidArchibald<\/a> Fix debugger attach to process when running on WSL in <a href=\"https:\/\/github.com\/microsoft\/vscode-python-debugger\/pull\/267\">@vscode-python-debugger#267<\/a><\/li>\n<\/ul>\n<h2>Call for Community Feedback<\/h2>\n<p>As we are planning and prioritizing future work, we value your feedback! Below are a few issues we would love feedback on:<\/p>\n<ul>\n<li>Design proposal for test coverage in <a href=\"https:\/\/github.com\/microsoft\/vscode-python\/issues\/22827\">(@vscode-python#22827)<\/a><\/li>\n<\/ul>\n<p>Try out these new improvements by downloading the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-python.python\">Python extension<\/a> and 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 + Shift + X or \u2318 + \u21e7 + X). You can learn more about <a href=\"https:\/\/code.visualstudio.com\/docs\/python\/python-tutorial\">Python support in Visual Studio Code<\/a> in the documentation. 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 <a href=\"https:\/\/github.com\/Microsoft\/vscode-python\">Python VS Code GitHub page<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The May 2024 release of the Python and Jupyter extensions for Visual Studio Code are now available. This month&#8217;s updates include a new Pylance code action and setting, removal of debugpy from the Python extension, socket disablement for testing scenarios, and Pylance performance updates. Keep reading to learn more!<\/p>\n","protected":false},"author":99209,"featured_media":10119,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,6],"tags":[17,1261],"class_list":["post-9699","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","category-visual-studio-code","tag-python","tag-release"],"acf":[],"blog_post_summary":"<p>The May 2024 release of the Python and Jupyter extensions for Visual Studio Code are now available. This month&#8217;s updates include a new Pylance code action and setting, removal of debugpy from the Python extension, socket disablement for testing scenarios, and Pylance performance updates. Keep reading to learn more!<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/9699","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\/99209"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/comments?post=9699"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/9699\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/media\/10119"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/media?parent=9699"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/categories?post=9699"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/tags?post=9699"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}