python / python/typeshed

[Typing] `batched` revealed type?

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

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

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

説明

Bug report

Bug description:

Hi!

Consider the following.

from functools import reduce
from itertools import batched

x = reduce(batched, [1], (1,))

It makes mypy unhappy!

error: Argument 1 to "reduce" has incompatible type "type[batched[Any]]"; expected "Callable[[tuple[int], int], tuple[int]]"  [arg-type]

I did try to previously type hint the tuple with

the_tuple: tuple[int, ...] = (1,)

But the error remains the same.

It may be that I'm not understanding something elementary in which case, thanks for the help! Otherwise, is this a problem of batched or something deeper?

Thanks!

CPython versions tested on:

3.13

Operating systems tested on:

Linux

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

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

はじめの一歩

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

調査の方向性

報告ではファイルパスもテストパスも指定されていません。まず itertools.batched の typeshed スタブと reduce の型付けを調べ、次に Python 3.13 の例で提示された mypy エラーを再現してください。意図された動作が解決され、適切な typeshed チェックでカバーされていれば完了です。

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

評価

技術スタック
python
領域
developer-experience
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

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

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