Skip to content

Commit 07705c0

Browse files
authored
Switch type comparison in BaseFn to use is_types_compatible (#3461)
1 parent 37c53dd commit 07705c0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/cfnlint/rules/functions/_BaseFn.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from collections import namedtuple
99
from typing import Any, Tuple
1010

11-
from cfnlint.helpers import ToPy, ensure_list
11+
from cfnlint.helpers import ToPy, ensure_list, is_types_compatible
1212
from cfnlint.jsonschema import ValidationError, ValidationResult, Validator
1313
from cfnlint.rules import CloudFormationLintRule
1414

@@ -118,7 +118,7 @@ def validate_fn_output_types(
118118
) -> ValidationResult:
119119
tS = self.resolve_type(validator, s)
120120
if tS:
121-
if not any(t in self.types for t in tS):
121+
if not is_types_compatible(self.types, tS):
122122
reprs = ", ".join(repr(type) for type in tS)
123123
yield ValidationError(f"{instance!r} is not of type {reprs}")
124124

test/unit/rules/functions/test_length.py

+7
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ def context(cfn):
113113
{"transforms": Transforms(["AWS::LanguageExtensions"])},
114114
[],
115115
),
116+
(
117+
"Fn::Length output while a number can be a string",
118+
{"Fn::Length": []},
119+
{"type": "string"},
120+
{"transforms": Transforms(["AWS::LanguageExtensions"])},
121+
[],
122+
),
116123
],
117124
)
118125
def test_validate(name, instance, schema, context_evolve, expected, rule, context, cfn):

0 commit comments

Comments
 (0)