Changed schema error vs warning strategy#1252
Conversation
PR Review: Changed schema error vs warning strategySummary: This PR introduces a Important issues1.
errors = [... if issue["severity"] <= 1] # severity 1 only
warnings = [... if issue["severity"] >= 10] # severity 10+ onlyAny future severity value in the range 2–9 would be silently excluded from both lists. The method name implies a complete partition. Consider 2. The first sentence still reads "checking non-warning compliance" but the new signature has 3. Inconsistent
A caller who uses Suggestions
|
There was a problem hiding this comment.
Pull request overview
This PR adjusts how schema validation treats warnings vs errors by adding a check_warnings switch to schema validation utilities and introducing an issue-splitting helper in the error reporter. It also updates CI caching settings and modifies the coverage workflow steps.
Changes:
- Add
check_warningsparameter support tovalidate_schema_object/validate_schemaand add tests covering warning suppression/reporting behavior. - Add
ErrorHandler.separate_issuesplus unit tests for separating errors vs warnings. - Update GitHub Actions workflows (uv cache dependency glob; remove Ruff lint step from coverage workflow).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
hed/scripts/schema_script_util.py |
Adds check_warnings control to schema validation flow and forwards it into object validation. |
tests/scripts/test_script_util.py |
Adds tests to confirm warning inclusion/suppression behavior for schema validation utilities. |
hed/errors/error_reporter.py |
Introduces ErrorHandler.separate_issues helper to split issue lists by severity. |
tests/errors/test_error_reporter.py |
Adds unit tests for ErrorHandler.separate_issues. |
.github/workflows/ci_windows.yaml |
Adds uv cache dependency glob configuration. |
.github/workflows/ci_cov.yaml |
Removes Ruff linting step from the coverage workflow and simplifies dependency install. |
Comments suppressed due to low confidence (2)
hed/scripts/schema_script_util.py:58
- When
check_warnings=True, any warnings frombase_schema.check_compliance()will trigger the earlyreturnand skip the roundtrip format validation, even though warnings are typically non-fatal. If the intent is “fail only on errors but optionally report warnings”, consider separating errors vs warnings (or filtering to errors for the early-return decision) so roundtrip checks still run when there are warnings only. Also consider passingcheck_for_warnings=check_warningsintocheck_compliance()instead of post-filtering by severity to keep behavior aligned with the schema validator’s API.
issues = base_schema.check_compliance()
if not check_warnings:
issues = [issue for issue in issues if issue.get("severity", ErrorSeverity.ERROR) == ErrorSeverity.ERROR]
if issues:
error_message = get_printable_issue_string(issues, title=schema_name)
validation_issues.append(error_message)
return validation_issues
.github/workflows/ci_cov.yaml:44
- This workflow change removes the Ruff install+lint step from
ci_cov.yaml. If linting is still intended to gate merges, confirm the dedicatedRuffworkflow remains required/required-status in branch protection; otherwise, this change may unintentionally reduce CI coverage compared to before.
# Install dependencies
- name: Install dependencies
run: uv pip install -e ".[docs,test]"
# Run unittest with coverage
- name: Test with unittest and coverage
env:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR Review: Changed schema error vs warning strategyOverall the change is well-structured and the test coverage is solid. One behavioral bug needs fixing before merge; the rest are minor or already handled correctly. Important
The early-return guard fires for any non-empty issues = base_schema.check_compliance()
if not check_warnings:
issues = [... only errors ...]
if issues: # fires even for warnings-only
validation_issues.append(error_message)
return validation_issues # roundtrip checks never runWhen Minimal fix — separate the early-exit decision from the warning-inclusion decision: issues = base_schema.check_compliance()
errors_only = [i for i in issues if i.get("severity", ErrorSeverity.ERROR) == ErrorSeverity.ERROR]
report_issues = issues if check_warnings else errors_only
if report_issues:
validation_issues.append(get_printable_issue_string(report_issues, title=schema_name))
if errors_only: # only hard errors block roundtrip
return validation_issuesThe existing test False positives in prior automated reviews (no action needed)"Inconsistent defaults" — both "Silent gap in Suggestions
|
Review SummaryThree critical bugs in Critical:
|
hed/scripts/schema_script_util.py
Outdated
| try: | ||
| issues = base_schema.check_compliance() | ||
| issues = [issue for issue in issues if issue.get("severity", ErrorSeverity.ERROR) == ErrorSeverity.ERROR] | ||
| issues = base_schema.check_compliance(check_warnings=check_warnings) |
There was a problem hiding this comment.
Critical: The keyword argument name is wrong. The actual check_compliance signature is:
def check_compliance(self, check_for_warnings=True, name=None, error_handler=None)Passing check_warnings= raises TypeError: check_compliance() got an unexpected keyword argument 'check_warnings'.
| issues = base_schema.check_compliance(check_warnings=check_warnings) | |
| issues = base_schema.check_compliance(check_for_warnings=check_warnings) |
PR Review: Changed schema error vs warning strategySummaryThe PR cleanly separates error/warning handling in schema validation. The new Two issues need attention before merge: Important — Breaking public API change
from hed.errors import replace_tag_referenceswill raise Recommended fix: Either add a backward-compat re-export in replace_tag_references = ErrorHandler.replace_tag_references # deprecated; use ErrorHandler.replace_tag_referencesor bump the major version and document the break in the changelog. Suggestion — Unexplained reassignment in
|
No description provided.