Making functions/methods subscriptable
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 1.8k
- フォーク
- 302
- 平均マージ
- 23時間
- マージ済み PR(30日)
- 8
説明
I'd like to make both instances and the types of functions and methods (including builtin methods) subscriptable.
Part of this proposal has been discussed already on python-ideas (https://discuss.python.org/t/making-functions-subscriptable-at-runtime/26463) but I thought it might also be worthwhile making FunctionType etc. subscriptable and work in a similar way to Callable just with extra descriptor behaviour that binds it into a MethodType.
class Foo:
bar: FunctionType[[Self, int], str]
# equivalent to
def bar(self, arg1, /) -> str: ...
This is different from Callable as if FunctionType was replaced with Callable, bar would always require a self argument.
This unfortunately probably requires special casing in type checkers as it isn't quite currently possible with PEP 612 (ParamSpec + Concatenate) (see #946) unless the PEP is updated
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まずリンクされている python-ideas の議論を読み、次に PEP 612 と issue #946 を確認して、示されている制限を理解してください。この提案には、subscriptable な FunctionType と関連する型、descriptor binding、およびおそらく type-checker の特別扱いが含まれます。完了には、合意された設計と、それに対応する type-checker のサポートが必要です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- developer-experience
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100