{"id":1775,"date":"2018-02-01T12:18:26","date_gmt":"2018-02-01T20:18:26","guid":{"rendered":"http:\/\/blogs.msdn.microsoft.com\/pythonengineering\/?p=1775"},"modified":"2019-11-18T22:01:31","modified_gmt":"2019-11-19T06:01:31","slug":"python-in-visual-studio-code-jan-2018-release","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-jan-2018-release\/","title":{"rendered":"Python in Visual Studio Code \u2013 Jan 2018 Release"},"content":{"rendered":"<div class=\"post\">\n<div class=\"body\">\n<div class=\"postBody\" id=\"ed8a662e-8a7d-4050-9e00-f58f019bf009\">\n<p>We\u2019re pleased to announce the January 2018 release for the Microsoft Python extension for Visual Studio code is now available. You can the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-python.python\">download the Microsoft Python extension for VS Code<\/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 <a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/milestone\/2?closed=1\">closed a total of 72 issues<\/a> focusing on linting improvements, support for virtual environments, and other general improvements. Keep on reading for some of the highlights.<\/p>\n<div class=\"post\">\n<div class=\"body\">\n<div class=\"postBody\" id=\"ed8a662e-8a7d-4050-9e00-f58f019bf009\">\n<h2>Improved Default Linter Rules<\/h2>\n<div class=\"post\">\n<div class=\"body\">\n<div class=\"postBody\" id=\"ed8a662e-8a7d-4050-9e00-f58f019bf009\">\n<p>The default Pylint rules used in the extension have been improved to reduce noise in the editor. By default, only errors and warnings are shown that are useful for catching coding mistakes and are likely to result in runtime exceptions. We have disabled the style rules and most of the warnings, resulting in less noise in the editor when using the default settings. You can view the default ruleset definition in our\u00a0<a href=\"https:\/\/code.visualstudio.com\/docs\/python\/linting#_pylint\">Linting Python in VS Code<\/a>\u00a0documentation.<\/p>\n<p>The default Pylint options activate all linter rules (also known as checkers), including many style warnings. This meant that previously many warnings were shown complaining about the names of variables and functions by default. While these style warnings can be useful for some code bases, they can also add a lot of unnecessary noise for others. For example, the below warning tells me that I should be using uppercase for the \u201curlpatterns\u201d variable, which goes against the coding style being used in this codebase:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/12\/2019\/02\/1_LintingRules.png\"><\/a><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/12\/2019\/02\/1_LintingRules.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/02\/1_LintingRules.png\" alt=\"\" class=\"wp-image-1785 size-full aligncenter\" width=\"761\" height=\"267\" \/><\/a><\/p>\n<p>You can customize which rules are enabled to match the style used in your codebase by:<\/p>\n<ul>\n<li>Adding a <em>.pylintrc<\/em> file in your workspace, e.g. in a specific folder with .py files or in the workspace root.<\/li>\n<li>Modifying the <em>python.linting.pylintArgs<\/em> setting.<\/li>\n<li>Disabling our ruleset by setting <em>python.linting.pylintUseMinimalCheckers<\/em> to <em>false<\/em>, which will enable Pylint&#8217;s own default rules.<\/li>\n<\/ul>\n<h2>Commands for Configuring Linting<\/h2>\n<div class=\"post\">\n<div class=\"body\">\n<div class=\"postBody\" id=\"ed8a662e-8a7d-4050-9e00-f58f019bf009\">\n<div class=\"body\">\n<div class=\"postBody\" id=\"ed8a662e-8a7d-4050-9e00-f58f019bf009\">\n<p>There are new linting commands that allow you to configure some linter settings without having to manually edit configuration files. The <i>Python: Select Linter<\/i> command allows you to select your linter of choice, and the <i>Python: Enable Linting<\/i> allows you to enable and disable linting.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/12\/2019\/02\/02_SelectLinter.png\"><\/a><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/12\/2019\/02\/02_SelectLinter.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/02\/02_SelectLinter.png\" alt=\"\" class=\"aligncenter wp-image-1795 size-full\" width=\"504\" height=\"248\" \/><\/a><\/p>\n<div class=\"post\">\n<div class=\"body\">\n<div class=\"postBody\" id=\"ed8a662e-8a7d-4050-9e00-f58f019bf009\">\n<div class=\"post\">\n<div class=\"body\">\n<div class=\"postBody\" id=\"ed8a662e-8a7d-4050-9e00-f58f019bf009\">\n<p>Selecting a linter allows you to easily switch from Pylint to Flake8 or other supported linters. Note that using this command will only enable a single linter to be run, if you want to configure multiple linters you can do so by manually editing configuration options.<\/p>\n<h2>Terminal Now Uses Conda and Virtual Environments<\/h2>\n<p>Creating a new Python terminal will now automatically activate the currently selected virtual or conda environment.<\/p>\n<p>Below is a simple \u201chello world\u201d flask web app. Flask is not installed globally on this machine, but it is installed in the virtual environment in the app\u2019s current folder.<\/p>\n<p style=\"text-align: center\"><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/12\/2019\/02\/2_HelloFlask.png\"><\/a><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/12\/2019\/02\/2_HelloFlask.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/02\/2_HelloFlask.png\" alt=\"\" class=\"alignnone wp-image-1796 size-full\" width=\"540\" height=\"260\" \/><\/a><\/p>\n<div class=\"post\">\n<div class=\"body\">\n<div class=\"postBody\" id=\"ed8a662e-8a7d-4050-9e00-f58f019bf009\">\n<p>You can activate the virtual environment using the <i>Python: Select Interpreter<\/i> command:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/12\/2019\/02\/3_SelectInterpreter.png\"><\/a><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/12\/2019\/02\/3_SelectInterpreter.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/02\/3_SelectInterpreter.png\" alt=\"\" class=\"wp-image-1805 size-full aligncenter\" width=\"730\" height=\"271\" \/><\/a><\/p>\n<div class=\"post\">\n<div class=\"body\">\n<div class=\"postBody\" id=\"ed8a662e-8a7d-4050-9e00-f58f019bf009\">\n<p>You can create a new terminal using the <em>Python: Create Terminal<\/em> command, which will open a command window and activate the selected virtual or conda environment:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/12\/2019\/02\/4_CreateTerminal.png\"><\/a><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/12\/2019\/02\/4_CreateTerminal.png\"><\/a><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/12\/2019\/02\/4_CreateTerminal.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/02\/4_CreateTerminal.png\" alt=\"\" class=\"wp-image-1835 size-full aligncenter\" width=\"659\" height=\"183\" \/><\/a><\/p>\n<div class=\"post\">\n<div class=\"body\">\n<div class=\"postBody\" id=\"ed8a662e-8a7d-4050-9e00-f58f019bf009\">\n<p>You can then run the app using <em>python helloflask.py<\/em>, and the app will run successfully because flask is available in the activated virtual environment:<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/12\/2019\/02\/05_RunApp.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/02\/05_RunApp.png\" alt=\"\" class=\"size-full wp-image-1825 aligncenter\" width=\"662\" height=\"277\" \/><\/a><\/p>\n<div class=\"post\">\n<div class=\"body\">\n<div class=\"postBody\" id=\"ed8a662e-8a7d-4050-9e00-f58f019bf009\">\n<p>In previous versions this would fail because it would run the file using the global python interpreter\u00a0instead of the virtual environment\u2019s interpreter, which does not have flask installed,.<\/p>\n<p>The <i>Python: Run File in Terminal<\/i> command will also activate the selected environment before running the Python script. If for any reason you want to disable virtual environment terminal activation, set <i>python.terminal.activateEnvironments<\/i> to <i>false<\/i>.<\/p>\n<h2>Try it out today<\/h2>\n<p>Try out the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-python.python\">Python VS Code extension<\/a> today, and be sure to <a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/new\">file an issue on our Microsoft\/vscode-python GitHub page<\/a> if you run into any problems.<\/p>\n<p>We are continuing to improve the extension and are releasing a new version every month, so be sure to tell us what you think!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We\u2019re pleased to announce the January 2018 release for the Microsoft Python extension for Visual Studio code is now available. You can the download the Microsoft Python extension for VS Code from the marketplace, or install it directly from the extension gallery in Visual Studio Code. You can learn more about Python support in Visual [&hellip;]<\/p>\n","protected":false},"author":883,"featured_media":10119,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-1775","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-visual-studio-code"],"acf":[],"blog_post_summary":"<p>We\u2019re pleased to announce the January 2018 release for the Microsoft Python extension for Visual Studio code is now available. You can the download the Microsoft Python extension for VS Code from the marketplace, or install it directly from the extension gallery in Visual Studio Code. You can learn more about Python support in Visual [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/1775","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=1775"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/1775\/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=1775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/categories?post=1775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/tags?post=1775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}