python / python/cpython

Support `typing.get_type_hints(partial(fn, ...))` by 'unwrapping' the `partial`, and discarding hints for bound arguments

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

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

stdlib topic-typing type-feature
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

We added this to Hypothesis' get_type_hints() helper a few years ago, and while most of that function is clearly not suitable to upstream, it struck me recently that "works with functools.partial" could quite reasonably be added to the stdlib function.

It's also plausible that the typing module prefers to avoid calling inspect.signature, though I don't have a great sense of how to determine which parameters have been bound without getting the signature of the partial object. In any case, the implementation need not be the same as in Hypothesis, although as the author you're welcome to use that code if you'd like.

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

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

はじめの一歩

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

調査の方向性

まず、既存の typing.get_type_hints の実装と、hypothesis-python/src/hypothesis/internal/compat.py で参照されている Hypothesis ヘルパーを読んでください。functools.partial と inspect.signature が束縛された引数をどのように公開するかを確認し、partial がアンラップされ、束縛された引数の型ヒントが破棄されることを示すテストを定義してください。既存の get_type_hints のケースを壊さずに、この動作がカバーされていれば完了です。

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

評価

技術スタック
python
領域
devtools
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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