pink
pink 是一个代码格式化工具,支持格式化整个文件夹代码导包顺序。
安装
$ pip install pink
用法
$ pink
usage: pink [-h] [-l LINE] [-sp SETTINGS_PATH] [-v] [PATHS [PATHS ...]]
Format imports via command line with `isort`
positional arguments:
PATHS Files and directories that should be executed format
command.
optional arguments:
-h, --help show this help message and exit
-sp SETTINGS_PATH, --settings_path SETTINGS_PATH
`isort` Explicitly set the settings path instead of
auto determining based on file location
-v, --version Displays the current version of pink
示例
$ pink {source_file/source_dir}
# 格式化文件
$ pink code.py
# 格式化单文件夹
$ pink code/*.py
# 格式化多文件夹
$ pink code/*.py test/*.py
# 如若需要配置 isort,需要在项目下新建一个 .isort.cfg 文件
# 具体配置参考 [官方文档](https://github.com/timothycrosley/isort)
$ pink code/*.py test/*.py -sp .isort.cfg
LICENSE
MIT ©chenjiandongx