Expose settings.json for efficient Python coding in VS Code

I usually code in Python, so I set it in VS Code so that I can code efficiently. I would like to introduce the setting.

environment

Development library for efficient coding

It is assumed that you will build a development environment with pipenv

settings.json

Full setting

json:.vscode/settings.json


{
  "[python]": {
    "editor.tabSize": 4,
    "editor.formatOnSave": true,
    "editor.formatOnPaste": false,
    "editor.formatOnType": false,
    "editor.insertSpaces": true,
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
    },
  },
  "python.pythonPath": "${workspaceFolder}/.venv/bin/python",
  "python.envFile": "${workspaceFolder}/.env",
  "python.linting.enabled": true,
  "python.linting.pylintEnabled": false,
  "python.linting.pycodestyleEnabled": false,
  "python.linting.flake8Enabled": true,
  "python.formatting.provider": "black",
  "python.formatting.blackPath": "${workspaceFolder}/.venv/bin/black",
  "python.sortImports.path": "${workspaceFolder}/.venv/bin/isort",
  "python.linting.mypyEnabled": true,
  "python.linting.mypyPath": "${workspaceFolder}/.venv/bin/mypy",
  "python.linting.mypyArgs": [
    "--config-file", "mypy.ini"
  ],
  "python.testing.unittestEnabled": false,
  "python.testing.nosetestsEnabled": false,
  "python.testing.pytestEnabled": true,
  "python.testing.pytestArgs": [
    "-vv",
    "--show-capture=all",
    "tests"
  ],
  "autoDocstring.docstringFormat": "google",
}

Reading environment variables

"python.envFile": "${workspaceFolder}/.env"

If you specify the file that sets the environment variable in python.envFile, the environment variable will be read.

Automatic formatting by isort

In order to automatically format the import statement with isort, it is necessary to set to enable automatic formatting in addition to specifying the PATH of iceplant.

"editor.codeActionsOnSave": {
   "source.organizeImports": true
}

The settings are written in the pull request of Add isort CodeAction (sort imports on save) # 1926.

docstring

docstring uses google notation. Type " "" and press Enter to automatically complete the docstring.

"autoDocstring.docstringFormat": "google"

reference

Recommended Posts

Expose settings.json for efficient Python coding in VS Code
VS Code settings for developing in Python with completion
Create a Python environment for professionals in VS Code on Windows
Use Python in Anaconda environment with VS Code
Specific sample code for working with SQLite3 in Python
Allow real-time code checking in Python development with VS Code
Revive symbol search in Python workspace with VS Code
Python code for k-means method in super simple case
Python with VS Code (Windows 10)
Search for strings in Python
Python code memo for yourself
Techniques for sorting in Python
Debug Python with VS Code
Generate QR code in Python
[Python] Sample code for Python grammar
Character code learned in Python
About "for _ in range ():" in python
Insert Import statements needed for Python code completion in Neovim
Tips for coding short and easy to read in Python
UpNext2 Development Record # 1 Build Python CI environment in VS Code
I want to be able to run Python in VS Code
Check for memory leaks in Python
Check for external commands in python
[Python] Generate QR code in memory
Automatically format Python code in Vim
VS Code snippets for data analysts
Write selenium test code in python
Python unittest module execution in vs2017
Atom preferences for comfortable Python coding
Run unittests in Python (for beginners)
Code tests around time in Python
[VS Code] ~ Tips when using python ~
Install python with mac vs code
Prepare a Python virtual environment for your project with venv with VS Code
Code reading of Safe, a library for checking password strength in Python
Fourier series verification code written in Python
Notes on nfc.ContactlessFrontend () for nfcpy in python
Inject is recommended for DDD in Python
Summary of various for statements in Python
Type annotations for Python2 in stub files!
Template for writing batch scripts in python
Pass PYTHONPATH in 1 minute with VS Code
MongoDB for the first time in Python
Get a token for conoha in python
Sample for handling eml files in Python
AtCoder cheat sheet in python (for myself)
A tool for easily entering Python code
I searched for prime numbers in python
Notes for using python (pydev) in eclipse
Tips for making small tools in python
Use pathlib in Maya (Python 2.7) for upcoming Python 3.7
Get the EDINET code list in Python
Notes on using code formatter in Python
[Python coding standard] PEP 8 vs Google Style
R code compatible sheet for Python users
Code reading for m3u8, a library for manipulating HLS video format m3u8 files in Python
Template for creating command line applications in Python
CERTIFICATE_VERIFY_FAILED in Python 3.6, the official installer for macOS
VS Code + Azure Functions + Python environment construction procedure
++ and-cannot be used for increment / decrement in python
Import-linter was useful for layered architecture in Python