Avatar for the python-attrs user
python-attrs
cattrs
BlogDocsChangelog

Performance History

Latest Results

Fix the cache_result parameter name in get_*_hook docstrings
main
4 days ago
Fix the cache_result parameter name in get_*_hook docstrings
mmporong:fix-hook-cache-result-docs
4 days ago
fix: carry over the fallback hook factories in Converter.copy() Problem ------- `BaseConverter.copy()` and `Converter.copy()` (and therefore `copy.deepcopy()`, which delegates to `copy()`) silently drop the converter's `unstructure_fallback_factory` and `structure_fallback_factory`. A copy of a converter configured with custom fallbacks falls back to the built-in defaults instead: unstructuring returns the object as is and structuring raises `StructureHandlerNotFoundError`. Every other constructor option - `dict_factory`, `unstruct_strat`, `omit_if_default`, `forbid_extra_keys`, `type_overrides`, `unstruct_collection_overrides`, `prefer_attrib_converters`, `detailed_validation` and `use_alias` - is carried over, and the fallback factories were simply never threaded through, so this is an oversight rather than a design decision. `Converter.copy` and `BaseConverter.copy` are also the documented way of cloning a converter ("Converters may be cloned using the `Converter.copy()` method", `docs/indepth.md`). Cause ----- `MultiStrategyDispatch` receives the fallback factory in its constructor, but `BaseConverter.__init__` never stored it on the converter, and `copy()` does not pass the factories to the new instance. The new converter therefore falls back to the defaults of the `__init__` signature. Fix --- Store both factories on the converter in `BaseConverter.__init__`, and add `unstructure_fallback_factory` and `structure_fallback_factory` parameters to `BaseConverter.copy` and `Converter.copy` that default to the current values, so they are both carried over and individually overridable on the copy. The new parameters are appended to the signatures, keeping existing positional calls valid. Tests ----- `tests/test_copy.py`: * `test_copy_fallback_factories` - custom fallbacks still apply after `copy()` and `deepcopy()`, for both `BaseConverter` and `Converter`. * `test_copy_fallback_factories_overrides` - the factories can be overridden on the copy without affecting the original. Both fail on `main` and pass with the fix; the rest of the suite is unaffected. Signed-off-by: simpleqt <2015900818@qq.com>
simpleqt:fix/copy-fallback-factories
11 days ago
Link the changelog entry to the pull request
digit50:fix/msgspec-recursive-hooks
11 days ago
Link the changelog entry to the pull request
digit50:fix/msgspec-recursive-hooks
11 days ago

Latest Branches

CodSpeed Performance Gauge
0%
Fix the cache_result parameter name in get_*_hook docstrings#815
5 days ago
5310648
mmporong:fix-hook-cache-result-docs
CodSpeed Performance Gauge
0%
fix: carry over the fallback hook factories in Converter.copy()#807
12 days ago
d5ace96
simpleqt:fix/copy-fallback-factories
CodSpeed Performance Gauge
+1%
13 days ago
e5487fe
tin/sentinels
© 2026 CodSpeed Technology
Home Terms Privacy Docs