enumerate(Union[Sequence, Sequence])
オープン
まだ誰も着手していません。
feature
needs discussion
topic-join-v-union
topic-type-variables
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
- Are you reporting a bug, or opening a feature request?
Bug - Please insert below the code you are checking with mypy.
from typing import Sequence, Union
def baz(idx: int, arg: Union[int, str]) -> None:
pass
def foo(the_list: Union[Sequence[int], Sequence[str]]) -> None:
for idx, val in enumerate(the_list):
reveal_type(idx)
reveal_type(val)
baz(idx, val)
- What is the actual behavior/output?
foo.py:8: note: Revealed type is 'builtins.int'
foo.py:9: note: Revealed type is 'builtins.object*'
foo.py:10: error: Argument 2 to "baz" has incompatible type "object"; expected "Union[int, str]"
- What is the behavior/output you expect?
foo.py:8: note: Revealed type is 'builtins.int'
foo.py:9: note: Revealed type is 'Union[int, str]'
- What are the versions of mypy and Python you are using?
Do you see the same issue after installing mypy from Git master?
0.761, 0.770 and master all have the same result. - What are the mypy flags you are using? (For example --strict-optional)
--strict
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
foo.py の例を mypy と報告されている --strict フラグで再現し、その後、シーケンスの Union に対する enumerate の型推論パスを調べます。reveal_type(val) が Union[int, str] を報告し、関連しないチェックを弱めることなく baz の呼び出しが受け入れられれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100