[Typing] `batched` revealed type?
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 2.1k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 82
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file or test path is named in the report. Start by examining the typeshed stub for itertools.batched and the typing of reduce, then reproduce the supplied mypy error with the Python 3.13 example. Done means the intended behavior is resolved and covered by a suitable typeshed check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100