python / python/typeshed

functools.partial should use PEP612 ParamSpec (depends on #8708)

オープン
#8,703 コメント 8 件 リアクション 7 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

status: deferred
主要言語
Python
スター
5.1k
フォーク
2.1k
平均マージ
1日 19時間
マージ済み PR(30日)
82

説明

Currently, functools.partial's __call__ method takes *args: Any, **kwargs: Any and returns _T (a TypeVar for the return type of the callable the partial is wrapping). This is decent, but matching the parameter typing would make this more useful in more situations.

I can sort of see how to deal with this, although I'll admit I'm unsure how to make this generically work. I imagine you could probably deal with some number of Concatenates (maybe up to 5 or 10) to deal with most cases. It's possible fixing this requires another PEP to allow an arbitrary-length Concatenate-type pattern.

Related to https://github.com/python/mypy/issues/1484

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

stdlib/functools.pyi の 75 行目付近から始め、PEP 612 の ParamSpec と Concatenate の概念を確認してください。要求された型付けを表現できるかどうかを判断する前に、issue #8708 と関連する mypy issue への依存関係を確認してください。完了の条件は、functools.partial の call が Any を使用するのではなく、ラップされた callable のパラメーターの型付けを維持することです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
tooling
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。