LoginSignup
0
0

More than 1 year has passed since last update.

【Python】VSCodeでPEP8に沿ったプログラムを書く

Posted at

はじめに

vscodeには、Pythonの標準コーディングスタイルであるPEP8に準拠したフォーマッタツールが用意されています。それらを使用するための設定を行いました。

参考記事

【Lint】vscodeでpep8のチェックをする手順【Python】
[python PEP8] VSCodeでautopep8とflake8を適用する

autopep8の適用

上記記事の手順に従ってautopep8のインストールと設定を行ました。
保存時のフォーマットも有効化しました。
スクリーンショット 2023-03-30 21.42.26.png
ファイル保存時に下記のようにフォーマットしてくれます。

# 保存前
a = [1,2,3,4]

# 保存後
a = [1, 2, 3, 4]

flake8の適用

上記記事で参照されている記事の手順に従ってflake8のインストールと設定を行ました。
ファイル保存時、コーディング規約に違反したコードに波線が引かれています。
スクリーンショット 2023-03-30 22.11.18.png

設定後のsettings.json

{
    "editor.formatOnSave": true,
    "python.linting.flake8Enabled": true
}
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