Customize static analysis behavior¶
fmt
コマンドによって実行される静的解析をfully alterするには、hatch-static-analysis
という名前の予約されたenvironmentを変更します。たとえば、デフォルトの動作をBlack,isortとbasicflake8の組み合わせに置き換える場合は、次のように定義できます。:
[tool.hatch.envs.hatch-static-analysis]
dependencies = ["black", "flake8", "isort"]
[tool.hatch.envs.hatch-static-analysis.scripts]
format-check = [
"black --check --diff {args:.}",
"isort --check-only --diff {args:.}",
]
format-fix = [
"isort {args:.}",
"black {args:.}",
]
lint-check = "flake8 {args:.}"
lint-fix = "lint-check"
[envs.hatch-static-analysis]
dependencies = ["black", "flake8", "isort"]
[envs.hatch-static-analysis.scripts]
format-check = [
"black --check --diff {args:.}",
"isort --check-only --diff {args:.}",
]
format-fix = [
"isort {args:.}",
"black {args:.}",
]
lint-check = "flake8 {args:.}"
lint-fix = "lint-check"
format-*
スクリプトは--formatter
/-f
フラグに対応し、lint-*
スクリプトは--linter
/-l
フラグに対応します。*-fix
スクリプトはデフォルトで実行され、*-check
スクリプトは--check
フラグに対応します。この例に基づいて、さまざまなスクリプトが動作にどのように影響するかを次に示します。:
Command | Expanded scripts |
---|---|
hatch fmt |
|
hatch fmt src tests |
|
hatch fmt -f |
|
hatch fmt -l |
|
hatch fmt --check |
|
hatch fmt --check -f |
|
hatch fmt --check -l |
|