Add regression matrix for heterogeneous union annotations - #735
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 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".
| @pytest.mark.xfail( | ||
| reason="mode#80: Faust does not yet pass through heterogeneous JSON unions", | ||
| strict=True, | ||
| ) |
There was a problem hiding this comment.
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 👍 / 👎.
| with pytest.raises(NotImplementedError, match="Union of types"): | ||
| TypeExpression(annotation).as_function() |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
typing.Unionand PEP 604 (X | Y) annotations.Current finding
Mode 0.5.3 now correctly recognizes PEP 604 unions. Faust's
UnionNodeonly collapses unions when every member is a model or every member is a literal scalar. A union such asstr | list | dict | Nonetherefore reachesUnionNode.build()and raisesNotImplementedErrorduringRecordclass 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.