Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork366
chore/unformatted exceptions#3403
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
17 commits Select commitHold shift + click to select a range
9da7257 refactor errors
d-v-b733c1d2 make metadatavalidationerrors take a single argument
d-v-b8a7e0a4 create all errors with a single argument
d-v-b6917b11 move indexing-specific errors into the main errors module
d-v-b4d5baa5 ensure tests pass
d-v-b2936179 Merge branch 'main' of github.com:zarr-developers/zarr-python into ch…
d-v-bce4aa18 remove redundant template from array indexing exception
d-v-bf0300d1 add tests for single-argument templated exceptions
d-v-b593923f changelog
d-v-b0d122b9 Merge branch 'main' into chore/unformatted-exceptions
d-v-b288dd6a Merge branch 'main' into chore/unformatted-exceptions
d-v-b9ce2404 put the f on the f string
d-v-bec36c48 Update src/zarr/core/group.py
d-v-b840c037 Merge branch 'chore/unformatted-exceptions' of https://github.com/d-v…
d-v-be1fb28e Merge branch 'main' into chore/unformatted-exceptions
d-v-b970bcd8 fix test for specific error message
d-v-bfd6c3b2 Merge branch 'main' into chore/unformatted-exceptions
d-v-bFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
6 changes: 6 additions & 0 deletionschanges/3403.misc.rst
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| Moves some indexing-specific exceptions to ``zarr.errors``, and ensures that all Zarr-specific | ||
| exception classes accept a pre-formatted string as a single argument. This is a breaking change to | ||
| the following exceptions classes: :class:`zarr.errors.BoundsCheckError`, :class:`zarr.errors.NegativeStepError` | ||
| :class:`zarr.errors.VindexInvalidSelectionError`. These classes previously generated internally | ||
| formatted error messages when given a single argument. After this change, formatting of the error | ||
| message is up to the routine invoking the error. |
6 changes: 4 additions & 2 deletionssrc/zarr/api/asynchronous.py
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
3 changes: 2 additions & 1 deletionsrc/zarr/core/array.py
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
15 changes: 10 additions & 5 deletionssrc/zarr/core/group.py
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
68 changes: 37 additions & 31 deletionssrc/zarr/core/indexing.py
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
6 changes: 4 additions & 2 deletionssrc/zarr/core/metadata/v3.py
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
62 changes: 30 additions & 32 deletionssrc/zarr/errors.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,17 @@ | ||
| __all__ = [ | ||
| "ArrayIndexError", | ||
| "ArrayNotFoundError", | ||
| "BaseZarrError", | ||
| "BoundsCheckError", | ||
| "ContainsArrayAndGroupError", | ||
| "ContainsArrayError", | ||
| "ContainsGroupError", | ||
| "GroupNotFoundError", | ||
| "MetadataValidationError", | ||
| "NegativeStepError", | ||
| "NodeTypeValidationError", | ||
| "UnstableSpecificationWarning", | ||
| "VindexInvalidSelectionError", | ||
| "ZarrDeprecationWarning", | ||
| "ZarrFutureWarning", | ||
| "ZarrRuntimeWarning", | ||
| @@ -21,55 +23,41 @@ class BaseZarrError(ValueError): | ||
| Base error which all zarr errors are sub-classed from. | ||
| """ | ||
| _msg: str= "{}" | ||
| def __init__(self, *args: object) -> None: | ||
| """ | ||
| If a single argument is passed, treat it as a pre-formatted message. | ||
| If multiple arguments are passed, they are used as arguments for a template string class | ||
| variable. This behavior is deprecated. | ||
| """ | ||
| if len(args) == 1: | ||
| super().__init__(args[0]) | ||
| else: | ||
| super().__init__(self._msg.format(*args)) | ||
| class NodeNotFoundError(BaseZarrError, FileNotFoundError): | ||
| """ | ||
| Raised when a node (array or group) is not found at a certain path. | ||
| """ | ||
| class ArrayNotFoundError(NodeNotFoundError): | ||
| """ | ||
| Raised when an array isn't found at a certain path. | ||
| """ | ||
| _msg = "No array found in store {!r} at path {!r}" | ||
| class GroupNotFoundError(NodeNotFoundError): | ||
| """ | ||
| Raised when a group isn't found at a certain path. | ||
| """ | ||
| _msg = "No group found in store {!r} at path {!r}" | ||
| class ContainsGroupError(BaseZarrError): | ||
| @@ -106,8 +94,6 @@ class UnknownCodecError(BaseZarrError): | ||
| Raised when a unknown codec was used. | ||
| """ | ||
| class NodeTypeValidationError(MetadataValidationError): | ||
| """ | ||
| @@ -146,3 +132,15 @@ class ZarrRuntimeWarning(RuntimeWarning): | ||
| """ | ||
| A warning for dubious runtime behavior. | ||
| """ | ||
| class VindexInvalidSelectionError(IndexError): ... | ||
| class NegativeStepError(IndexError): ... | ||
| class BoundsCheckError(IndexError): ... | ||
| class ArrayIndexError(IndexError): ... | ||
maxrjones marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
14 changes: 11 additions & 3 deletionssrc/zarr/storage/_common.py
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
4 changes: 2 additions & 2 deletionstests/test_api.py
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
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.