Settings for Python coding in Visual Studio Code

This is a continuation of Try Visual Studio Code.

After that, if you set lint and let it check the grammar etc., it should be almost finished as an environment setting, but I will investigate how to set it so that pep8 can be called as homework. I will keep it.

Install Python extensions in Visual Studio Code

As I wrote before, also named Python I have installed and enabled the extension called.

Set lint

The original meaning of lint seems to be lint or something like that, but in short, it's like removing the lint from sewn clothes, or something like that. To put it simply, check the grammar like a mother-in-law.

When it comes to Python grammar and notation checks, there are commands such as pep8 and pylint that check whether the coding standard is PEP8 compliant.

This time, set up Visual Studio Code to call pylint.

Install pylint

I am building an environment with Anaconda, so install pylint as follows.

First, anaconda looks for packaged pylint.

% anaconda search -t conda pylint

Then anaconda / pylint seems to be a standard distribution.

% anaconda show anaconda/pylint
Using Anaconda API: https://api.anaconda.org
Name:    pylint
Summary:
Access:  public
Package Types:  conda
Versions:
   + 1.2.0
   + 1.2.1
   + 1.1.0
   + 1.4.1
   + 1.4.0
   + 1.4.2
   + 1.3.1
   + 1.5.4

To install this package with conda run:
     conda install --channel https://conda.anaconda.org/anaconda pylint

So I knew how to install it.

% conda install --channel https://conda.anaconda.org/anaconda pylint

By the way, in the case of pep8

In the anaconda environment, pep8 was already installed.

Describe in "User settings"

Make user settings for Visual Studio Code.

All you need to do to get lint to work and check every time you save a file is almost enough:

	"python.linting.enabled": true

Or maybe this is the default, and pylint is running.

By the way, if you are a pep8 sect, just do the following.

	"python.linting.enabled": true,
	"python.linting.pylintEnabled": false,
	"python.linting.pep8Enabled": true

After that, I think that you can make the following settings as needed.

If you want to check every time you change the code, or if you want to check when saving the file, set the following items to true.

    "python.linting.lintOnTextChange": true,
    "python.linting.lintOnSave": true,

With the above, when writing Python code in Visual Studio Code, it is possible to check the grammar and notation method by lint.

2017-12-15 Addendum

takerushi pointed out.

For details, see the comments.

    "python.linting.lintOnTextChange": true,

Seems to be abolished.

Recommended Posts

Settings for Python coding in Visual Studio Code
[Visual Studio Code] [Python] Tasks.json + problemMatcher settings for Python
Python development in Visual Studio 2017
Python development in Visual Studio
VS Code settings for developing in Python with completion
Make Visual Studio Code autocomplete for python external libraries
AWS SDK for Python (Boto3) development in Visual Studio 2017
Expose settings.json for efficient Python coding in VS Code
Do something like a Python interpreter in Visual Studio Code
Installation of Visual studio code and installation of python
Python Tools for Visual Studio Installation Guide
Run Python in C ++ on Visual Studio 2017
Bash, Python, Javascript, code command, etc. in Visual Studio Code on Mac
A memo for those who use Python in Visual Studio (me)
Run Python YOLOv3 in C ++ on Visual Studio 2017
Logging settings for daily log rotation in python
Django with Python Tools 2.2 for Visual Studio (PTVS 2.2)
Settings for getting started with MongoDB in python
Create a Python development environment in 10 minutes (Mac OS X + Visual Studio Code)
Highlight Python user function calls in Visual Studio Code (vscode) Default Dark + theme
Steps to put dlib in Python Tools for Visual Studio and have fun
I customized it with Visual Studio Code (mainly for python), so I will summarize it
Translator in Python from Visual Studio 2017 (Microsoft Translator Text API)
Specific sample code for working with SQLite3 in Python
Python development environment with Windows + Anaconda3 + Visual Studio Code
Python development environment with Windows + Python + PipEnv + Visual Studio Code
Until you run server Django in Visual Studio Code
Japanese output when dealing with python in visual studio
Python code for k-means method in super simple case
Install numpy in Visual Studio 2019
Search for strings in Python
Python code memo for yourself
Techniques for sorting in Python
Bottle Pug in Visual studio 2019
Generate QR code in Python
[Python] Sample code for Python grammar
Character code learned in Python
About "for _ in range ():" in python
Execute C ++ functions from Python with Pybind11 (for Windows & Visual Studio Code people) Debugging
Insert Import statements needed for Python code completion in Neovim
How to use linux commands in Visual Studio Code terminal
Set up a Python development environment with Visual Studio Code
How to debug the Python standard library in Visual Studio
Tips for coding short and easy to read in Python
Install python and Visual Studio Code on windows10 (April 2020 version)
Build Python3 for Windows 10 on ARM with Visual Studio 2019 (x86) on Windows 10 on ARM
Execute C ++ functions from Python with Pybind11 (for Windows & Visual Studio Code people) Environment construction
Check for memory leaks in Python
Java with Visual Studio Code (Part 2)
Snippet settings for python jupyter notebook
Check for external commands in python
[Python] Generate QR code in memory
Automatically format Python code in Vim
Visual Studio Code may be good
Write selenium test code in python
Atom preferences for comfortable Python coding
Run unittests in Python (for beginners)
Code tests around time in Python
Create a Python environment for professionals in VS Code on Windows
Try to create a python environment with Visual Studio Code & WSL
How to configure CORS settings for Azure storage service in Python