From 752470f8a86e7080def9930a0ec91ff64c0efe5f Mon Sep 17 00:00:00 2001 From: Kay Robbins <1189050+VisLab@users.noreply.github.com> Date: Wed, 4 Mar 2026 05:23:45 -0600 Subject: [PATCH 1/2] Added a comment to explain reassignment --- hed/scripts/schema_script_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hed/scripts/schema_script_util.py b/hed/scripts/schema_script_util.py index 7af37d04..b9f9b09c 100644 --- a/hed/scripts/schema_script_util.py +++ b/hed/scripts/schema_script_util.py @@ -50,7 +50,7 @@ def validate_schema_object(base_schema, schema_name, check_warnings=False): issues = base_schema.check_compliance(check_for_warnings=check_warnings) if issues and check_warnings: errors, warnings = separate_issues(issues) - issues = errors + warnings + issues = errors + warnings # Ensure errors are listed before warnings else: errors = issues From d4996bea6fe53fbb557146b7215080b73cc0eda2 Mon Sep 17 00:00:00 2001 From: Kay Robbins <1189050+VisLab@users.noreply.github.com> Date: Wed, 4 Mar 2026 05:49:33 -0600 Subject: [PATCH 2/2] Changed check_warnings to check_for_warnings for consistency --- hed/scripts/schema_script_util.py | 16 ++++++++-------- tests/scripts/test_script_util.py | 30 +++++++++++++++--------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/hed/scripts/schema_script_util.py b/hed/scripts/schema_script_util.py index b9f9b09c..b20ef8c1 100644 --- a/hed/scripts/schema_script_util.py +++ b/hed/scripts/schema_script_util.py @@ -31,7 +31,7 @@ def _is_prerelease_partner(base_schema) -> bool: return hed_cache.get_hed_version_path(with_standard, check_prerelease=False) is None -def validate_schema_object(base_schema, schema_name, check_warnings=False): +def validate_schema_object(base_schema, schema_name, check_for_warnings=False): """Validate a schema object by checking compliance and roundtrip conversion. 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): Parameters: base_schema (HedSchema): The schema object to validate. schema_name (str): The name/path of the schema for error reporting. - check_warnings (bool): If True, include warnings in the validation. Default is False. + check_for_warnings (bool): If True, include warnings in the validation. Default is False. Returns: list: A list of validation issue strings. Empty if no issues found. """ validation_issues = [] try: - issues = base_schema.check_compliance(check_for_warnings=check_warnings) - if issues and check_warnings: + issues = base_schema.check_compliance(check_for_warnings=check_for_warnings) + if issues and check_for_warnings: errors, warnings = separate_issues(issues) - issues = errors + warnings # Ensure errors are listed before warnings + issues = errors + warnings # Ensure errors are listed before warnings else: errors = issues @@ -79,7 +79,7 @@ def validate_schema_object(base_schema, schema_name, check_warnings=False): return validation_issues -def validate_schema(file_path, check_warnings=False): +def validate_schema(file_path, check_for_warnings=False): """Validate a schema file, ensuring it can save/load and passes validation. Loads the schema from file, checks the file extension is lowercase, @@ -90,7 +90,7 @@ def validate_schema(file_path, check_warnings=False): If loading a TSV file, this should be a single filename where: Template: basename.tsv, where files are named basename_Struct.tsv, basename_Tag.tsv, etc. Alternatively, you can point to a directory containing the .tsv files. - check_warnings (bool): If True, include warnings in the validation. Default is False. + check_for_warnings (bool): If True, include warnings in the validation. Default is False. Returns: list: A list of validation issue strings. Empty if no issues found. @@ -105,7 +105,7 @@ def validate_schema(file_path, check_warnings=False): validation_issues = [] try: base_schema = load_schema(file_path) - validation_issues = validate_schema_object(base_schema, file_path, check_warnings=check_warnings) + validation_issues = validate_schema_object(base_schema, file_path, check_for_warnings=check_for_warnings) except HedFileError as e: print(f"Saving/loading error: {file_path} {e.message}") error_text = e.message diff --git a/tests/scripts/test_script_util.py b/tests/scripts/test_script_util.py index 5e004d47..12b83f69 100644 --- a/tests/scripts/test_script_util.py +++ b/tests/scripts/test_script_util.py @@ -272,7 +272,7 @@ def test_uppercase_extension_policy_enforcement(self): class TestCheckWarnings(unittest.TestCase): - """Tests for the check_warnings parameter in validate_schema_object and validate_schema.""" + """Tests for the check_for_warnings parameter in validate_schema_object and validate_schema.""" @classmethod def setUpClass(cls): @@ -283,22 +283,22 @@ def setUpClass(cls): cls.warning_schema = copy.deepcopy(clean) cls.warning_schema.header_attributes["version"] = "999.0.0" - def test_clean_schema_check_warnings_false(self): - """A fully compliant schema produces no issues with check_warnings=False.""" + def test_clean_schema_check_for_warnings_false(self): + """A fully compliant schema produces no issues with check_for_warnings=False.""" with contextlib.redirect_stdout(io.StringIO()): - issues = validate_schema_object(self.clean_schema, "test", check_warnings=False) + issues = validate_schema_object(self.clean_schema, "test", check_for_warnings=False) self.assertEqual(issues, []) - def test_clean_schema_check_warnings_true(self): - """A fully compliant schema produces no issues with check_warnings=True.""" + def test_clean_schema_check_for_warnings_true(self): + """A fully compliant schema produces no issues with check_for_warnings=True.""" with contextlib.redirect_stdout(io.StringIO()): - issues = validate_schema_object(self.clean_schema, "test", check_warnings=True) + issues = validate_schema_object(self.clean_schema, "test", check_for_warnings=True) self.assertEqual(issues, []) - def test_warning_schema_check_warnings_true_reports_issues(self): - """A prerelease version generates a warning that is reported when check_warnings=True.""" + def test_warning_schema_check_for_warnings_true_reports_issues(self): + """A prerelease version generates a warning that is reported when check_for_warnings=True.""" with contextlib.redirect_stdout(io.StringIO()): - issues = validate_schema_object(self.warning_schema, "test", check_warnings=True) + issues = validate_schema_object(self.warning_schema, "test", check_for_warnings=True) combined = "\n".join(issues) self.assertTrue(issues, "Expected at least one issue for prerelease version warning") self.assertIn( @@ -313,14 +313,14 @@ def test_warning_schema_check_warnings_true_reports_issues(self): # because a clean schema with only a version warning should roundtrip without further errors. self.assertEqual(len(issues), 1, "Roundtrip should have run and produced no additional errors") - def test_warning_schema_check_warnings_false_suppresses_warnings(self): - """Warnings are suppressed and validation passes when check_warnings=False.""" + def test_warning_schema_check_for_warnings_false_suppresses_warnings(self): + """Warnings are suppressed and validation passes when check_for_warnings=False.""" with contextlib.redirect_stdout(io.StringIO()): - issues = validate_schema_object(self.warning_schema, "test", check_warnings=False) + issues = validate_schema_object(self.warning_schema, "test", check_for_warnings=False) self.assertEqual(issues, []) def test_validate_schema_default_is_warnings_false(self): - """validate_schema default check_warnings=False matches explicit False.""" + """validate_schema default check_for_warnings=False matches explicit False.""" schema_path = os.path.join( os.path.dirname(os.path.dirname(__file__)), "data", @@ -329,5 +329,5 @@ def test_validate_schema_default_is_warnings_false(self): ) with contextlib.redirect_stdout(io.StringIO()): default_issues = validate_schema(schema_path) - explicit_issues = validate_schema(schema_path, check_warnings=False) + explicit_issues = validate_schema(schema_path, check_for_warnings=False) self.assertEqual(default_issues, explicit_issues)