LoginSignup
1
0

More than 1 year has passed since last update.

isort で ignore_blobs を設定する

Last updated at Posted at 2021-09-10

isort の実行時にファイル(パス)を無視させる設定をしようとして、書き方がぱっとわからなかったのでメモ

環境

  • Python + poetry + Django
  • 設定ファイル: pyproject.toml
  • isort = "5.9.3"

ignore_blobs

ファイルを無視させるには ignore_blobs というオプションを設定すれば良いらしく、これを pyproject.toml に記述する。

[tool.isort]
ensure_newline_before_comments = true
force_grid_wrap = 0
force_single_line = false
include_trailing_comma = true
line_length = 120
multi_line_output = 3
use_parentheses = true
# こんな感じでカンマ区切りでファイルを渡す
skip_glob = "*/migrations/*.py,src/lib/*.py"

設定の確認方法

現在適用されている設定は下記のコマンドで確認できる。
設定を見ると、pyproject.toml で渡しているもの以外にも、デフォルトで skip されているファイルもあることが確認できる。ここで設定されているものは、わざわざ自前で書いてあげなくても良さそう。

poetry run isort --show-config
1
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
1
0