Whole file

Krukov/cashews

The author described this change as Fix decode dict in a key template #352. It counts as a record because the check below fails on the code as it stood at 2bea1f504 and passes on d4fa79bae, with nothing else changed between the two runs.

Fix saved2025-08-03
Sharing licenceMIT · LICENSE
Change size+8 5

What the code was meant to do, written into the code itself as a save note

Fix decode dict in a key template #352

The change

3737
3838 def _get_decoded_dict(format_value):
3939 def _decode_dict(value: dict) -> TemplateValue:
40- _kv = (k + ":" + format_value(v) for k, v in sorted(value.items()))
40+ _kv = (format_value(k) + ":" + format_value(v) for k, v in sorted(value.items()))
4141 return ":".join(_kv)
4242
4343 return _decode_dict
190190
191191 def default_format(template: KeyTemplate, **values) -> KeyOrTemplate:
192192 _template_context, rewrite = key_context.get()
193- values["@"] = _template_context
194- if rewrite:
195- _template_context = {**values, **_template_context}
193+ if _template_context:
194+ values["@"] = _template_context
195+ if rewrite:
196+ _template_context = {**values, **_template_context}
197+ else:
198+ _template_context = {**_template_context, **values}
196199 else:
197- _template_context = {**_template_context, **values}
200+ _template_context = values
198201 return default_formatter.format(template, **_template_context)
199202
200203

The check that tells the two apart

failpass·tests/test_key.py::test_cache_key_args_kwargs[args21-kwargs21-{@:get(context_value)}:{kwarg}-context:1:1]

Check file tests/test_key.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it2bea1f504fef763a7cbab8fb2a6c7f14d94015fc
Broken version dated2025-08-03
Modulecashews.formatter
Units changed_get_decoded_dict, default_format
Fingerprint28c0be47807339a7
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.