Skip to content

fix(backends): count a 0.3.x None from delete() as removed, with a FutureWarning - #428

Merged
allen0099 merged 3 commits into
masterfrom
fix/71-delete-none-compat
Oct 2, 2026
Merged

allen0099 merged 3 commits into
masterfrom
fix/71-delete-none-compat

Conversation

@allen0099

Copy link
Copy Markdown
Owner

Follow-up to #427 (#71).

#427 made delete() return whether a key was removed, and the non-atomic fallbacks (delete_many, get_and_delete, delete_if_equals) now use that result. A third-party backend written for 0.3.x still returns None, which those fallbacks would have read as "not removed": get_and_delete would return None after deleting the entry, delete_if_equals would report failure, and delete_many would count 0.

This change routes the fallbacks through _delete_reporting, which counts None as removed, as every fallback assumed in 0.3.x, and emits a FutureWarning naming the backend class and linking the migration guide. FutureWarning rather than DeprecationWarning because the warning is raised inside the package, where a DeprecationWarning is hidden by default, and the behaviour change in 0.5.0 (treating None as False) affects the application at runtime.

  • tests/backends/test_base.py: a legacy backend whose delete() returns None, checked against all three fallbacks (result and warning).
  • Changelog fragment and migration guide (EN + zh-TW) updated.

An independent review agent read the change before this PR; its finding (warning class) is applied in the second commit.

Refs #71

…rning

The #71 fallbacks treated a None result as "not removed", so a backend
written against 0.3.x lost every get_and_delete() and delete_if_equals()
race against itself after deleting the key. None now keeps the 0.3.x
meaning and emits a DeprecationWarning; 0.5.0 treats it as False.
@allen0099 allen0099 added this to the 0.4.0 milestone Oct 2, 2026
@allen0099 allen0099 added bug Something isn't working backends Cache backends and their atomic primitives labels Oct 2, 2026
@allen0099
allen0099 merged commit f5daf65 into master Oct 2, 2026
13 checks passed
@allen0099
allen0099 deleted the fix/71-delete-none-compat branch October 2, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backends Cache backends and their atomic primitives bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant