Rework specifying and layering of configuration
还没有人认领这个 Issue。
评估
调研方向
首先跟踪 flake8 的 CLI 解析、配置文件加载和配置分层路径;该 issue 未指定具体文件或测试。将当前行为与每个 shell 示例进行比较,然后定义重复使用 --config、移除 --append-config 以及处理 --isolated 所需的解析顺序和优先级规则。实现并验证所列行为即表示完成。
由索引模型根据 Issue 内容生成。
描述
In GitLab by @ericvw on Dec 29, 2019, 07:30
After having spent some time making changes in CLI parsing, the configuration
file loading, and the layering of the configuration options, I would like to
simplify how configuration gets specified and layered. I wanted to raise this
issue for awareness and discussion before proceeding with this larger goal.
The user-facing would be the following:
- Allow
--configto be used multiple times for specifying configuration
files. Options in subsequent--configfile take precedence. The command
line arguments in the configuration files will be used as if they were
provided first on the command line before other options that are specified on
the command line. - Remove
--append-configin favor of--confignow that--configcan be
specified multiple times. - Keep
--isolatedto ignore the automatic detection of configuration (i.e.,
user configuration and the searching-up-the-paths configuration). However,
--configmay be specified with--isolatedto provide files to be parsed.
Below are the behaviors expected if the above changes were implemented:
# Configuration options found in the user's config path followed by
# configuration options found locally taking precedence.
flake8 file1.py file2.py
# Same as above with options in 'config.ini' taking precedence.
flake8 --config config.ini file1.py file2.py
# The '--max-line-length 99' takes precedence over the option specified in
# any configuration file.
flake8 --max-line-length 99 --config config.ini file1.py file2.py
# Configuration options in 'config2.ini' takes precedence over those in 'config1.ini'.
flake8 --config config1.ini --config2.ini file1.py file2.py
# Configuration options in 'config1.ini' takes precedence over those in 'config2.ini'.
flake8 --config2.ini --config config1.ini file1.py file2.py
# Default configuration is used and not read from the user's config path nor
# detecting local configuration.
flake8 --isolated file1.py file2.py
# Same as above, however, configuration options in 'config.ini' are used as if they were
# specified on the command line.
flake8 --isolated --config 'config.ini' file1.py file2.py
With these changes, the benefits are the following:
- Configuration files from
--configare just appended to a single list to be
parsed. If--isolatedis not specified, elide the user and local files
included in the list of configuration files to parse. - Handling of single configuration and what is considered "appended"
configuration is exactly the same. - With
--isolatedpresent, there is still an elegant way to specify a set of
configuration options via file without having to put them all on the command
line.
The following trade-offs are the following:
- The changes are backward-incompatible.
- Removal of
--append-config. - Changing the behavior of
--isolatedto allow--configin addition to. - Change the behavior of
--configto be specified multiple times.
- Removal of
@asottile and @sigmavirus24, would greatly appreciate your input and feedback
before I proceed forward. Thanks!
- 主要语言
- Python
- 星标
- 3.8k
- 派生
- 356
- 平均合并
- 3 小时 25 分钟
- 30 天内合并 PR
- 5
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
PyCQA/flake8 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 76/100
-
难度 3/5 1-2 天 新手友好度 45/100
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 42/100
-
难度 3/5 1-2 天 新手友好度 35/100
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 72/100
letsencrypt/cp-cps#353 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 84/100
PedestrianDynamics/pyFDS-Evac#394 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
DOI-USGS/pywatershed#421 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
python-pillow/Pillow#10087 · 1 条评论 ·
维护者通常 1 天内回复