Skip to content

Add union introspection compatibility tests#81

Merged
wbarnha merged 13 commits into
masterfrom
test-pep604-union-contract
Jul 23, 2026
Merged

Add union introspection compatibility tests#81
wbarnha merged 13 commits into
masterfrom
test-pep604-union-contract

Conversation

@wbarnha

@wbarnha wbarnha commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

  • Add a compatibility contract for is_union, is_optional, remove_optional, and _remove_optional.
  • Cover both typing.Union and PEP 604 (X | Y) syntax.
  • Keep the suite import-safe on Python 3.9 while exercising PEP 604 behavior on Python 3.10+.

Why

Mode issue #80 exposed a downstream compatibility boundary: Mode 0.5.3 correctly recognizes PEP 604 unions that 0.4.1 did not recognize. These tests make that behavior explicit so future changes cannot silently alter the annotation shape downstream projects receive.

This PR does not change Mode runtime behavior; the reported exception is raised later by Faust's type-expression compiler.

@wbarnha
wbarnha merged commit e98f2e0 into master Jul 23, 2026
14 checks passed
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.

1 participant