Refactor validator return type to support warnings via ValidationResult wrapper (#1479) - #1480
Conversation
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1480 +/- ##
==========================================
- Coverage 93.18% 93.15% -0.04%
==========================================
Files 41 41
Lines 10269 10296 +27
Branches 2126 2128 +2
==========================================
+ Hits 9569 9591 +22
- Misses 421 424 +3
- Partials 279 281 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks! Looks good overall. Could you please add some basic tests of
Could you please also add a changelog entry that points to this PR? |
3a072bb to
669261e
Compare
9d3ea64 to
88bb8e9
Compare
|
@sejalpunwatkar Thanks for your work on this. Let me know when it is ready for re-review. |
|
Hi @rly, the PR is now ready for your re-review! I have fully addressed your feedback from the initial code review:
|
|
Thanks @sejalpunwatkar . This is looking much better. I have a few more comments and suggestions above |
5e33150 to
964acbf
Compare
|
Hi @rly, I've addressed all your feedback: fixed the changelog section, updated the docstrings, corrected the test indentation, implemented the missing test, and updated the ValidationWarning.eq check. Ready for review! |
# Conflicts: # CHANGELOG.md
Change "Validate an file" to "Validate a file" per code review suggestion.
|
Thanks for catching that, @rly ! Fixed now. |
…ning - Error and ValidationWarning now share __init__, properties, __str__, __hash__, and __eq__ logic via a common ValidationIssue base class - Error.__eq__ now correctly checks type, matching ValidationWarning - Add test confirming Error and ValidationWarning with same fields are not equal
for more information, see https://pre-commit.ci
…ejalpunwatkar/hdmf into feature/1479-validation-result
- Update changelog entry and placement - Move ValidationResult into validator module - Add TestValidate for testing a clean validation with no warnings - Refactor TestValidationResultWrapper
|
Thanks for your patience and contributions @sejalpunwatkar ! I made a few minor adjustments and this is now good to go. |
Motivation
Addresses #1479
This PR implements Phase 1 (the foundational plumbing) to introduce
ValidationWarninginfrastructure without breaking the existing error reporting model. This change ensures that downstream packages (like PyNWB and NWB Inspector) can eventually consume warning-level messages without modifying their immediate logic or incorrectly marking files as invalid.How to test the behavior?
ValidationWarningclass as a sibling toErrorinsideerrors.py, preserving the matching internal shape (.name,.reason,.location).ValidationResultwrapper class inerrors.pywith custom Python overrides (__bool__,__len__,__iter__,__getitem__) pointing explicitly to theerrorsbucket to ensure backward compatibility.ValidatorMap.validate()insidevalidator.pyto capture theerrors_list, wrap it into the newValidationResultcontainer with an empty warnings container (warnings=[]), and adjusted its strict@docvalreturn type check tortype=(list, ValidationResult).Checklist
CHANGELOG.mdwith your changes?