Skip to content

fix: point two deprecation warnings at the calling code - #4612

Merged
maxrjones merged 2 commits into
zarr-developers:mainfrom
maxrjones:fix/deprecation-warning-attribution
Nov 9, 2026
Merged

maxrjones merged 2 commits into
zarr-developers:mainfrom
maxrjones:fix/deprecation-warning-attribution

Conversation

@maxrjones

Copy link
Copy Markdown
Member

Summary

I increased the stacklevel for a couple deprecation warnings because cached_property adds a stack level and we want the warnings to be visible.

For reviewers

I'm confident in these changes.

Author attestation

  • I am a human, these are my changes, and I have reviewed and understood every change and can explain why each is correct.

TODO

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/user-guide/*.md
  • Changes documented as a new file in changes/
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

Python shows a DeprecationWarning by default only when it is attributed
to __main__, so warnings that pointed at zarr internals were hidden
from users running scripts:

- `ArrayV2Metadata.chunk_grid` is a cached_property, which adds a frame;
  stacklevel 2 pointed at functools. Now 3.
- Setting `zarr.storage.default_compressor` used stacklevel 1, which
  pointed at zarr itself. Now 2.

Tests now assert the warning location. The deprecation policy in
docs/contributing.md explains why the location matters, and notes
that a warning raised inside a coroutine cannot reach the caller
through the synchronous API, so deprecations that must reach script
users should warn from the public synchronous function.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.90%. Comparing base (98aff7b) to head (ae9ae94).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4612      +/-   ##
==========================================
+ Coverage   94.88%   94.90%   +0.02%     
==========================================
  Files          96       96              
  Lines       14048    14048              
==========================================
+ Hits        13329    13332       +3     
+ Misses        719      716       -3     
Files with missing lines Coverage Δ
src/zarr/core/metadata/v2.py 92.30% <ø> (+1.64%) ⬆️
src/zarr/storage/__init__.py 96.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@maxrjones
maxrjones merged commit 27f034e into zarr-developers:main Nov 9, 2026
44 checks passed
@maxrjones
maxrjones deleted the fix/deprecation-warning-attribution branch November 9, 2026 17:36
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