Exhaustiveness of type tuple[bool, bool]
还没有人认领这个 Issue。
评估
调研方向
使用 Python 3.14.7 和 --enable-error-code exhaustive-match 运行提供的复现代码,然后跟踪 exhaustive-match 分析如何处理 match 语句中的 tuple[bool, bool]。当四种布尔情况被识别为完整匹配,且不报告 missing-return 或 unhandled-case 错误,同时真正不完整的匹配仍会报告错误时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
Bug Report
It looks like the exhaustiveness of tuples of bools is not checked in match statements.
To Reproduce
def measure(a: bool, b: bool) -> float:
match a, b:
case True, True:
return 1
case True, False:
return 0.9
case False, True:
return 0.5
case False, False:
return 0
Expected Behavior
Should pass, looks exhaustive to me (or I should go take a nap).
Actual Behavior
$ mypy --enable-error-code exhaustive-match repro.py
repro.py:1: error: Missing return statement [return]
repro.py:2: error: Match statement has unhandled case for values of type "tuple[bool, bool]" [exhaustive-match]
repro.py:2: note: If match statement is intended to be non-exhaustive, add `case _: pass`
Found 2 errors in 1 file (checked 1 source file)
Your Environment
- Mypy version used: mypy 2.3.1 (compiled: yes)
- Mypy command-line flags:
--enable-error-code exhaustive-match - Mypy configuration options from
mypy.ini(and other config files): ø - Python version used: 3.14.7
- 主要语言
- Python
- 星标
- 20.6k
- 派生
- 3.3k
- 平均合并
- 1 天 12 小时
- 30 天内合并 PR
- 58
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python/mypy 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
-
documentation
难度 2/5 1-3 小时 新手友好度 72/100
-
bug topic-configuration topic-error-reporting
难度 2/5 1-3 小时 新手友好度 68/100
-
bug topic-attrs
难度 2/5 1-3 小时 新手友好度 62/100
相似的 Issue
-
essnmx good first issue
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 2/5 1-3 小时 新手友好度 65/100
syfoud/Simulated_Scepter#174 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
Giskard-AI/giskard-oss#2840 · 1 条评论 ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success 未关闭area: repo bug perceived difficulty: 2
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
yeti-platform/yeti#1380 ·