Raise a clearer error when open_dataset is given a list of paths - #11526
Open
NoiceHax wants to merge 2 commits into
Open
Raise a clearer error when open_dataset is given a list of paths#11526NoiceHax wants to merge 2 commits into
NoiceHax wants to merge 2 commits into
Conversation
Passing a list or tuple of paths to open_dataset failed with the generic "did not find a match in any of xarray's currently installed IO backends" message, which does not hint at the actual mistake. The check sits at the end of guess_engine, right after the existing FileNotFoundError check, so backends that do accept a sequence still get their chance to claim the input first. Co-authored-by: Claude <noreply@anthropic.com>
for more information, see https://pre-commit.ci
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.
Description
xr.open_dataset(["file1.nc", "file2.nc"])failed with "did not find a match in any of xarray's currently installed IO backends", which sends you off checking whether one of the files is corrupt or whether a dependency is missing. The real problem is that the argument is a list and the user wantsopen_mfdataset.guess_enginenow spots a list or tuple and says that:The check sits at the end of
guess_engine, next to the existingFileNotFoundErrorcheck and just before the genericValueError. Every backend still gets a chance to claim the input first, so a third party backend that does accept a sequence keeps working. Only the path that was already failing changes.Noice = "Noice"is added to the typos allowlist inpyproject.tomlso the whats-new byline passes pre-commit.Checklist
xr.open_dataset(list_of_paths)#6510whats-new.rstapi.rstAI Disclosure
Tools: Claude Code. The code and test were drafted with it, then I read the diff and ran the tests locally.