Improve precision of itertools.product types when called with 7 or more arguments#11163
Conversation
|
Diff from mypy_primer, showing the effect of this PR on open source code: jax (https://github.com/google/jax)
+ jax/_src/scipy/ndimage.py:123: error: Argument 1 to "_nonempty_prod" has incompatible type "tuple[Array | Any | int | float | complex, ...]"; expected "Sequence[Array]" [arg-type]
|
|
While this is probably not a big deal, since a product of more than six iterables will rarely come up, this does mean that anything using more than that will now will most likely result in a My intuition initially was that mypy would reject mixing non-uniform iterables for the final overload, but since It's probably still a good trade-off to support the nested iterable case, since it is a more common use-case, just thought I'd mention it. |
Previously when the following expression would yield a type with
Any:but this is ok:
This PR attempts to fix that but do let me know if I've got anything wrong (I only did some local testing in
pyright)!EDIT: Fixed a typo
args: List[int]->args: List[List[int]]found by @hauntsaninja #11163 (review) , thanks!