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

Performance History

Latest Results

Escape the index note when structuring heterogeneous tuples `make_hetero_tuple_structure_fn` builds the per-index note by interpolating `str(cl)` into a single-quoted string literal in the generated source, at `src/cattrs/gen/__init__.py` line 903 on main: `f"__c_ivn('Structuring {cl} @ index {ix}', {ix}, {type_name})]"`. When a type argument has a quote in its `repr`, such as `Literal["a"]`, the quote closes the literal early and compiling the hook raises `SyntaxError` before any data is looked at. This only affects the generated path, so `Converter()` fails where `BaseConverter()` and `Converter(detailed_validation=False)` succeed. `NamedTuple`s structure through the same factory, so they crash the same way. This is the same class of bug as #769 and #771, and the fix is the same shape already used in `src/cattrs/gen/typeddicts.py` line 394: build the note text in Python and embed it with `repr`. The note text is byte-identical to before, so nothing that reads `IterableValidationNote` changes. The test covers a quote from `Literal`, the same quote nested inside a `List`, an `Annotated` whose metadata repr contains both quote characters, and a `NamedTuple` field, then triggers a real validation failure and checks the note reads exactly as it does for a tuple whose arguments have no quotes. The expected note is built from the same type expression so the assertion does not depend on how a given Python version renders typing objects.
main
1 day ago
Escape the index note when structuring heterogeneous tuples `make_hetero_tuple_structure_fn` builds the per-index note by interpolating `str(cl)` into a single-quoted string literal in the generated source, at `src/cattrs/gen/__init__.py` line 903 on main: `f"__c_ivn('Structuring {cl} @ index {ix}', {ix}, {type_name})]"`. When a type argument has a quote in its `repr`, such as `Literal["a"]`, the quote closes the literal early and compiling the hook raises `SyntaxError` before any data is looked at. This only affects the generated path, so `Converter()` fails where `BaseConverter()` and `Converter(detailed_validation=False)` succeed. `NamedTuple`s structure through the same factory, so they crash the same way. This is the same class of bug as #769 and #771, and the fix is the same shape already used in `src/cattrs/gen/typeddicts.py` line 394: build the note text in Python and embed it with `repr`. The note text is byte-identical to before, so nothing that reads `IterableValidationNote` changes. The test covers a quote from `Literal`, the same quote nested inside a `List`, an `Annotated` whose metadata repr contains both quote characters, and a `NamedTuple` field, then triggers a real validation failure and checks the note reads exactly as it does for a tuple whose arguments have no quotes. The expected note is built from the same type expression so the assertion does not depend on how a given Python version renders typing objects.
MaxFreedomPollard:escape-hetero-tuple-note
2 days ago

Latest Branches

CodSpeed Performance Gauge
0%
Escape the index note when structuring heterogeneous tuples#777
2 days ago
9294bbd
MaxFreedomPollard:escape-hetero-tuple-note
CodSpeed Performance Gauge
0%
9 days ago
f0c5a80
MaxFreedomPollard:sort-forbidden-extra-keys
CodSpeed Performance Gauge
0%
14 days ago
739d17c
onk3sh:fix/naive-datetime-timestamps
© 2026 CodSpeed Technology
Home Terms Privacy Docs