3
0

VSCode PythonのBlack Formatter、Flake8、isortインストールと設定

Last updated at Posted at 2024-03-15

はじめに

VSCodeでPythonコードを作成する時、使用しているVSCodeの拡張機能(Black Formatter、Flake8、isort)のインストールと自分が使っている設定を整理した。

Black Formatter

Pythonコードを自動的にフォーマットするツール

Flake8

Pythonのコードをチェックするツール

isort

インポートの順序をフォーマットするツール

設定

VSCodeのsetting.jsonで以下のコードを作成する。
例には1行の最大文字数を100にしている。

setting.json
  "[python]": {
    "editor.defaultFormatter": "ms-python.black-formatter",
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {
      "source.organizeImports": "explicit"
    }
  },
  "black-formatter.args": ["--line-length=100"],
  "flake8.args": ["--max-line-length=100"],
  "isort.args": ["--profile", "black"]
3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0