Python コードチェック
Key word
- Python, Visual Studio Code
- linter, formatter
- flake8, black
はじめに
Pythonの環境を構築する際のlinter, formatterの設定をメモしておきます.
メモ
準備
必要なものをインストール
pip install flake8
pip install black
vscode設定
{
  "python.languageServer": "Pylance",
  "python.analysis.diagnosticSeverityOverrides": {
      "reportGeneralTypeIssues": "none" // np.piなどでerrorが出るので対処
  },
  "python.linting.enabled": true,
  "python.linting.pylintEnabled": false,
  "python.linting.flake8Enabled": true,
  "python.linting.lintOnSave": true,
  "python.formatting.provider": "black",
  "python.linting.flake8Args": [
      "--max-line-length",
      "88",
      "--ignore",
      "E203, E266, E501, F403, F401"
  ],
  "python.formatting.blackArgs": [
      "--ignore",
      "W503"
  ],
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
      "source.organizeImports": true
  }
}
W503(2項演算子の前で改行)などflake8のルールをblackとの兼ね合いで無視するところが少し気になる.
