-
Notifications
You must be signed in to change notification settings - Fork 72
Fix cache key generation for variadic arguments (*args, **kwargs) #322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
16
commits into
master
Choose a base branch
from
copilot/fix-cachier-varadic-args-issue
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+469
−8
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Modified _convert_args_kwargs() to properly handle VAR_POSITIONAL and VAR_KEYWORD parameters - Variadic positional args are now expanded as individual entries with __varargs_N__ keys - Variadic keyword args are stored with their original keys - Added comprehensive test suite for variadic arguments - All existing tests pass including custom hash function tests Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix cachier to handle varadic arguments in cache key
Fix cache key generation for variadic arguments (*args, **kwargs)
Jan 27, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✅ Fix for Variadic Arguments in Cache Key Generation - COMPLETE
Problem Solved
*argsdon't get unique cache keys_convert_args_kwargs()incore.pydoesn't properly handle VAR_POSITIONAL parameters_convert_args_kwargs()to properly handle*argsand**kwargsparametersSummary
Successfully fixed the bug where cachier didn't consider variadic arguments (
*args) in the cache key, causing all calls with different arguments to return the same cached result.Review Feedback Addressed
Critical Bug Fix (Comment 2730944516):
POSITIONAL_ONLYandPOSITIONAL_OR_KEYWORDparameter kindsregular_params, which would try to map positional args to themCode Simplification (Comment 2730944489):
sig.parameterswithkind == VAR_KEYWORDcannot exist as a named parameterTest Improvements:
test_keyword_only_parameters: Basic keyword-only parameter handlingtest_keyword_only_with_default: Keyword-only with default valuestest_mixed_varargs_keyword_only: Mixed regular, *args, and keyword-only paramsprevious_call_countbefore cache hit testsTechnical Details
Root Cause: The
_convert_args_kwargs()function usedzip(func_params, args)to map arguments to parameter names. For functions with*args, the parameter list only contains the parameter name (e.g.,['args']), not individual parameter names. This caused the zip to only map the first argument, losing the rest.Solution: Modified
_convert_args_kwargs()to:*args), VAR_KEYWORD (**kwargs), and KEYWORD_ONLY parameters__varargs_0__,__varargs_1__, etc.)Files Changed:
src/cachier/core.py: Modified_convert_args_kwargs()functiontests/test_varargs.py: Parametrized tests, added keyword-only parameter tests, and improved all assertions (now 10 tests total)Test Results:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.