{"id":9272,"date":"2023-02-03T07:01:04","date_gmt":"2023-02-03T15:01:04","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/python\/?p=9272"},"modified":"2024-02-01T15:28:00","modified_gmt":"2024-02-01T23:28:00","slug":"python-in-visual-studio-code-february-2023-release","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-february-2023-release\/","title":{"rendered":"Python in Visual Studio Code &#8211; February 2023 Release"},"content":{"rendered":"<p>We\u2019re excited to announce that the February 2023 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 announcements:<\/p>\n<ul>\n<li>Automatic environment selection when VS Code is launched from an activated terminal<\/li>\n<li>Select <a href=\"https:\/\/pip.pypa.io\/en\/stable\/reference\/requirements-file-format\/\">requirements files<\/a> or <a href=\"https:\/\/packaging.python.org\/en\/latest\/tutorials\/installing-packages\/#installing-extras\">optional dependencies<\/a> with the <code>Python: Create Environment<\/code> command<\/li>\n<li>Preview: Improved IntelliSense support for pytest with Pylance<\/li>\n<li>Jupyter kernel picker improvements<\/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 environment selection when VS Code is launched from an activated terminal<\/h2>\n<p>When a user launches VS Code via the terminal with a conda or virtual environment already activated, VS Code now detects that activated environment. Depending on the type of environment, VS Code either auto-selects the environment itself, or asks the user if they would like to select the environment that is present. This feature aims at improving your workflow by auto-selecting the environment rather than requiring manual selection. <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/60238438\/215604138-dcc177f4-cb1c-4f53-9b51-93db87c8123f.gif\" alt=\"Conda environment auto-selection\" \/><\/p>\n<h2>Select requirements files and optional dependencies with the <code>Python: Create Environment<\/code> command<\/h2>\n<p>We are continuing to improve our <code>Python: Create Environment<\/code> command based on your feedback! Previously, when a user created an environment with the <code>Python: Create Environment<\/code> command, the command searched for common requirements and dependency files and loaded them into the environment automatically. Now, the <code>Python: Create Environment<\/code> command finds <a href=\"https:\/\/pip.pypa.io\/en\/stable\/reference\/requirements-file-format\/\">requirements files<\/a> in the workspace folder, and allows users to multi-select any number of requirements to install in a quick pick.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/60238438\/215588859-87eeb24c-c671-40cd-897d-07544a73e1be.gif\" alt=\"Create Environment with requirements.txt files\" \/><\/p>\n<p>Alternatively, the Python extension detects and reads the <a href=\"https:\/\/packaging.python.org\/en\/latest\/tutorials\/installing-packages\/#installing-extras\">optional dependencies<\/a> provided in the <code>[project.optional-dependencies]<\/code> table of the <code>pyproject.toml<\/code> file. We then perform an installation of any selected optional dependencies along with using the <code>pip install --editable .<\/code> command (performing an editable install will become <a href=\"https:\/\/github.com\/microsoft\/vscode-python\/issues\/20620\">conditional on their being a <code>[build-system]<\/code> table in <code>pyproject.toml<\/code><\/a> in a future release). This is integrated as a quick pick in the <code>Python: Create Environment<\/code> command. <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/60238438\/215588972-a2778aa2-be3f-403e-86eb-5a787642a3be.gif\" alt=\"Create Environment with requirements.txt files\" \/><\/p>\n<h2>Preview: Improved IntelliSense support for pytest with Pylance<\/h2>\n<p>We&#8217;re excited to announce support for pytest fixtures and parameterization in the pre-release version of Pylance! This update includes powerful features that can help you work more efficiently and effectively when writing and maintaining clear, concise and easy to understand tests with pytest.<\/p>\n<p>You can more conveniently navigate and read through your tests thanks to added support for go to definition and find all references, which also enables quick updates with symbol rename (F2):<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/45497113\/215238812-b5ac8afd-6bb2-45e3-af25-9286cfc85017.gif\" alt=\"Using `Go to definition` to rename Pytest symbols\" \/><\/p>\n<p>Pylance also provides completions for pytest fixtures and for parameterized arguments, to help you write your tests more efficiently:\n<img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/45497113\/216171777-c71749bc-78cc-44fc-bf2b-fad132ba47dc.gif\" alt=\"Completions for pytest parameterized arguments\" \/><\/p>\n<p>Adding type hints to your pytest fixture parameters can help further improve readability of your tests and catch errors before they become a problem. Pylance now offers two features that make this process more practical: you can trigger code actions (Cmd + . on macOS, Ctrl + . on Windows\/Linux) to annotate the types of your pytest parameters, or even enable inlay hints through the <code>\"python.analysis.inlayHints.pytestParameters\"<\/code> setting (and then just double click a hint to insert it into your code).<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/45497113\/215239111-a671de9a-c7e9-4372-9469-8d6a476acf2f.gif\" alt=\"Pytest fixture inlay hints\" \/>\nPylance will also infer the types of parameterized pytest arguments, based on the parameter values provided to the decorator:\n<img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/45497113\/216172767-ca4e4132-127c-49de-89e8-a60039f2f4be.gif\" alt=\"Pylance displaying inferred type for pytest parameterized arguments\" \/><\/p>\n<p>You can try these updates by installing <a href=\"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-june-2022-release\/#pre-release-pylance-extension\">the pre-release version of the Pylance extension<\/a>, and report any issues you may encounter at https:\/\/github.com\/microsoft\/pylance-release.<\/p>\n<h2>Jupyter kernel picker improvements<\/h2>\n<p>We continued to improve the MRU (Most Recently Used) kernel picker. It can be enabled by setting <code>\"notebook.kernelPicker.type\"<\/code> to <code>\"mru\"<\/code>. Kernels that are not used will be moved into a secondary picker &#8220;Select Another Kernel&#8230;&#8221;. This picker will group all kernels by their source (for example: &#8220;Jupyter Kernel&#8221;, &#8220;Python Environment&#8221;, etc.) when you have latest Jupyter extension and Python extension installed.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/60238438\/215554437-4202a2d3-6883-4068-a26c-d22686588b07.png\" alt=\"Notebook Kernel Picker\" \/><\/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>Join Selected Cells (<code>kb(notebook.cell.joinSelected)<\/code>) to merge multiple selected cells into one cell in Jupyter Notebooks <\/li>\n<li>Fallback rendering of output to a supported mimetype in Jupyter <a href=\"https:\/\/github.com\/microsoft\/vscode-jupyter\/issues\/8635\">(vscode-jupyter#8635)<\/a><\/li>\n<li>New <code>refactor.extract<\/code> code action kinds with Pylance: <code>refactor.extract.method<\/code> and <code>refactor.extract.variable<\/code> <a href=\"https:\/\/github.com\/microsoft\/pylance-release\/issues\/3803\">(pylance-release#3803)<\/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\/enthusiastic2003\">@enthusiastic2003<\/a>: Fix for running Python files with parenthesis in path <a href=\"https:\/\/github.com\/microsoft\/vscode-python\/pull\/20414\">(vscode-python#20414)<\/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 February 2023 release of the Python and Jupyter extensions for Visual Studio Code are now available. This release includes automatic environment selection, improvements to the Create Environment command, improved Intellisense support for pytest in preview, and improvements to the Jupyter kernel picker. 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],"tags":[17],"class_list":["post-9272","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-python"],"acf":[],"blog_post_summary":"<p>The February 2023 release of the Python and Jupyter extensions for Visual Studio Code are now available. This release includes automatic environment selection, improvements to the Create Environment command, improved Intellisense support for pytest in preview, and improvements to the Jupyter kernel picker. Keep reading to learn more!<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/9272","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=9272"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/9272\/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=9272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/categories?post=9272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/tags?post=9272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}