0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【備忘録】VSCodeでlinter、formatterの設定をする自分用メモ(flake8、black、isort)

Posted at

概要

題名の通り、VSCodeでlinter、formatterとしてflake8、black、isortを使用するための設定方法についての手順メモ。自分用メモなので間違っているかもしれない。

手順

前提

以下を前提とする:

  • Python3系がインストール済み
  • VSCodeがインストール済み
  • VSCodeの拡張機能のPythonがインストール済み
  • VSCodeの拡張機能のPylanceがインストール済み(拡張機能のPythonを入れると勝手に入ってるはず)

flake8、blackのpipインストール

上記3つを使うためにとりあえず以下を実行してモジュールをインストールする:

flake8のインストール
pip install flake8
blackのインストール
pip install black

(本当はどちらも次のisortと同じく、VSCodeの拡張機能で入れるのが推奨っぽい)

VSCodeの拡張機能でisortを入れる

VSCodeの「拡張機能」を開き、検索窓から「isort」を検索してisortをインストールする。

settings.jsonへ設定を記載

まず、左下の歯車マークをクリック→設定を選択し、右上の方にある「紙をひっくり返す?」的なマークをクリックしてsettings.jsonを開く。
そして開いたsettings.jsonに次を追記する:

settings.jsonへの追記事項
{
    "python.linting.enabled": true,
    "python.linting.pylintEnabled": false,
    "python.linting.flake8Enabled": true,
    "python.formatting.provider": "black",
    "editor.defaultFormatter": null,
    "editor.formatOnSave": true
}

これである程度PEP8に沿ってプログラミングを進めていける(はず)

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?