Support exhaustiveness checking of single enumerable properties
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Feature
Support exhaustiveness checking of single boolean and enum properties and attributes of objects.
Pitch
The proposal is to improve exhaustiveness checking by supporting properties/attributes on a matched object. While it would be amazing to have infinitely nested support for this, I think we can recognize that there is value in supporting just single-level enumerable attributes.
In this example mypy isn't currently recognizing that all possible variations of Foo are handled, and gives an error on the assert_never().
from typing import assert_never
class Sentinel: ...
class Foo:
prop: bool
val: Foo | Sentinel
match val:
case Sentinel():
...
case Foo(prop=True):
...
case Foo(prop=False):
...
case no_match:
assert_never(no_match) # Currently a false positive here, no_match should be <nothing>.
https://mypy-play.net/?mypy=latest&python=3.11&gist=1edcb8f3ea56334662ed2036404563a1
Likewise, if the feature is accepted, we should expect an unreachable error for the third case in this example.
from typing import assert_never
class Foo:
prop: bool
val: Foo
match val:
case Foo(prop=True):
...
case Foo(prop=False):
...
case Foo():
... # Currently a false negative here, should be unreachable.
https://mypy-play.net/?mypy=latest&python=3.11&gist=74b23b6868c0c52056be1ade612b3052
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
2つの Python の match の例と、それらにリンクされた mypy-play の再現コードから始めます。単一レベルのブール型プロパティおよび enum 型プロパティについて、網羅性と到達不能なケースの動作を定義し、その後、issue に記載された false-positive と false-negative の結果が修正されていることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100