Skip to content

Add regression matrix for heterogeneous union annotations - #735

Merged
wbarnha merged 8 commits into
masterfrom
fix-pep604-json-unions
Aug 12, 2026
Merged

Add regression matrix for heterogeneous union annotations#735
wbarnha merged 8 commits into
masterfrom
fix-pep604-json-unions

Conversation

@wbarnha

@wbarnha wbarnha commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

  • Add a focused compatibility suite for Faust model field unions.
  • Cover both typing.Union and PEP 604 (X | Y) annotations.
  • Preserve coverage for currently supported scalar, optional-model, and nested-container forms.
  • Reproduce the exact declaration from NotImplementedError: Union of types not supported mode#80.
  • Separate JSON-shaped pass-through candidates from ambiguous/coercion-sensitive unions that should remain explicitly unsupported.

Current finding

Mode 0.5.3 now correctly recognizes PEP 604 unions. Faust's UnionNode only collapses unions when every member is a model or every member is a literal scalar. A union such as str | list | dict | None therefore reaches UnionNode.build() and raises NotImplementedError during Record class creation.

The issue #80 cases are marked strict xfail in this draft so CI documents the existing failure while the implementation fix is designed. Ambiguous model/scalar and coercion-sensitive unions remain passing negative tests.

@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.20%. Comparing base (44f408a) to head (6e258bd).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #735   +/-   ##
=======================================
  Coverage   96.20%   96.20%           
=======================================
  Files         110      110           
  Lines       11790    11790           
  Branches     1281     1281           
=======================================
  Hits        11343    11343           
  Misses        350      350           
  Partials       97       97           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wbarnha
wbarnha marked this pull request as ready for review August 11, 2026 18:38

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7ae2c7f181

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +57 to +60
@pytest.mark.xfail(
reason="mode#80: Faust does not yet pass through heterogeneous JSON unions",
strict=True,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove the stale strict xfail markers

The parent revision already implements heterogeneous unions as pass-through expressions in UnionNode.build, so all four parameterizations here complete successfully; strict=True converts each resulting XPASS into a test-suite failure. The same stale strict marker on the record-declaration test below causes another unconditional XPASS failure, so these tests must no longer be marked xfail.

Useful? React with 👍 / 👎.

Comment on lines +95 to +96
with pytest.raises(NotImplementedError, match="Union of types"):
TypeExpression(annotation).as_function()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Align unsupported-union assertions with pass-through behavior

For every annotation in this parameterization, _maybe_unroll_union leaves the heterogeneous union intact and the existing UnionNode.build returns the input expression rather than raising NotImplementedError. Consequently, every invocation exits the pytest.raises context without an exception and fails CI; these expectations need to match the already-established pass-through semantics.

Useful? React with 👍 / 👎.

@wbarnha
wbarnha merged commit 27212f6 into master Aug 12, 2026
33 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