Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Exhaustiveness of type tuple[bool, bool]

未关闭
#21,968 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
python
领域
compilers

调研方向

使用 Python 3.14.7 和 --enable-error-code exhaustive-match 运行提供的复现代码,然后跟踪 exhaustive-match 分析如何处理 match 语句中的 tuple[bool, bool]。当四种布尔情况被识别为完整匹配,且不报告 missing-return 或 unhandled-case 错误,同时真正不完整的匹配仍会报告错误时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

bug topic-match-statement topic-reachability

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

python/mypy 的其他 Issue

查看 python/mypy 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。