Clarification on how Typevars in a generic function should resolve
未关闭
还没有人认领这个 Issue。
topic: documentation
- 主要语言
- Python
- 星标
- 1.8k
- 派生
- 302
- 平均合并
- 23 小时
- 30 天内合并 PR
- 8
描述
Hi, regarding the issue opened here:
https://github.com/astral-sh/ty/issues/2255
Can you please provide clarification on how TypeVars in a function like func in the below code should be resolved?
class A:
pass
class B(A):
pass
class C(A):
pass
def func[T: A](x: T, y: T) -> T:
...
func(B(), C()) # I think this should raise a type error by type checkers but no type checker (mypy, pyright, etc) raise an error for this
Please look at these comments:
https://github.com/astral-sh/ty/issues/2255#issuecomment-3697606854
https://github.com/astral-sh/ty/issues/2255#issuecomment-3697628015
https://github.com/astral-sh/ty/issues/2255#issuecomment-3698867080
https://github.com/astral-sh/ty/issues/2255#issuecomment-3699067335
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
先阅读链接的 ty issue #2255 及其中引用的评论,然后将它们的解释与此处的泛型函数示例进行比较。记录在 func(B(), C()) 中解析 T 的约定规则,包括是否应拒绝该调用;当 typing 社区有了明确且已记录的答案时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- compilers, documentation
- Issue 类型
- 文档
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 冷清
- 描述清晰度
- 需要澄清
- 新手友好度
- 30/100