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

ENH: make dask a hard requirement for unyt.dask_array #353

Merged

Conversation

neutrinoceros
Copy link
Member

@neutrinoceros neutrinoceros commented Jan 15, 2023

unyt.dask_array itself isn't loaded with import unyt so this doesn't make dask a hard dependency to the whole package, just the one module that is already unusable without it.

I find this simple change helps with boostrapping type-checking in unyt (see #296) because mypy is (rightfully) confused by conditional inheritance as is currently implemented in unyt_dask_array.

Namely, this resolves the following warnings from mypy

unyt/dask_array.py:194: error: Variable "unyt.dask_array._dask_Array" is not valid as a type  [valid-type]
unyt/dask_array.py:194: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
unyt/dask_array.py: note: In class "unyt_dask_array":
unyt/dask_array.py:194: error: Invalid base class "_dask_Array"  [misc]

unyt._on_demand_imports._dask continues to be useful in unyt_array.__array_ufunc__ so I'm not removing it.

@neutrinoceros neutrinoceros force-pushed the require_dask_for_unyt.dask_array branch from 47ac5f8 to 27c7e77 Compare January 15, 2023 12:00
@neutrinoceros neutrinoceros force-pushed the require_dask_for_unyt.dask_array branch from d398027 to 44a0a27 Compare January 15, 2023 12:38
@neutrinoceros neutrinoceros marked this pull request as ready for review January 15, 2023 12:42
Copy link
Contributor

@chrishavlin chrishavlin left a comment

Choose a reason for hiding this comment

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

simplifying the conditional import is great, but one question about the pytest import that you added (see comments).

unyt/dask_array.py Outdated Show resolved Hide resolved
@neutrinoceros neutrinoceros force-pushed the require_dask_for_unyt.dask_array branch from 9f299ac to a39dd45 Compare January 17, 2023 16:40
@neutrinoceros
Copy link
Member Author

Thank you for pointing this out @chrishavlin ! should be good now

Copy link
Contributor

@chrishavlin chrishavlin left a comment

Choose a reason for hiding this comment

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

Looks good!

@ngoldbaum ngoldbaum merged commit 44d0509 into yt-project:main Jan 17, 2023
@neutrinoceros neutrinoceros deleted the require_dask_for_unyt.dask_array branch January 18, 2023 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants