Skip to content

Commit

Permalink
add a part of a test
Browse files Browse the repository at this point in the history
Signed-off-by: Yee Hing Tong <[email protected]>
  • Loading branch information
wild-endeavor committed Sep 30, 2021
1 parent 71bb771 commit 31b517c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion flytekit/core/type_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def guess_python_type(self, literal_type: LiteralType) -> Type[T]:
if literal_type.metadata is not None and "definitions" in literal_type.metadata:
return convert_json_schema_to_python_class(literal_type.metadata)

raise ValueError(f"Dictionary transformer cannot reverse {literal_type}")
raise ValueError(f"Dataclass transformer cannot reverse {literal_type}")


class ProtobufTransformer(TypeTransformer[_proto_reflection.GeneratedProtocolMessageType]):
Expand Down
13 changes: 13 additions & 0 deletions tests/flytekit/unit/core/test_type_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,3 +616,16 @@ def test_literals_resolver(literal_value, python_type, expected_python_value):
lr = LiteralsResolver(lit_dict)
out = lr.get("a", python_type)
assert out == expected_python_value


def test_guess_of_dataclass():
@dataclass_json
@dataclass()
class Foo(object):
x: int
y: str
z: typing.Dict[int, str]

lt = TypeEngine.to_literal_type(Foo)
# This will need to be improved in the future after fixing the Model class.
TypeEngine.guess_python_type(lt)

0 comments on commit 31b517c

Please sign in to comment.