(🐞) No error when overload implementation has incompatible return type
未关闭
还没有人认领这个 Issue。
feature
topic-overloads
- 主要语言
- Python
- 星标
- 20.6k
- 派生
- 3.3k
- PR 合并指标
- PR 指标待抓取
描述
from typing import overload
@overload
def foo(a: int) -> int: ...
@overload
def foo(a: float) -> int: ...
def foo(a: object) -> object: # no error
return object()
While the strictest of solutions would be to enforce the return type be an intersection of the overload return types, that would result in being overly strict to the point of being unusable. I suggest enforcing the return type to be a union of the overloads, this is not typesafe, but is much safer than not checking it at all.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,在链接的 mypy playground 中复现该示例,并跟踪它所执行的 overload 实现返回类型检查。将完成定义为:针对实现的不兼容返回类型生成诊断,同时保留所述的 overload 预期行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100