Skip to content

fix: keep dedicated PEP 695 alias hooks in union passthrough spillover - #799

Open
Eryx-Z wants to merge 1 commit into
python-attrs:mainfrom
Eryx-Z:fix/passthrough-alias-dedicated-hooks
Open

Eryx-Z wants to merge 1 commit into
python-attrs:mainfrom
Eryx-Z:fix/passthrough-alias-dedicated-hooks

Conversation

@Eryx-Z

@Eryx-Z Eryx-Z commented Oct 16, 2026 •

Copy link
Copy Markdown

Changes

Fixes #797

configure_union_passthrough was unwrapping every PEP 695 type alias to its base type. A custom structure hook registered for the alias therefore never ran when the alias appeared inside a passthrough union (Trimmed | int returned the raw string).

Only unwrap aliases that still use the default type-alias factory. Aliases with a dedicated hook stay in spillover so converter.structure applies them.

Checklist

  • Tests added / relevant tests pass
  • I own and understand these changes; no third-party co-author tags

configure_union_passthrough was unwrapping every type alias to its base,
so a custom structure hook registered for the alias never ran when the
alias appeared inside a passthrough union (e.g. Trimmed | int).

Only unwrap aliases that still use the default type-alias factory; leave
aliases with a dedicated hook in spillover so converter.structure can
apply them.

Fixes python-attrs#797

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Structure hook on a PEP 695 alias is ignored inside a passthrough union

2 participants