Consider adding a "TopLevel" keyword that stands in for the top level bound of a corresponding type variable
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 1.8k
- 派生
- 302
- 平均合并
- 23 小时
- 30 天内合并 PR
- 8
描述
Summary
Please consider a new typing keyword that stands in for the top level type of a corresponding type variable.
Motivation
Consider a test here and the corresponding definition of DistributionInfo here. The test loses all typing information because I used DistributionInfo[Any, Any, Any]. So if I want typing information, I have to use:
def test_flatten(generator: Generator,
distribution_info: DistributionInfo[NaturalParametrization[ExpectationParmetrization, JaxComplexArray],
ExpectationParametrization[NaturalParmetrization],
NumpyComplexArray]) -> None:
I would much rather just do
def test_flatten(generator: Generator,
distribution_info: DistributionInfo[TopLevel, TopLevel, TopLevel]) -> None:
It's not just shorter, but it reduces churn if the type definitions change. Note that TopLevel is recursive (it chooses the top level of the nested types too).
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从链接的 tests/test_flatten.py 和 tests/distribution_info.py 开始,了解使用 DistributionInfo[Any, Any, Any] 时会丢失哪些类型信息。明确 TopLevel 的预期递归语义,以及它与现有类型变量行为的区别。当提案包含精确的规范和已达成一致的验证路径时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- devtools
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100