{"id":2345,"date":"2018-06-05T11:12:44","date_gmt":"2018-06-05T19:12:44","guid":{"rendered":"http:\/\/blogs.msdn.microsoft.com\/pythonengineering\/?p=2345"},"modified":"2019-11-18T22:00:40","modified_gmt":"2019-11-19T06:00:40","slug":"python-in-visual-studio-code-may-2018-release","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-may-2018-release\/","title":{"rendered":"Python in Visual Studio Code \u2013 May 2018 Release"},"content":{"rendered":"<p>We are pleased to announce that the May 2018 release of the Python Extension for Visual Studio Code is now available from the marketplace and the gallery. You can <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. You can learn more about <a href=\"https:\/\/code.visualstudio.com\/docs\/languages\/python\">Python support in Visual Studio Code<\/a> in the VS Code documentation.<\/p>\n<p>In this release we have <a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues?q=milestone%3A%22May+2018%22+is%3Aclosed\">closed a total of 103 issues<\/a> including support for the new and popular formatter Black, improvements to the experimental debugger and formatting as you type.<\/p>\n<h2>Support for Black Formatter<\/h2>\n<p><em><a href=\"https:\/\/github.com\/ambv\/black\">Black<\/a><\/em> is a new code formatting tool for Python that was first released in March and has quickly gained popularity. <em>Black<\/em> has a single opinion about how Python code should be formatted, allowing you to easily achieve consistency across your codebase. The Python extension now supports using it as a formatter.<\/p>\n<p>To enable the <em>Black<\/em> formatter, go into File &gt; User Preferences &gt; Settings, and put the following setting in your User Settings (for settings for all workspaces) or Workspace settings (for the current workspace\/folder).<\/p>\n<pre>\"python.formatting.provider\": \"black\"<\/pre>\n<p>Then run the VS Code command \u201cFormat Document\u201d. You will get a prompt to install the <em>Black<\/em> formatter:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/12\/2019\/02\/1_InstallBlack.png\"><img decoding=\"async\" class=\"size-full wp-image-2355 aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/06\/1_InstallBlack-2.png\" alt=\"\" width=\"552\" height=\"117\" \/><\/a><\/p>\n<p>Selecting Yes will install <em>Black<\/em> into the currently selected interpreter in VS Code. Once <em>Black<\/em> has finished installing, you will need to run the <code>Format Document<\/code> command again to format your document.<\/p>\n<p>In the below code example, we can see that black adds a blank line before functions, spaces around equals signs, and uses double quotation marks instead of single quotation marks:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/12\/2019\/02\/2_BlackResults.png\"><img decoding=\"async\" class=\"size-full wp-image-2365 aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/06\/2_BlackResults-2.png\" alt=\"\" width=\"807\" height=\"325\" \/><\/a><\/p>\n<p>If you want formatting to happen automatically when hitting save, you can add the following setting:<\/p>\n<pre>\"editor.formatOnSave\": true<\/pre>\n<p>If you want to format Python 2.7 code, <em>Black<\/em> will need to run in a Python 3 environment. In that case, you can install black using <code>python3 \u2013m pip install \u2013upgrade black<\/code> into a Python 3 interpreter\/environment of your choice, and then set the <code>python.formatting.blackPath<\/code> setting to point to the black command that was installed (on UNIX-based OSs you can typically find this with the command <code>which black<\/code>).<\/p>\n<h2>Various Fixes 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. The full list of improvements is listed in our <a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/blob\/master\/CHANGELOG.md\">changelog<\/a>, some notable improvements are:<\/p>\n<ol>\n<li>Improvements to testing: added a \u2018Discover Unit Tests\u2019 command (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/1474\">#1474<\/a>) for discovering unit tests, removed error in the output window when running tests (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/1529\">#1529<\/a>)<\/li>\n<li>Improvements to the Experimental Debugger: auto-enable jinja template debugging on *.jinja and *.j2 files (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/1484\">#1484<\/a>), ensure debugged program is terminated when\u00a0Stop\u00a0debugging button is clicked. (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/1345\">#1345<\/a>), support for attach\/detach (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/1255\">#1255<\/a>)<\/li>\n<li>Fixed syntax errors caused when using the editor.formatOnType setting is enabled (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/1799\">#1799<\/a>)<\/li>\n<li>Ensure python environment activation works as expected within a multi-root workspace. (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/1476\">#1476<\/a>)<\/li>\n<li>Fixed flask debugging configurations so that they work with the latest versions of flask (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/1634\">#1634<\/a>)<\/li>\n<li>Ensure the display name of an interpreter does not get prefixed twice with the words\u00a0Python. (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/1651\">#1651<\/a>)<\/li>\n<li>`Go to Definition`\u00a0now works for functions which have numbers that use\u00a0`_` as a separator (as part of our Jedi 0.12.0 upgrade). (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/180\">#180<\/a>)<\/li>\n<li>Fixed rename refactor issue that removes the last line of the source file when the line is being refactored and source does not end with an EOL. (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/695\">#695<\/a>)<\/li>\n<\/ol>\n<p>Be sure to <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-python.python\">download the Python extension<\/a> for VS Code now to try out the above improvements. If you run into any issues be sure to file an issue on the <a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/milestone\/3\">Python VS Code GitHub<\/a> page.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We are pleased to announce that the May 2018 release of the Python Extension for Visual Studio Code is now available from the marketplace and the gallery. In this release we have closed a total of 103 issues including support for the new and popular formatter Black, improvements to the experimental debugger and formatting as you type.<\/p>\n","protected":false},"author":883,"featured_media":2832,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-2345","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-visual-studio-code"],"acf":[],"blog_post_summary":"<p>We are pleased to announce that the May 2018 release of the Python Extension for Visual Studio Code is now available from the marketplace and the gallery. In this release we have closed a total of 103 issues including support for the new and popular formatter Black, improvements to the experimental debugger and formatting as you type.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/2345","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\/883"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/comments?post=2345"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/2345\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/media\/2832"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/media?parent=2345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/categories?post=2345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/tags?post=2345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}