Skip to content

fix: hash on unspecified keyword values#8127

Merged
mscolnick merged 4 commits intomainfrom
dm/cache-kwarg-invalid
Feb 5, 2026
Merged

fix: hash on unspecified keyword values#8127
mscolnick merged 4 commits intomainfrom
dm/cache-kwarg-invalid

Conversation

@dmadisetti
Copy link
Collaborator

📝 Summary

closes #7977

Fixes issue in calculating mo.cache values. Although we tracked kwargs passed in, we didn't track the default kwargs. This PR injects default kwargs into hashed scope.

@vercel
Copy link

vercel bot commented Feb 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Feb 5, 2026 6:14am

Request Review

@dmadisetti dmadisetti added the bug Something isn't working label Feb 5, 2026
@mscolnick mscolnick requested a review from Copilot February 5, 2026 02:31
mscolnick
mscolnick previously approved these changes Feb 5, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes issue #7977 where mo.cache was not invalidating when default argument values changed, leading to stale cached results. The fix ensures that default argument values are included in the cache hash computation.

Changes:

  • Modified _cache_call class to track default argument values and keyword-only arguments
  • Updated cache hashing logic to include default values when arguments are not explicitly provided
  • Added comprehensive tests covering various function signature forms and edge cases

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
marimo/_save/save.py Added tracking of default argument values and keyword-only parameters; modified _prepare_call_execution to inject defaults into the hash scope
tests/_save/test_hash.py Added three new test methods covering default argument cache invalidation, explicit arguments matching previous defaults, and various function signature forms
tests/_save/test_cache.py Updated test_shadowed_kwargs to reflect the corrected behavior where explicit arguments matching defaults result in cache hits

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mscolnick mscolnick merged commit 936761a into main Feb 5, 2026
42 of 45 checks passed
@mscolnick mscolnick deleted the dm/cache-kwarg-invalid branch February 5, 2026 15:58
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.19.8-dev33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mo.cache does not invalidate when default argument values change (leads to stale cached results)

2 participants