Repository navigation
feat(api): declare mode and data on create - #4455
Merged
Merged
Conversation
`create` accepted `mode` and `data` only through `**kwargs`: `mode` was popped for opening the store and `data` reached `AsyncArray._create`. Both are now named, documented parameters of the sync and async `create`, and `**kwargs` is gone, so an unknown keyword raises a TypeError from `create` itself. Assisted-by: ClaudeCode:claude-opus-5-5
Assisted-by: ClaudeCode:claude-opus-5-5
d-v-b
marked this pull request as ready for review
September 30, 2026 16:22
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4455 +/- ##
=======================================
Coverage 94.46% 94.46%
=======================================
Files 93 93
Lines 13234 13233 -1
=======================================
Hits 12501 12501
+ Misses 733 732 -1
🚀 New features to boost your workflow:
|
…vior Adversarial review of zarr-developers#4455 found the new docstrings overpromised: `data` is not `array[...] = data` for a zarr Array, `'r'` does not always open the store read-only, and the `mode`/`overwrite` interaction was undocumented. `mode` is now documented as the legacy spelling with `overwrite` preferred, each mode's outcome is stated, and `data` points to `create_array(data=...)`. The tests now cover the async `create`, the default mode, the `mode`/`overwrite` combinations, that `'w'` removes old chunks and stray keys, invalid modes, and that an unknown keyword leaves the store untouched. The fragment moves to misc. Assisted-by: ClaudeCode:claude-opus-5-5
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.
This PR makes
zarr.createandzarr.api.asynchronous.createhave accurate signatures and docstrings. part of **kwargs removal.🤖 AI text below 🤖
zarr.createandzarr.api.asynchronous.createnow listmodeanddatain their signatures and docstrings. Both were accepted before without being declared. An unknown keyword now raises aTypeErrorfromcreatebefore anything in the store is touched. Previously, withmode="w", the existing data was deleted before the error was raised.modeis documented as a legacy spelling;overwriteis preferred.This is the first step of replacing
**kwargsin the array-creation helpers (empty,zeros,ones,full, the*_likefunctions andopen_array) with explicit parameters. Before this change,createpassed**kwargson toAsyncArray._create, and the only extra names that function accepted weremode(whichcreatepopped out ofkwargs) anddata. The docs still rely onmode(zarr.zeros(..., mode='w')indocs/user-guide/experimental.md), so it stays, documented as legacy.datais documented with a pointer tocreate_array(data=...), whosedatasets the shape and data type, unlikecreate's.overwrite:'w'replaces even withoverwrite=False, and'w-'fails even withoverwrite=True.mode,overwrite, an existing array anddata, for both the sync and asynccreate. It compares the stored keys with a fresh store, so it fails if old chunks or unrelated keys survive a replacement. There is one test per error case: an existing array without overwrite (default mode,'a','r+'),'w-'over existing data,'r', an invalid mode, and an unknown keyword (sync and async, store left untouched).TypeErrorfor an unknown keyword comes from and that it is raised beforemode="w"deletes anything.modeannotated as plainstr, asopenandopen_arrayalready do.Notes
modehas no effect whenstoreis aStorePath, becausemake_store_pathreturns it unchanged. The group helpers (Group.zerosetc.) pass aStorePath, somodedoes nothing there. The docstring says so. Changing that is out of scope.modeincreate, not only its text: it derivesoverwritefrommode, so'w'would take effect for aStorePathtoo. Whichever PR merges second must update the docstring sentence aboutStorePath. The per-mode outcomes are written to hold on both sides.zarr.create(..., data=<zarr Array>)raisesSyncError(the docstring now says a Zarr array is not supported), and assigning a longer 1-D value into an array silently truncates (being investigated separately).empty/zeros/ones/fulland the group helpers (after fix(group): create group helper arrays in the group's zarr format #4412), for the*_likefunctions, and foropen_array/open_like(after fix(api): apply config when open_array opens an existing array #4408 and fix(api): validate a new node before deleting the existing one #4410).🤖 Generated with Claude Code