Add Pydantic data models for processing pipeline#6
Merged
Conversation
Define 7 pipeline models (ProcessingJob, PageText, OCRResult, VisionResult, ReconciledDocument, Classification, ProcessedDocument) with validators for confidence ranges, date parsing, and string constraints. Includes ~25 tests covering creation, defaults, validation, and JSON roundtrips. Closes #5 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace duplicate confidence_in_range validators with Annotated type - Add _parse_date validator to ProcessedDocument.document_date - Remove ambiguous US date format from _DATE_FORMATS - Add validate_assignment=True to ProcessingJob for runtime safety - Add min_length=1 to ProcessingJob.file_type - Add whitespace-only rejection to Classification fields - Add tests for new validations (non-string date, whitespace, assignment) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ound 2 - Handle datetime-is-subclass-of-date in _parse_date by extracting .date() - Strip whitespace from Classification fields (recipient, category, subject) - Add blank-check validator to ProcessingJob.file_type - Add tests for datetime-to-date conversion, whitespace stripping, blank file_type Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add validate_assignment=True to Classification, ReconciledDocument, and ProcessedDocument so validators run on mutation - Strip and lowercase file_type in ProcessingJob validator - Strip whitespace from date strings before parsing in _parse_date - Add ISO datetime string fallback in _parse_date for LLM outputs - Add tests for assignment validation, datetime strings, whitespace dates Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ProcessingJob,PageText,OCRResult,VisionResult,ReconciledDocument,Classification,ProcessedDocument_parse_datehelper supporting ISO dates, ISO datetimes, European (dd/mm/YYYY), and dot-separated (dd.mm.YYYY) formats with whitespace strippingConfidencetype alias (Annotated[float, Field(ge=0.0, le=1.0)]) shared across modelsvalidate_assignment=Trueon models with validators for runtime safetyTest plan
models.pyat 99% coverage (97% uncovered lines are defensive branches for None/empty-string inputs that Pydantic skips)ruff checkpassesruff format --checkpassesty checkpassesCloses #5
🤖 Generated with Claude Code