Bad interaction between ParamSpec and TypeVarTuple
オープン
まだ誰も着手していません。
bug
topic-paramspec
topic-pep-646
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
This should type check, but
from typing import Callable, TypeVarTuple
def run[T, **P](fn: Callable[P, T], *args: P.args, **kwargs: P.kwargs) -> T: ...
def coroutine_or_error[*Us](async_fn: Callable[[*Us], int], *args: *Us) -> int: ...
def test[*Ts](async_fn: Callable[[*Ts], int], args: tuple[*Ts]) -> None:
run(coroutine_or_error, async_fn, *args)
https://mypy-play.net/?mypy=latest&python=3.12&gist=e43aee5d75dd536ed2529b3dc052e630 gives
Argument 1 to "run" has incompatible type "Callable[[Callable[[VarArg(*Us)], int], VarArg(*Us)], int]"; expected "Callable[[Callable[[VarArg(*Ts)], int], VarArg(object)], int]" [arg-type]
Example derived from https://github.com/python-trio/trio/blob/f1039299644dfaf6dcd60ed29a4a3a51494d09a4/src/trio/_core/_run.py#L1970
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされた mypy-play の例でスニペットを再現し、報告された ParamSpec と TypeVarTuple の診断を比較します。派生したユースケースを理解するため、参照されている Trio のエントリポイント src/trio/_core/_run.py#L1970 を読んでください。例が互換性のない Callable エラーなしで型チェックを通れば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100