dask/dask

Add static type annotations

Open

#11,047 opened on Apr 11, 2024

View on GitHub
 (8 comments) (0 reactions) (0 assignees)Python (11,520 stars) (1,658 forks)batch import
good first issue

Description

I am having trouble with using Dask in a project that uses PyRight because Dask does not use static type annotations/

Take, da.from_array, for example: https://github.com/dask/dask/blob/b2ec1e1a2361db1e269ba86c7c59d3f6df70a02d/dask/array/core.py#L3307-L3317

Or array.rechunk: https://github.com/dask/dask/blob/b2ec1e1a2361db1e269ba86c7c59d3f6df70a02d/dask/array/rechunk.py#L268-L275

PyRight complains if you use anything but a str for chunks:

image

Argument of type "tuple[Literal[1], Literal[-1], Literal[-1]]" cannot be assigned to parameter "chunks" of type "str" in function "from_array"
  "tuple[Literal[1], Literal[-1], Literal[-1]]" is incompatible with "str"

This happens because in from_array and rechunk, chunks="auto" infers to a str type.

Is there an awareness of this problem? Is there a known solution? If not, is there a plan to fix this?

Contributor guide