dask / dask/dask

Add static type annotations

Open
#11,047 12 comments 0 reactions 0 assignees View on GitHub
good first issue
Dominant language
Python
Stars
13.9k
Forks
2k
PR merge metrics
No merged PRs in 30d

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](https://github.com/dask/dask/assets/38672686/009bf48b-2897-40b2-ab23-bc035f0304da)

```py
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.