Skip to content

Commit d4996be

Browse files
committed
Changed check_warnings to check_for_warnings for consistency
1 parent 39326a1 commit d4996be

2 files changed

Lines changed: 23 additions & 23 deletions

File tree

hed/scripts/schema_script_util.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _is_prerelease_partner(base_schema) -> bool:
3131
return hed_cache.get_hed_version_path(with_standard, check_prerelease=False) is None
3232

3333

34-
def validate_schema_object(base_schema, schema_name, check_warnings=False):
34+
def validate_schema_object(base_schema, schema_name, check_for_warnings=False):
3535
"""Validate a schema object by checking compliance and roundtrip conversion.
3636
3737
Tests the schema for compliance issues and validates that it can be successfully
@@ -40,17 +40,17 @@ def validate_schema_object(base_schema, schema_name, check_warnings=False):
4040
Parameters:
4141
base_schema (HedSchema): The schema object to validate.
4242
schema_name (str): The name/path of the schema for error reporting.
43-
check_warnings (bool): If True, include warnings in the validation. Default is False.
43+
check_for_warnings (bool): If True, include warnings in the validation. Default is False.
4444
4545
Returns:
4646
list: A list of validation issue strings. Empty if no issues found.
4747
"""
4848
validation_issues = []
4949
try:
50-
issues = base_schema.check_compliance(check_for_warnings=check_warnings)
51-
if issues and check_warnings:
50+
issues = base_schema.check_compliance(check_for_warnings=check_for_warnings)
51+
if issues and check_for_warnings:
5252
errors, warnings = separate_issues(issues)
53-
issues = errors + warnings # Ensure errors are listed before warnings
53+
issues = errors + warnings # Ensure errors are listed before warnings
5454
else:
5555
errors = issues
5656

@@ -79,7 +79,7 @@ def validate_schema_object(base_schema, schema_name, check_warnings=False):
7979
return validation_issues
8080

8181

82-
def validate_schema(file_path, check_warnings=False):
82+
def validate_schema(file_path, check_for_warnings=False):
8383
"""Validate a schema file, ensuring it can save/load and passes validation.
8484
8585
Loads the schema from file, checks the file extension is lowercase,
@@ -90,7 +90,7 @@ def validate_schema(file_path, check_warnings=False):
9090
If loading a TSV file, this should be a single filename where:
9191
Template: basename.tsv, where files are named basename_Struct.tsv, basename_Tag.tsv, etc.
9292
Alternatively, you can point to a directory containing the .tsv files.
93-
check_warnings (bool): If True, include warnings in the validation. Default is False.
93+
check_for_warnings (bool): If True, include warnings in the validation. Default is False.
9494
9595
Returns:
9696
list: A list of validation issue strings. Empty if no issues found.
@@ -105,7 +105,7 @@ def validate_schema(file_path, check_warnings=False):
105105
validation_issues = []
106106
try:
107107
base_schema = load_schema(file_path)
108-
validation_issues = validate_schema_object(base_schema, file_path, check_warnings=check_warnings)
108+
validation_issues = validate_schema_object(base_schema, file_path, check_for_warnings=check_for_warnings)
109109
except HedFileError as e:
110110
print(f"Saving/loading error: {file_path} {e.message}")
111111
error_text = e.message

tests/scripts/test_script_util.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def test_uppercase_extension_policy_enforcement(self):
272272

273273

274274
class TestCheckWarnings(unittest.TestCase):
275-
"""Tests for the check_warnings parameter in validate_schema_object and validate_schema."""
275+
"""Tests for the check_for_warnings parameter in validate_schema_object and validate_schema."""
276276

277277
@classmethod
278278
def setUpClass(cls):
@@ -283,22 +283,22 @@ def setUpClass(cls):
283283
cls.warning_schema = copy.deepcopy(clean)
284284
cls.warning_schema.header_attributes["version"] = "999.0.0"
285285

286-
def test_clean_schema_check_warnings_false(self):
287-
"""A fully compliant schema produces no issues with check_warnings=False."""
286+
def test_clean_schema_check_for_warnings_false(self):
287+
"""A fully compliant schema produces no issues with check_for_warnings=False."""
288288
with contextlib.redirect_stdout(io.StringIO()):
289-
issues = validate_schema_object(self.clean_schema, "test", check_warnings=False)
289+
issues = validate_schema_object(self.clean_schema, "test", check_for_warnings=False)
290290
self.assertEqual(issues, [])
291291

292-
def test_clean_schema_check_warnings_true(self):
293-
"""A fully compliant schema produces no issues with check_warnings=True."""
292+
def test_clean_schema_check_for_warnings_true(self):
293+
"""A fully compliant schema produces no issues with check_for_warnings=True."""
294294
with contextlib.redirect_stdout(io.StringIO()):
295-
issues = validate_schema_object(self.clean_schema, "test", check_warnings=True)
295+
issues = validate_schema_object(self.clean_schema, "test", check_for_warnings=True)
296296
self.assertEqual(issues, [])
297297

298-
def test_warning_schema_check_warnings_true_reports_issues(self):
299-
"""A prerelease version generates a warning that is reported when check_warnings=True."""
298+
def test_warning_schema_check_for_warnings_true_reports_issues(self):
299+
"""A prerelease version generates a warning that is reported when check_for_warnings=True."""
300300
with contextlib.redirect_stdout(io.StringIO()):
301-
issues = validate_schema_object(self.warning_schema, "test", check_warnings=True)
301+
issues = validate_schema_object(self.warning_schema, "test", check_for_warnings=True)
302302
combined = "\n".join(issues)
303303
self.assertTrue(issues, "Expected at least one issue for prerelease version warning")
304304
self.assertIn(
@@ -313,14 +313,14 @@ def test_warning_schema_check_warnings_true_reports_issues(self):
313313
# because a clean schema with only a version warning should roundtrip without further errors.
314314
self.assertEqual(len(issues), 1, "Roundtrip should have run and produced no additional errors")
315315

316-
def test_warning_schema_check_warnings_false_suppresses_warnings(self):
317-
"""Warnings are suppressed and validation passes when check_warnings=False."""
316+
def test_warning_schema_check_for_warnings_false_suppresses_warnings(self):
317+
"""Warnings are suppressed and validation passes when check_for_warnings=False."""
318318
with contextlib.redirect_stdout(io.StringIO()):
319-
issues = validate_schema_object(self.warning_schema, "test", check_warnings=False)
319+
issues = validate_schema_object(self.warning_schema, "test", check_for_warnings=False)
320320
self.assertEqual(issues, [])
321321

322322
def test_validate_schema_default_is_warnings_false(self):
323-
"""validate_schema default check_warnings=False matches explicit False."""
323+
"""validate_schema default check_for_warnings=False matches explicit False."""
324324
schema_path = os.path.join(
325325
os.path.dirname(os.path.dirname(__file__)),
326326
"data",
@@ -329,5 +329,5 @@ def test_validate_schema_default_is_warnings_false(self):
329329
)
330330
with contextlib.redirect_stdout(io.StringIO()):
331331
default_issues = validate_schema(schema_path)
332-
explicit_issues = validate_schema(schema_path, check_warnings=False)
332+
explicit_issues = validate_schema(schema_path, check_for_warnings=False)
333333
self.assertEqual(default_issues, explicit_issues)

0 commit comments

Comments
 (0)