Skip to content

fix(store): return None from LocalStore reads of a directory on Windows - #466

Draft
d-v-b wants to merge 2 commits into
test/store-contractfrom
fix/local-store-windows-dir-get
Draft

d-v-b wants to merge 2 commits into
test/store-contractfrom
fix/local-store-windows-dir-get

Conversation

@d-v-b

@d-v-b d-v-b commented Nov 18, 2026

Copy link
Copy Markdown
Owner

🤖 AI text below 🤖

On Windows, LocalStore.get, get_sync and get_partial_values now return None for a name that is a directory, as they already do on Linux and macOS, instead of raising PermissionError. A PermissionError on a file still raises, and get_partial_values now returns None for a missing key, as the Store interface documents.

Summary
  • src/zarr/storage/_local.py: a new _get_or_none helper returns None on FileNotFoundError, IsADirectoryError and NotADirectoryError. It also returns None on PermissionError, but only when path.is_dir(); otherwise it re-raises. get, get_sync and get_partial_values all call it. Before this, get_partial_values caught nothing, so a missing key raised FileNotFoundError. It now returns None, which matches the Store.get_partial_values docstring and MemoryStore.
  • getsize is unchanged. stat() on a directory succeeds on Windows too, so it never raises PermissionError. A separate ledger entry already records that it returns a number for a directory on every OS.
  • tests/test_store/test_stateful_conformance.py: local and latency-local are removed from the Windows-only entry "get() on a directory raises PermissionError". fsspec-local stays, because this fix doesn't touch fsspec. test_divergence_ledger_is_exact will fail on Windows if the entry is still needed, or if it is now wrong.
Tests
  • test_read_returns_none_for_a_name_without_a_file runs on every OS and skips nothing. It writes d/k, then reads d, missing and d/k/below through each of get, get_sync and get_partial_values, and expects None every time. The windows-error cases replace _get with a version that raises PermissionError for a directory, as Windows does, so the new branch also runs on Linux and macOS. When the agent removed the is_dir() check, exactly those three cases failed.
  • test_read_raises_permission_error_for_a_file checks that a PermissionError on a real file still reaches the caller.
  • test_filesystem_calls_are_observed now expects _get_or_none as the off-loop helper for get and get_partial_values.
  • Local runs on macOS: everything under tests/test_store/ passed, and so did pytest tests -k "local or partial or shard". Pre-commit (ruff, mypy, numpydoc) also passed.
  • macOS can't exercise the Windows path itself. Only Windows CI can confirm that open() on a directory raises PermissionError and that the ledger entry for local/latency-local is gone. CI is started with workflow_dispatch on this branch, because the Test workflow only runs on pull requests into main.
Stack

Stacked on test/store-contract (zarr-developers#4646), which adds the conformance state machine and the ledger entry this PR shrinks. Merge zarr-developers#4646 first, then retarget this PR to main.

🤖 Generated with Claude Code

d-v-b and others added 2 commits November 18, 2026 14:46
Windows raises PermissionError when it opens a directory as a file, so
LocalStore.get, get_sync and get_partial_values raised instead of
returning None. A shared reader now treats PermissionError as a missing
key only when the path is a directory, so real permission errors still
raise. get_partial_values also returns None for missing keys, as the
Store ABC documents.

Drop local and latency-local from the Windows-only PermissionError
entry in the conformance ledger; fsspec-local stays.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
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.

1 participant