Skip to content

Conversation

@d-v-b
Copy link
Contributor

@d-v-b d-v-b commented Jan 8, 2026

This PR builds on #3638 to add routines to the store ABC, and thereby all other stores, for handling additional types for the prototype parameter passed to store.get and the methods that call get. This change makes it easier to use store methods without unnecessary imports.

The type of prototype is widened to type[Buffer] | BufferPrototype | None. type[Buffer] | BufferPrototype is compacted to the type alias BufferLike.

When prototype is type[Buffer], the store will use that class directly. Since the stores never use the BufferPrototype.nd_buffer, passing a Buffer class should be preferred over using BufferPrototype.

When prototype is None, the store class retrieves a Buffer class by calling its _get_default_buffer_class method. The default implementation returns the default_buffer_prototype which makes our ABC less abstract but keeps these changes non-breaking.

@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

❌ Patch coverage is 60.89744% with 61 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.99%. Comparing base (1c05c1a) to head (6bba68f).

Files with missing lines Patch % Lines
src/zarr/storage/_fsspec.py 0.00% 17 Missing ⚠️
src/zarr/abc/store.py 42.85% 12 Missing ⚠️
src/zarr/testing/store.py 69.69% 10 Missing ⚠️
src/zarr/storage/_local.py 75.00% 7 Missing ⚠️
src/zarr/storage/_memory.py 70.83% 7 Missing ⚠️
src/zarr/storage/_common.py 25.00% 3 Missing ⚠️
src/zarr/storage/_obstore.py 81.25% 3 Missing ⚠️
src/zarr/storage/_logging.py 0.00% 1 Missing ⚠️
src/zarr/storage/_wrapper.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3644      +/-   ##
==========================================
+ Coverage   60.89%   60.99%   +0.10%     
==========================================
  Files          86       86              
  Lines       10182    10293     +111     
==========================================
+ Hits         6200     6278      +78     
- Misses       3982     4015      +33     
Files with missing lines Coverage Δ
src/zarr/experimental/cache_store.py 100.00% <100.00%> (ø)
src/zarr/storage/_zip.py 72.98% <100.00%> (+1.13%) ⬆️
src/zarr/storage/_logging.py 61.94% <0.00%> (ø)
src/zarr/storage/_wrapper.py 43.58% <0.00%> (ø)
src/zarr/storage/_common.py 66.00% <25.00%> (ø)
src/zarr/storage/_obstore.py 62.28% <81.25%> (+1.45%) ⬆️
src/zarr/storage/_local.py 72.10% <75.00%> (+1.51%) ⬆️
src/zarr/storage/_memory.py 61.34% <70.83%> (+4.90%) ⬆️
src/zarr/testing/store.py 74.92% <69.69%> (-0.08%) ⬇️
src/zarr/abc/store.py 37.73% <42.85%> (+0.85%) ⬆️
... and 1 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@d-v-b d-v-b marked this pull request as ready for review January 8, 2026 17:08
@d-v-b d-v-b requested a review from TomAugspurger January 9, 2026 09:16
@d-v-b d-v-b requested a review from normanrz January 16, 2026 09:43
@normanrz
Copy link
Member

@d-v-b Could you elaborate on the motivation for widening the Store API like this?

@d-v-b
Copy link
Contributor Author

d-v-b commented Jan 16, 2026

Stores don't do anything with NDBuffer classes. They just use a Buffer class. So prototype: BufferPrototype is indirect -- no store will use the BufferPrototype.nd_buffer element. That's why prototype can be a Buffer class in this PR.

And multiple stores have already implemented logic for selecting a default buffer class. The changes here propagate that sensible design to all store classes.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 16, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing d-v-b:feat/default-buffer (b205b35) with main (e94504e)

Summary

✅ 30 untouched benchmarks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants