Overlapping type
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 1.8k
- フォーク
- 302
- 平均マージ
- 23時間
- マージ済み PR(30日)
- 8
説明
This is an rough idea from the recent discussion of whether to use object/Any or _KT for arguments of certain methods like pop or __sub__. E.g.:
class MyPoppable[KT, VT]:
def pop(self, x: X) -> VT: ...
What should X be? Using KT (or KT | None) finds type errors like the following:
poppable: MyPoppable[str]
poppable.pop(123)
But has a problem with overlapping types:
def foo(x: int | str):
poppable.pop(x)
On the other hand, using object doesn't catch type errors like poppable.pop(123).
The solution would be able to specify that any partially overlapping type would be accepted:
class MyPoppable[KT, VT]:
def pop(self, x: Overlapping[KT]) -> VT: ...
MyPoppable[str]().pop() would accept str, str | None, Literal["x"], str | int, etc., but not e.g. plain int.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
issue にある重複する型の例から始め、そこから参照されている最近の議論を確認します。union、リテラル、重複しない型を含む、Overlapping 型の意図されたセマンティクスを定義します。動作と型付け規則について合意できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100