Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add T_DuckArray type hint to Variable.data #8203

Merged
merged 22 commits into from
Sep 19, 2023
Merged

Conversation

Illviljan
Copy link
Contributor

@Illviljan Illviljan commented Sep 18, 2023

The typing of Variable.data has been the very wide Variable.data: Any because of the difficulties defining the typing of a duckarray.

This has led to confusion in downstream functions that uses .data. Sometimes arguments uses Any, np.typing.ArrayLike, np.ndarray or dask array typing which is unnecessarily narrow when xarray also supports for example sparse arrays or cupy arrays.

This PR is a start at cleaning this up by defining a T_DuckArray typevar that symbolizes an array api compliant array.

@kmuehlbauer kmuehlbauer marked this pull request as ready for review September 18, 2023 18:57
@kmuehlbauer
Copy link
Contributor

This is really annoying. Sorry for marking this @Illviljan, somehow the GitHub App does thing's without intention.

@Illviljan Illviljan marked this pull request as draft September 18, 2023 19:08
@Illviljan Illviljan changed the title Add T_DuckArray type hint Add T_DuckArray type hint to Variable.data Sep 18, 2023
@Illviljan Illviljan marked this pull request as ready for review September 18, 2023 20:47
@Illviljan
Copy link
Contributor Author

Yay, green mypy!
I'm stopping here before I accidentally open another can of worms.

Some solutions are taken from #8075.

Copy link
Collaborator

@max-sixty max-sixty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

I can add into #8198 when this merges

@Illviljan Illviljan added the plan to merge Final call for comments label Sep 19, 2023
@dcherian dcherian merged commit 2b444af into pydata:main Sep 19, 2023
24 checks passed
@dcherian
Copy link
Contributor

Merging quickly to unblock anderson

@Illviljan Illviljan deleted the duckarray branch September 19, 2023 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plan to merge Final call for comments topic-typing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants