静态填充 `known_third_party` `isort` 设置。
项目描述
seed-isort-config
静态填充 known_third_party
isort
设置。
当单独运行时,isort
并不擅长确定哪些依赖项是第三方。
幸运的是,aspy.refactor_imports
在静态分析方面做得更好。
为什么不直接使用 reorder-python-imports
呢?嗯,它缺少一些由 isort
提供的功能(故意)。
此脚本所做的就是在自动填充 known_third_party
isort 配置。
安装
pip install seed-isort-config
用法
seed-isort-config
提供了一个同名可执行文件。在 git
仓库内运行它。
要指定自定义应用程序根目录(如使用 src
模式),请传递冒号分隔的 --application-directories
参数。
可以使用 --exclude
标志排除文件。此参数接受 Python 正则表达式。
有关完整参数列表,请参阅 seed-isort-config --help
。
入门
seed-isort-config
在 isort 配置文件中查找现有的 known_third_party
设置。如果存在,它将修改该设置,否则将创建一个新的 .isort.cfg
文件。
开始的最简单方法是只需在您的 isort 配置中添加一个空的 known_third_party =
部分(如果使用 pyproject.toml
,则为 known_third_party = []
)。
与 pre-commit 一起使用
当与 pre-commit
集成时,这效果尤其好。
- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config
- repo: https://github.com/timothycrosley/isort
rev: 4.3.21 # pick the isort version you'd like to use from https://github.com/timothycrosley/isort/releases
hooks:
- id: isort
在此配置中,seed-isort-config
将在isort
运行之前调整isort
配置中的known_third_party
部分!
请注意,seed-isort-config
不像正常的pre-commit linter那样操作,因此必须通过args: [--exclude=...]
配置文件排除。例如:args: [--exclude=tests/.*\.py]
。
项目详情
seed_isort_config-2.2.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | be4cfef8f9a3fe8ea1817069c6b624538ac0b429636ec746edeb27e98ed628c8 |
|
MD5 | e1036cf42fef58eaf11d73a4ce828c33 |
|
BLAKE2b-256 | e1b2bda7e27d9b42e7fae4d78f47709f2c21f9cf0f3f927f701d9e6a8bd533a6 |
seed_isort_config-2.2.0-py2.py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 8601fb715a5a4aac39256bbf73c2da6a81f964da9c9d9897ab9074db3663526f |
|
MD5 | d37593d959a7c2837b0a12f658261b31 |
|
BLAKE2b-256 | 6b8578c654684181ecab22c279d425479a5265f9c1fa144939b35bdf1ac7cc35 |