Skip to content

Conversation

@RayBB
Copy link
Collaborator

@RayBB RayBB commented Aug 2, 2025

Followup to #11003 (comment)

One of the things mentioned there was adding typed dicts. However, in some of the cases where I was trying I'd eventually run into the memoized functions that have no types.

I did a little research and learned that we can add typehints for memoized functions. And it turns out it works just fine to do so without much change.

The one change that is made here is removing the _cache = 'delete' option.
Basically, it's not possible to faithfully show the type of the function you're caching and allow for extra args.
Also, deleting manually is much better for separation of concerns. Besides, we only used that arg in a few places so it's not much to fix.

Technical

Testing

Screenshot

Stakeholders

@github-project-automation github-project-automation bot moved this to Waiting Review/Merge from Staff in Ray's Project Aug 2, 2025
Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

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

Niiiice! It'll be nice to have the typehints go through the caching layer! TIL, ParamSpec! That's a useful tool in the toolbelt! Not testing this one since it seems relatively low risk, and Ray's tested it locally.

@cdrini cdrini merged commit 65a423a into master Aug 13, 2025
8 checks passed
@cdrini cdrini deleted the typethints/memcache_memoize branch August 13, 2025 16:52
@github-project-automation github-project-automation bot moved this from Waiting Review/Merge from Staff to Done in Ray's Project Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants