The type specification of zip_broadcast is too narrow; it disallows zip_broadcast calls with iterables of different element types.
Looking at zip_broadcast's own example usage, if we run mypy 1.11.0 on
import more_itertools
iterable_1 = [1, 2, 3]
iterable_2 = ['a', 'b', 'c']
scalar = '_'
list(more_itertools.zip_broadcast(iterable_1, iterable_2, scalar))
list(more_itertools.zip_broadcast('abc', 0, 'xyz', scalar_types=None))
we get an output of
sample.py:6: error: Argument 1 to "zip_broadcast" has incompatible type "list[int]"; expected "str | Iterable[str]" [arg-type]
Found 1 error in 1 file (checked 1 source file)
Reviewing the discussion in 525, 526, and 556, it looks likely that if a bunch of @overloads were tossed into the .pyi content it would improve the common cases of just a few iterables, but that a robust solution may only come with variadic generics.
The type specification of
zip_broadcastis too narrow; it disallowszip_broadcastcalls with iterables of different element types.Looking at
zip_broadcast's own example usage, if we runmypy1.11.0onwe get an output of
Reviewing the discussion in 525, 526, and 556, it looks likely that if a bunch of
@overloads were tossed into the.pyicontent it would improve the common cases of just a few iterables, but that a robust solution may only come with variadic generics.