Skip to content

chore: switch disallow_forward_slash_in_h5ad default to True#2436

Merged
flying-sheep merged 14 commits into
mainfrom
pa/write-slashes
May 15, 2026
Merged

chore: switch disallow_forward_slash_in_h5ad default to True#2436
flying-sheep merged 14 commits into
mainfrom
pa/write-slashes

Conversation

@flying-sheep

@flying-sheep flying-sheep commented May 12, 2026

Copy link
Copy Markdown
Member

OK, so this is broken:

if "/" in k.rsplit(store.name, maxsplit=1)[-1][1:]:

This fix changes the API in the following way:

  1. k="raw/var" is no longer legal. A quirk of the broken check allowed that before, but it should never have worked.
  2. k="" to write into the root is no longer legal, that should be "/"

the first one is definitely wanted, the second one used to work, but isn’t documented? Should I bring that back?

TODO:

  • I removed the store_type == "zarr" checks. I’m planning to bring them back.
  • Better error when people pass k="" or k="."
  • The current test failures are because setting disallow_forward_slash_in_h5ad=False and writing {obs,var}m results in unreadable anndata files. How should we deal with it? Disallow writing these even when it’s False?

  • Release note not necessary because:

@codecov

codecov Bot commented May 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.02326% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.70%. Comparing base (a7ba562) to head (6f4bc3b).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/anndata/_io/zarr.py 60.00% 2 Missing ⚠️
src/anndata/_io/specs/methods.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2436      +/-   ##
==========================================
+ Coverage   85.69%   85.70%   +0.01%     
==========================================
  Files          49       49              
  Lines        7793     7807      +14     
==========================================
+ Hits         6678     6691      +13     
- Misses       1115     1116       +1     
Files with missing lines Coverage Δ
src/anndata/_io/h5ad.py 93.23% <100.00%> (+0.06%) ⬆️
src/anndata/_io/specs/registry.py 94.85% <100.00%> (ø)
src/anndata/_io/utils.py 74.84% <100.00%> (+1.29%) ⬆️
src/anndata/_settings.py 92.59% <ø> (ø)
src/anndata/_types.py 100.00% <ø> (ø)
src/anndata/_io/specs/methods.py 91.39% <88.88%> (-0.15%) ⬇️
src/anndata/_io/zarr.py 81.44% <60.00%> (+0.39%) ⬆️

@flying-sheep flying-sheep changed the title feat: allow writing slashes chore: switch disallow_forward_slash_in_h5ad default to True May 12, 2026
@flying-sheep flying-sheep added this to the 0.13.0 milestone May 12, 2026
@flying-sheep
flying-sheep marked this pull request as ready for review May 12, 2026 15:31
@flying-sheep
flying-sheep requested a review from ilan-gold May 12, 2026 15:31

@ilan-gold ilan-gold left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rerequest once we have the prevention of writing mappings with forward slashes!

Comment thread docs/release-notes/2436.chore.md Outdated
@flying-sheep
flying-sheep requested a review from ilan-gold May 15, 2026 09:46
Comment thread src/anndata/_io/utils.py
Comment thread src/anndata/_io/specs/methods.py
Comment thread src/anndata/_io/h5ad.py
@flying-sheep
flying-sheep requested a review from ilan-gold May 15, 2026 10:24

@ilan-gold ilan-gold left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a bit of tinkering with _check_has_no_slash_key (#2436 (comment)) I have nothing cleaner. I think it's clear enough - maybe just a bit of pre-lunch confusion / hysteria.

Nice!

@flying-sheep

Copy link
Copy Markdown
Member Author

pre-lunch confusion / hysteria

I hope that dinners treat you better 😉

@flying-sheep
flying-sheep merged commit ef47eb8 into main May 15, 2026
30 checks passed
@flying-sheep
flying-sheep deleted the pa/write-slashes branch May 15, 2026 15:23
@ilan-gold ilan-gold modified the milestones: 0.13.0, 0.14.0 Jul 8, 2026
katosh added a commit to settylab/anndata that referenced this pull request Jul 9, 2026
…keys

Upstream switched the `disallow_forward_slash_in_h5ad` default to `True`
(scverse#2436), so a `/` in a key now aborts an h5ad write rather than emitting a
deprecation warning. `validate_key()` still hardcoded the old severity, which
made the repr advertise a slash key as merely deprecated while the
corresponding write raised `ValueError`.

Grade the key against the live setting instead of a constant, so the badge the
repr shows matches what a write would actually do, and keep the softer
"(deprecated)" wording for users who opt back out.

The branch carried a canary test asserting the old behaviour; replace it with
coverage of both settings states.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants