カスタムコマンド例¶
[tool.pyfltr.custom-commands]で任意のツールを追加できる。
カスタムコマンドの仕様はツール別設定の「カスタムコマンド」セクションを参照。
導入手順ははじめにを参照。
error-patternは名前付きグループfile / line / messageが必須、colは任意。
正規表現にこれらが含まれない場合は設定エラーとなる。
Pythonセキュリティ・品質ツール¶
bandit(セキュリティチェック)¶
設定ファイルとしてpyproject.tomlの[tool.bandit]または.banditを参照する例。
config-filesに列挙すると、対象ツール有効化時にいずれもプロジェクトルート直下に存在しない場合に
pyfltrが警告を発行する(ツール自体は実行する)。
[tool.pyfltr.custom-commands.bandit]
type = "linter"
path = "bandit"
args = ["-r", "-f", "custom"]
targets = "*.py"
error-pattern = '(?P<file>[^:]+):(?P<line>\d+):(?P<col>\d+):\s*(?P<message>.+)'
config-files = ["pyproject.toml", ".bandit"]
fast = true
deptry(未使用・不足依存の検出)¶
[tool.pyfltr.custom-commands.deptry]
type = "linter"
path = "deptry"
args = ["."]
targets = "*.py"
pass-filenames = false
vulture(未使用コードの検出)¶
[tool.pyfltr.custom-commands.vulture]
type = "linter"
path = "vulture"
args = []
targets = "*.py"
error-pattern = '(?P<file>[^:]+):(?P<line>\d+):\s*(?P<message>.+)'
fast = true
detect-secrets(シークレット検出)¶
[tool.pyfltr.custom-commands.detect-secrets]
type = "linter"
path = "detect-secrets"
args = ["scan", "--list-all-plugins"]
targets = "*.py"
pass-filenames = false
汎用ツール¶
codespell(スペルチェック)¶
fix-argsを定義するとfix段でargsの後ろに追加されて--write-changes付きで実行される。
[tool.pyfltr.custom-commands.codespell]
type = "linter"
path = "codespell"
args = []
fix-args = ["--write-changes"]
targets = ["*.py", "*.md", "*.rst", "*.txt"]
fast = true
cspell(スペルチェック、npm系)¶
js-runner対応のスペルチェッカー。package.jsonでインストールする前提で、js-runner = "pnpm"と併用する。
[tool.pyfltr]
js-runner = "pnpm"
[tool.pyfltr.custom-commands.cspell]
type = "linter"
path = "cspell"
args = ["lint", "--no-progress", "--no-summary"]
targets = ["*.py", "*.md", "*.ts", "*.js"]
error-pattern = '(?P<file>[^:]+):(?P<line>\d+):(?P<col>\d+)\s*-\s*(?P<message>.+)'
fast = true
JS/TSプロジェクト向け¶
svelte-check(Svelteの型チェック)¶
[tool.pyfltr.custom-commands.svelte-check]
type = "linter"
path = "svelte-check"
args = ["--tsconfig", "./tsconfig.json"]
targets = "*.svelte"
pass-filenames = false