-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Union Transformer Ambiguous Error Message #3076
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -4,6 +4,7 @@ | |||||||||
import sys | ||||||||||
import pytest | ||||||||||
import mock | ||||||||||
from flytekit import task | ||||||||||
|
||||||||||
from flytekit.core.context_manager import FlyteContextManager | ||||||||||
from flytekit.core.type_engine import TypeEngine, TypeTransformerFailedError | ||||||||||
|
@@ -140,3 +141,22 @@ class TestDataclass(DataClassJsonMixin): | |||||||||
assert o.b.remote_path == ot.b.remote_source | ||||||||||
assert o.c["a"] == ot.c["a"] | ||||||||||
assert o.d == FlyteFile(remote_path) | ||||||||||
|
||||||||||
def test_ambiguous_union_transformer_to_literal(): | ||||||||||
@dataclass | ||||||||||
class A: | ||||||||||
a: int | ||||||||||
|
||||||||||
@dataclass | ||||||||||
class B: | ||||||||||
a: int | ||||||||||
|
||||||||||
@task | ||||||||||
def t1() -> typing.Union[A, B]: | ||||||||||
return A(a=1) | ||||||||||
|
||||||||||
with pytest.raises( | ||||||||||
TypeError, | ||||||||||
match=("Potential types:") | ||||||||||
): | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider more specific error message assertion
The error message assertion Code suggestionCheck the AI-generated fix before applying
Suggested change
Code Review Run #da8f08 Is this a valid issue, or was it incorrectly flagged by the Agent?
|
||||||||||
t1() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add more to this error message stating why they are ambiguous? Something like:
Otherwise, it's hard to tell from the error what is wrong.