Skip to content

Commit dcf5f0c

Browse files
committed
Added integer conversion if possible
Signed-off-by: Jaehyun Kim <[email protected]>
1 parent d97cd8d commit dcf5f0c

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

flow/util/checkMetadata.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,27 +95,26 @@ def try_number(string):
9595
print(f"[ERROR] Value not found for {field}.")
9696
sys.exit(1)
9797

98-
formatError = list()
99-
if not isinstance(rule_value, float):
100-
formatError.append("rule_value")
101-
if not isinstance(build_value, float):
102-
formatError.append("build_value")
103-
if len(formatError) != 0:
104-
print(
105-
f"Error: field {field}, has invalid float format for "
106-
f"{', '.join(formatError)}"
107-
)
108-
ERRORS += 1
109-
continue
110-
111-
if op(build_value, rule_value):
112-
PRE = "[INFO]"
113-
CHECK = "pass"
114-
elif rule.get("level") == "warning":
115-
PRE = "[WARN]"
116-
CHECK = "pass"
117-
WARNS += 1
118-
else:
98+
# Convert to integer if possible
99+
if isinstance(rule_value, float) and rule_value.is_integer():
100+
rule_value = int(rule_value)
101+
if isinstance(build_value, float) and build_value.is_integer():
102+
build_value = int(build_value)
103+
104+
try:
105+
if op(build_value, rule_value):
106+
PRE = "[INFO]"
107+
CHECK = "pass"
108+
elif rule.get("level") == "warning":
109+
PRE = "[WARN]"
110+
CHECK = "pass"
111+
WARNS += 1
112+
else:
113+
PRE = "[ERROR]"
114+
CHECK = "fail"
115+
ERRORS += 1
116+
except TypeError:
117+
# Handle cases where types are not comparable (e.g., string vs. number)
119118
PRE = "[ERROR]"
120119
CHECK = "fail"
121120
ERRORS += 1

0 commit comments

Comments
 (0)