Skip to content

fix: raise TypeError from cache_clear() on async functions#51

Closed
27Bslash6 wants to merge 2 commits intomainfrom
fix/49-async-cache-clear
Closed

fix: raise TypeError from cache_clear() on async functions#51
27Bslash6 wants to merge 2 commits intomainfrom
fix/49-async-cache-clear

Conversation

@27Bslash6
Copy link
Contributor

Summary

  • cache_clear() on async-decorated functions called ainvalidate_cache() without awaiting, silently discarding the coroutine — cache was never cleared
  • Now raises TypeError directing users to await fn.ainvalidate_cache()
  • Added 4 unit tests covering async TypeError, error message content, sync regression guard, and async path validation

Test plan

  • test_cache_clear_raises_type_error_for_async_function — verifies TypeError is raised
  • test_cache_clear_error_message_suggests_ainvalidate — verifies error message
  • test_cache_clear_does_not_raise_for_sync_function — sync regression guard
  • test_async_ainvalidate_cache_still_works — async path still works
  • All pre-commit hooks pass (ruff lint, ruff format, basedpyright)

Closes #49

@codecov
Copy link

codecov bot commented Feb 22, 2026

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/cachekit/decorators/wrapper.py 0.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

- bytes 1.10.1 → 1.11.1 (RUSTSEC-2026-0007: integer overflow in BytesMut::reserve)
- filelock 3.20.1 → 3.24.3 (GHSA-qmgc-5h2g-mvrw: TOCTOU symlink vuln)
- orjson 3.11.4 → 3.11.7 (GHSA-hx9q-6w63-j58v: unbounded recursion)
- pip 25.3 → 26.0.1 (GHSA-6vgw-5pg2-w6jp: path traversal in wheel extraction)
- test_ttl_enforced: increase TTL 1s→3s to prevent CI timing flakiness
cache_clear() called ainvalidate_cache() without awaiting, silently
discarding the coroutine. The cache was never actually cleared.

Now raises TypeError directing users to await fn.ainvalidate_cache().

Closes #49
@27Bslash6 27Bslash6 force-pushed the fix/49-async-cache-clear branch from 3560cec to 16dca07 Compare February 22, 2026 02:44
@27Bslash6
Copy link
Contributor Author

Superseded by combined fix PR

@27Bslash6 27Bslash6 closed this Feb 22, 2026
@27Bslash6 27Bslash6 deleted the fix/49-async-cache-clear branch February 22, 2026 02:57
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.

cache_clear() broken for async-decorated functions

1 participant