TypeVarTuple with Callable and default arguments
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 1.8k
- フォーク
- 302
- 平均マージ
- 23時間
- マージ済み PR(30日)
- 8
説明
Previous discussion: https://github.com/microsoft/pyright/issues/3775
I've been playing around with TypeVarTuples recently, in particular together with Callable and args.
https://peps.python.org/pep-0646/#type-variable-tuples-with-callable
One issue became obvious early on which isn't defined in the PEP itself.
How should default arguments be handled?
A common pattern, especially in async code, is to pass a callable and it's args to a function
from typing import Callable
from typing_extensions import TypeVarTuple
Ts = TypeVarTuple("Ts")
def call_later(cb: Callable[[*Ts], None], *args: *Ts) -> None: ...
That works well if all arguments are required
def func1(x: int, y: int, z: int) -> None: ...
call_later(func1, 0, 0, 0) # ok
However, what should happen if y and z have default arguments?
def func2(x: int, y: int = 0, z: int = 0) -> None: ...
call_later(func2, 0)
Instinctively, I would think that it should work, too. As @erictraut did point out though, there are at least a few cases where the behavior would need to be further specified / or explicitly forbidden.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず issue 3775 の以前の議論と、Callable を使用した TypeVarTuples に関する PEP 646 のセクションを読んでください。必須引数とデフォルト引数の例、および議論で提起されたエッジケースを比較し、デフォルト引数について仕様で定める、または明示的に禁止する動作を確立してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- tooling
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100