Commit a683275
Fix cache key generation for variadic arguments (*args, **kwargs) (#322)
* Initial plan
* Fix: Handle variadic arguments (*args, **kwargs) in cache key generation
- 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
* Address PR review feedback: keyword-only params, parametrize tests, simplify code
- Fixed incorrect handling of keyword-only parameters (KEYWORD_ONLY should not be in regular_params)
- Simplified VAR_KEYWORD handling by removing unreachable else branch
- Parametrized first test to run on both pickle and memory backends
- Added 3 new tests for keyword-only parameter edge cases
- Fixed line length issues in docstrings and comments
* Improve test assertions to explicitly verify cache hits
- Changed assertions to capture previous call_count before testing cache hits
- Makes tests more explicit: verify count didn't increase rather than re-asserting same value
- Applied to test_varargs_different_cache_keys, test_varargs_empty, test_varkwargs_different_cache_keys, and test_varargs_and_varkwargs
* Simplify parameter handling in `map_arguments`
* Fix test assertion in test_varargs_memory_backend
- Changed assertion to capture previous_call_count before cache hit test
- Makes test explicit about verifying the count didn't increase
- Consistent with other test improvements in previous commit
* Refactor and parametrize varargs/varkwargs test cases for enhanced readability and backend coverage
* Remove redundant `@pytest.mark.pickle` annotations from varargs/varkwargs test cases
* [pre-commit.ci] auto fixes from pre-commit.com hooks
* Add comprehensive edge case tests for variadic arguments
- Added TestFunctoolsPartial: tests for functools.partial wrapped functions
- Added TestMethodWithVarargs: tests for functions simulating method behavior
- Added TestPositionalOnlyParams: tests for positional-only parameters (/) with varargs
- Added TestComplexParameterMix: tests for functions with all parameter types combined
- Added TestEdgeCasesEmptyAndNone: tests for None, empty strings, and zero values in varargs
- Total test count increased from 42 to 68 tests (26 new tests)
- All tests parametrized across pickle and memory backends for comprehensive coverage
* Simplify redundant conditional in _convert_args_kwargs
- Removed redundant if-else where both branches performed the same action
- Simplified kwds handling to always use kwargs.update(kwds)
- Removed unused var_keyword_name variable
- All 68 tests still pass
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>1 parent 425287d commit a683275
2 files changed
Lines changed: 711 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
86 | 125 | | |
87 | 126 | | |
88 | 127 | | |
| |||
0 commit comments