Preventing code quality regressions
未关闭
还没有人认领这个 Issue。
project: infrastructure
- 主要语言
- Python
- 星标
- 5.1k
- 派生
- 2.1k
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 82
描述
For some time now we've used pyright's stricter configuration to prevent code quality regressions. Unless a stubs package is mentioned in the config file, it's expected to have annotations for all its fields. While this has served us well for a while, it has become unsuitable since the introduction of _typeshed.Incomplete:
- pyright doesn't understand that a (partial)
Incompleteannotation is equivalent (for our purposes) to an unannotated item. - It's tedious to maintain the pyright stricter configuration in addition to the metadata in the stubs directory.
- It's easy to cheat the regression check by using
Incomplete.
To improve the situation, I propose to move to a custom solution:
- Add an
incompletemarker toMETADATA.toml(defaulting tofalse). - Add a custom script to CI that checks that a stub package marked as complete can't have any incomplete (unannotated or using
Incomplete) fields. Alternatively, we could add a disabled-by-default check to flake8-pyi and use that instead. - At a later date, we could also add a PR CI script that add a PR comment warning a user if the amount of incomplete increases due to a PR.
(See also https://alexwaygood.github.io/typeshed-stats/.)
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先查看 METADATA.toml 中的存根包元数据,以及使用 pyright 更严格配置的当前 CI 检查。比较实现自定义 CI 脚本与采用提议的默认禁用的 flake8-pyi 检查。完成的标准是:完整包不能包含未添加类型注解的字段,也不能包含使用 _typeshed.Incomplete 的字段,并且不完整标记默认为 false。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- ci-cd, tooling
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100