python / python/mypy

Callable with single argument accepts args expanding

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

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

bug
主要言語
Python
スター
20.6k
フォーク
3.3k
PR マージ指標
PR 指標を取得中

説明

Bug Report

(A clear and concise description of what the bug is.)

To Reproduce

from typing import Callable, TypeVar


T_ = TypeVar("T_")
P_ = TypeVar("P_")


def convert_to_hook(f: Callable[[P_], T_]) -> Callable[[list[P_]], T_]:

    def hook_f(args: list[P_]) -> T_:
        return f(*args)

    return hook_f

https://mypy-play.net/?mypy=latest&python=3.10&gist=e45c80cbb1e609c235b4da1813501cd5

Expected Behavior

The type check should fail and point to f(*args), because f is accepting only a single argument of type P_.

Actual Behavior

Success: no issues found in 1 source file

Your Environment

  • Mypy version used:
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used:

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

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

はじめの一歩

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

調査の方向性

報告された Python の再現コードから始め、リンクされた mypy-play の例またはローカルの mypy checkout で実行します。f(*args) 周辺の callable と引数展開の型チェックを追跡します。f は P_ 型の引数を 1 つしか受け取らないため、mypy が f(*args) でエラーを報告すれば完了です。

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

評価

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

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

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