Skip to content

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

Open
vyrnsynx wants to merge 1 commit into
python-attrs:mainfrom
vyrnsynx:fix-797-alias-hook-passthrough-union
Open

vyrnsynx wants to merge 1 commit into
python-attrs:mainfrom
vyrnsynx:fix-797-alias-hook-passthrough-union

Conversation

@vyrnsynx

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. Direct register_structure_hook registrations are detected via _direct_dispatch as well as predicate hooks on the function dispatch.

Checklist

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

configure_union_passthrough was unwrapping every PEP 695 type alias to its
base type, so a custom structure hook registered for the alias 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.

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

1 participant