black
$ pip install black
$ black target_dir/* target_file
設定ファイル
「設定する必要はない」というのがBlackの考え
用意するならpyproject.toml
code:pyproject.toml
line-length = 100
include = '\.pyi?$'
exclude = '''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
| foo.py # also separately exclude a file named foo.py in
# the root of the project
)
'''
code:toml
line-length = 100
exclude = """(
.git
| .venv
| migrations
)
"""
code:settings.json
{
"python.formatting.provider": "black",
"python.formatting.blackPath": "/usr/local/bin/black",
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnType": true,
}
プロジェクトのルートにpyproject.tomlがある状態で、.blackArgsが設定されていると機能しなかった
refs