Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: python-attrs/cattrs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: df4e4bb
Choose a base ref
...
head repository: python-attrs/cattrs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 995d66a
Choose a head ref
  • 3 commits
  • 5 files changed
  • 2 contributors

Commits on Sep 7, 2026

  1. Sort extra keys when formatting ForbiddenExtraKeysError (#776)

    `ForbiddenExtraKeysError.extra_fields` is a `set`, and `format_exception`
    in src/cattrs/v.py joined it directly, so `transform_error` put the extra
    keys in whatever order that set happened to iterate in. String hashing is
    randomized per process, so the message text changed from run to run once
    more than one extra key was present, which breaks anything that compares
    or snapshots the output of `transform_error`.
    
    `ForbiddenExtraKeysError.__str__` in src/cattrs/errors.py already sorts
    the same set, so the two renderings of one error disagreed as well.
    
    Sort the keys in `format_exception` too, and add a regression test with
    five extra keys, since the existing test only used one and could not
    observe the ordering.
    MaxFreedomPollard authored Sep 7, 2026
    Configuration menu
    Copy the full SHA
    bc34a46 View commit details
    Browse the repository at this point in the history

Commits on Sep 14, 2026

  1. 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 authored and Tinche committed Sep 14, 2026
    Configuration menu
    Copy the full SHA
    5bf7c97 View commit details
    Browse the repository at this point in the history

Commits on Sep 26, 2026

  1. v26.2.1

    Signed-off-by: Tin Tvrtkovic <[email protected]>
    Tinche committed Sep 26, 2026
    Configuration menu
    Copy the full SHA
    995d66a View commit details
    Browse the repository at this point in the history
Loading