Uh oh!
There was an error while loading. Please reload this page.
Move Xarray custom exceptions into a new xarray.errors module - #10285
Open
benbovy wants to merge 3 commits into
Open
Move Xarray custom exceptions into a new xarray.errors module#10285benbovy wants to merge 3 commits into
xarray.errors module#10285benbovy wants to merge 3 commits into
Conversation
benbovy
commented
May 6, 2025
MemberAuthor
I think this is ready. The warning emitted in the doc build seems unrelated. All errors are still exposed in Xarray's root namespace for backward compatibility, although we might want to remove this at some point and only access them via |
dcherian
commented
May 6, 2025
Contributor
Looks like we need to update this PR to include |
dcherian
commented
May 8, 2025
Contributor
Seems good to me. @keewis do you have any ideas for handling the deprecation cycle here? |
Collaborator
You could use a module level importwarningsdef__getattr__(attr):
moved_errors= (
"MergeError",
)
importxarray.errorsifattrinmoved_errors:
warnings.warn(f"Please import {attr} from xarray.errors", FutureWarning)
# NOTE: could maybe use importlib.import_module() but it registers the function # in sys.modules such that the warning is only called oncereturngetattr(xarray.errors, attr)
# required for ipython tab completionraiseAttributeError(f"module {__name__!r} has no attribute {attr!r}") |
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 freeto 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.
A bit cleaner, especially when displayed in error tracebacks.