Check for return type of overload implementation is too strict?
オープン
まだ誰も着手していません。
false-positive
needs discussion
priority-1-normal
topic-overloads
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Consider this simplified example:
from typing import overload, Optional, List
@overload
def f(x: int) -> List[int]: ...
@overload
def f(x: None) -> List[Optional[int]]: ...
def f(x: Optional[int]) -> List[Optional[int]]:
return [x]
Mypy currently complains about it that:
Overloaded function implementation cannot produce return type of signature 1
Although I understand why this happens, it is a bit annoying and can be perceived as a false positive. Maybe we should use is_overlapping_types() instead of is_subtype() for the check?
cc @Michael0x2a
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、簡略化したオーバーロードの例を再現し、mypy における実装の戻り値型チェックを追跡します。現在の is_subtype() チェックと、提案されている is_overlapping_types() の動作を比較し、そのうえで例を受け入れるべきかどうかを判断し、リグレッションカバレッジでその判断を検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- compilers, devtools
- issue の種類
- バグ
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100