Unpacking unions of tuples skips type checking
オープン
まだ誰も着手していません。
bug
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Bug Report
mypy applies type checks when passing an unpacked tuple to a function, but it seems to skip the checks when passing a variable that is a union of tuple types.
To Reproduce
def inner(_name: str, _num: int) -> None:
...
# mypy passes as expected
def fun1(name_and_num: tuple[str, int]) -> None:
inner(*name_and_num)
# mypy errors as expected
def fun2(name_and_num: tuple[str, float]) -> None:
inner(*name_and_num)
# mypy passes *but should error*
def fun3(name_and_num: tuple[str, int] | tuple[str, float]) -> None:
inner(*name_and_num)
https://gist.github.com/mypy-play/257f0a56dd44b405b2853e2854333cc2
Expected Behavior
arg-type error on line 14
Actual Behavior
No error on line 14
Your Environment
- Mypy version used: 1.5.1
- Python version used: 3.11.5
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、mypy 1.5.1 を使い、Python 3.11.5 上で、提供されている fun1、fun2、fun3 の例を用いて動作を再現します。アンパックされた union-of-tuples の型チェック経路を追跡し、fun3 の呼び出しで 14 行目に期待される arg-type エラーが報告されることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 45/100