Skip to content

Commit

Permalink
update pingsu's advice, no any to int
Browse files Browse the repository at this point in the history
Signed-off-by: Future-Outlier <[email protected]>
  • Loading branch information
Future-Outlier committed May 24, 2024
1 parent db38ee3 commit ef74a47
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
6 changes: 3 additions & 3 deletions flytepropeller/pkg/compiler/validators/typing.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,12 @@ func isTypeAny(t *flyte.LiteralType) bool {
}

func AreTypesCastable(upstreamType *flyte.LiteralType, downstreamType *flyte.LiteralType) bool {
typeChecker := getTypeChecker(downstreamType)

if isTypeAny(upstreamType) || isTypeAny(downstreamType) {
if isTypeAny(downstreamType) {
return true
}

typeChecker := getTypeChecker(downstreamType)

// if upstream is a singular union we check if the downstream type is castable from the union variant
if upstreamType.GetUnionType() != nil && len(upstreamType.GetUnionType().GetVariants()) == 1 {
variants := upstreamType.GetUnionType().GetVariants()
Expand Down
19 changes: 0 additions & 19 deletions flytepropeller/pkg/compiler/validators/typing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,6 @@ func TestSimpleLiteralCasting(t *testing.T) {
assert.True(t, castable, "Integers should be castable to Python Any")
})

t.Run("PythonAnyToInteger", func(t *testing.T) {
castable := AreTypesCastable(
&core.LiteralType{
Type: &core.LiteralType_Blob{},
Metadata: &structpb.Struct{
Fields: map[string]*structpb.Value{
"python_class_name": {
Kind: &structpb.Value_StringValue{StringValue: "typing.Any"},
},
},
},
},
&core.LiteralType{
Type: &core.LiteralType_Simple{Simple: core.SimpleType_INTEGER},
},
)
assert.True(t, castable, "Python Any should be castable to Integers")
})

t.Run("IntegerToFloat", func(t *testing.T) {
castable := AreTypesCastable(
&core.LiteralType{
Expand Down

0 comments on commit ef74a47

Please sign in to comment.