Skip to content

fix: auto-open ZipStore in list(), list_dir() and exists()#3855

Open
nuglifeleoji wants to merge 1 commit intozarr-developers:mainfrom
nuglifeleoji:fix/zipstore-list-auto-open
Open

fix: auto-open ZipStore in list(), list_dir() and exists()#3855
nuglifeleoji wants to merge 1 commit intozarr-developers:mainfrom
nuglifeleoji:fix/zipstore-list-auto-open

Conversation

@nuglifeleoji
Copy link
Copy Markdown
Contributor

Currently ZipStore._get() and ._set() guard against the store not being open:

if not self._is_open:
    self._sync_open()

But list(), list_dir(), and exists() access self._zf directly and crash with an AttributeError when called before open() (see #3846).

This PR applies the same auto-open pattern to those three methods so all store operations behave consistently.

A regression test in test_zip.py covers the three methods being called on an unopened store.

Closes #3846

Made with Cursor

ZipStore._get() and ._set() already auto-open the zip file when
called without a prior open(). Apply the same pattern to list(),
list_dir(), and exists() so that all store methods behave consistently
when the store has not been explicitly opened.

Closes zarr-developers#3846

Made-with: Cursor
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.90%. Comparing base (c9b534a) to head (e23cde0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3855   +/-   ##
=======================================
  Coverage   92.89%   92.90%           
=======================================
  Files          86       86           
  Lines       10689    10695    +6     
=======================================
+ Hits         9930     9936    +6     
  Misses        759      759           
Files with missing lines Coverage Δ
src/zarr/storage/_zip.py 97.68% <100.00%> (+0.08%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

ZipStore.list() fails if store not opened + lack of high-level listing API

1 participant