Skip to content

Support type aliases in union passthrough#753

Open
yzhkali wants to merge 1 commit into
python-attrs:mainfrom
yzhkali:fix/union-passthrough-type-alias
Open

Support type aliases in union passthrough#753
yzhkali wants to merge 1 commit into
python-attrs:mainfrom
yzhkali:fix/union-passthrough-type-alias

Conversation

@yzhkali
Copy link
Copy Markdown

@yzhkali yzhkali commented May 31, 2026

Summary

  • unwrap PEP 695 type aliases when union passthrough checks native union members
  • keep spillover handling for non-passthrough union members intact
  • add Python 3.12 coverage for a type alias mixed with a dataclass in the target union

Closes #742

Tests

  • .venv/bin/python -m pytest tests/strategies/test_tagged_unions_695.py tests/strategies/test_union_passthrough.py tests/strategies/test_union_passthrough_695.py
  • .venv/bin/ruff check src/cattrs/strategies/_unions.py tests/strategies/test_union_passthrough_695.py
  • .venv/bin/ruff format --check src/cattrs/strategies/_unions.py tests/strategies/test_union_passthrough_695.py
  • git diff --check

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.

Union passthrough does not work when target union uses a new-style type alias as element for passthrough

1 participant