Skip to content

Commit 656f251

Browse files
committed
Cleaned up the lobic on the validate_schema_object
1 parent 6e34f3b commit 656f251

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

hed/scripts/schema_script_util.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from hed.schema import from_string, load_schema, from_dataframes
44
from hed.schema import hed_cache
55
from hed.errors import get_printable_issue_string, HedFileError
6-
from hed.errors.error_types import ErrorSeverity
6+
from hed.errors.error_reporter import separate_issues
77
from hed.schema.schema_comparer import SchemaComparer
88

99
all_extensions = [".tsv", ".mediawiki", ".xml", ".json"]
@@ -48,12 +48,16 @@ def validate_schema_object(base_schema, schema_name, check_warnings=False):
4848
"""
4949
validation_issues = []
5050
try:
51-
issues = base_schema.check_compliance()
52-
if not check_warnings:
53-
issues = [issue for issue in issues if issue.get("severity", ErrorSeverity.ERROR) == ErrorSeverity.ERROR]
51+
issues = base_schema.check_compliance(check_warnings=check_warnings)
52+
if issues and check_warnings:
53+
errors, warnings = separate_issues(issues)
54+
issues = errors + issues
55+
else:
56+
errors = issues
57+
5458
if issues:
55-
error_message = get_printable_issue_string(issues, title=schema_name)
56-
validation_issues.append(error_message)
59+
validation_issues.append(get_printable_issue_string(issues, title=schema_name))
60+
if errors:
5761
return validation_issues
5862

5963
# If the withStandard partner only exists in the prerelease cache, all unmerged

tests/scripts/test_script_util.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,12 @@ def test_warning_schema_check_warnings_true_reports_issues(self):
306306
combined,
307307
"Expected SCHEMA_PRERELEASE_VERSION_USED warning code in output for prerelease version",
308308
)
309+
# Warnings must not gate the roundtrip checks — the warning message should be the only
310+
# entry and roundtrip errors (if any) would append further entries, but the key contract
311+
# is that the function does NOT return after reporting a warning-only result.
312+
# We verify this indirectly: issue count must equal exactly 1 (the warning summary)
313+
# because a clean schema with only a version warning should roundtrip without further errors.
314+
self.assertEqual(len(issues), 1, "Roundtrip should have run and produced no additional errors")
309315

310316
def test_warning_schema_check_warnings_false_suppresses_warnings(self):
311317
"""Warnings are suppressed and validation passes when check_warnings=False."""

0 commit comments

Comments
 (0)