Repository navigation
Don't import xarray to check isinstance, check if it's loaded instead - #12682
Merged
Merged
Conversation
Contributor
Unit Test ResultsSee test report for an extended history of previous test failures. This is useful for diagnosing flaky tests. 29 files ±0 29 suites ±0 6h 30m 41s ⏱️ - 9m 10s Results for commit df5db2a. ± Comparison against base commit 9c85cb7. ♻️ This comment has been updated with latest results. |
Contributor
Author
|
The remaining CI failures appear unrelated "pandas.errors.Pandas4Warning" |
crusaderky
self-requested a review
November 17, 2026 00:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dask.array.core imports xarray unconditionally, only to check if the object is an xarray. xarray is an expensive library that imports pandas, costing ~0.7-1 s, so this is a wasted startup cost to dask.array consumers not using xarray.
Instead of import, check if xarray is loaded, if it's not loaded then the object can safely be considered not an xarray object.
Recently implemented this in napari here: napari/napari#9780
and a similar pattern is used though out the scientific python ecosystem.
pixi run lint