refactor(video): reuse field guards in VideoImportConfig (#508) - #512
Conversation
|
👋 Hi @Rayan-and-beyond — thank you so much for your first contribution to HFlow! A maintainer will review your pull request as soon as possible. In the meantime:
💡 Tip: one open pull request per contributor at a time. Issues with an assignee are taken; everything else is fair game. We are excited to have you here and appreciate your help making the project better! 🙌 |
9c29b9b to
58a66cc
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The refactor preserves domain-specific validation and includes focused regression coverage.
Pull request overview
Refactors VideoImportConfig to reuse shared numeric validation guards while preserving video-specific even-dimension checks.
Changes:
- Reuses finite-number, positive-integer, and bounded-integer guards.
- Retains local H.264 evenness validation.
- Adds regression coverage for validation behavior and messages.
File summaries
| File | Description |
|---|---|
tests/test_video_import.py |
Adds invalid-input and validation-message coverage. |
src/hflow/importers/video.py |
Reuses shared field guards and retains evenness validation. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
One mutation does not bite: widening the start_time_ns upper bound passes all 38 tests, even though tests/test_video_import.py:229 passes (1 << 64). Have a look at why.
It predates your change, so "I established it is not independently reachable, here is why" is a complete answer.
Everything else is clean.
|
Thanks — I traced the upper-bound mutation. The existing I kept the field-level bound and added a focused assertion for its error. With that in place, removing only the upper bound now makes the test fail independently. I reran the video-import tests, Ruff, formatting, and |
Closes #508.
What changes
VideoImportConfig.__post_init__now reuses the shared numeric field guards instead of duplicating type and range checks.duration_s,source_start_s, andimage_hzuserequire_finite_floatimage_widthandimage_heightuserequire_positive_int, while the H.264 even-dimension rule stays local tovideo.pystart_time_nsusesrequire_int_in_rangewith the existing timestamp boundsThe video-specific validation remains in place, including the separate even-dimension error so non-positive and odd dimensions are reported distinctly.
Validation
Ran:
Result:
tests/test_video_import.py: 39 passedty: cleanI also checked each guard independently.
The
start_time_nsupper-bound case originally stayed green when that bound was removed because the later MCAP timestamp-range check rejected the same value. I added a focused assertion for the field-level error so that removing only the upper bound now fails independently instead of being masked by the downstream check.