Refactor feed types to use strongly-typed dataclasses (PP-2728)#3025
Merged
jonathangreen merged 11 commits intomainfrom Feb 5, 2026
Merged
Refactor feed types to use strongly-typed dataclasses (PP-2728)#3025jonathangreen merged 11 commits intomainfrom
jonathangreen merged 11 commits intomainfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3025 +/- ##
==========================================
+ Coverage 93.00% 93.02% +0.02%
==========================================
Files 479 479
Lines 43502 43527 +25
Branches 6047 6041 -6
==========================================
+ Hits 40461 40493 +32
+ Misses 1970 1965 -5
+ Partials 1071 1069 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
tdilauro
approved these changes
Feb 5, 2026
Contributor
tdilauro
left a comment
There was a problem hiding this comment.
Looks good! 🚀
One minor typo/wordo. Also noticed that there might be some small type coverage gaps, but those may have already been in there and just swept up in this change.
Replace the dynamic FeedEntryType class with specific dataclasses for improved type safety and IDE support: - Add TextValue, Category, Rating, Series, Distribution, PatronData, and DRMLicensor dataclasses to replace generic FeedEntryType usage - Add LicenseInfo and DrmInfo dataclasses in circulation annotator - Change Link to inherit from BaseModel instead of FeedEntryType - Add explicit facet attributes to Link (facetGroup, activeFacet, etc.) - Use boolean values for activeFacet/defaultFacet instead of strings - Remove FeedEntryType.create() factory and add_attributes() methods - Update serializers to handle new type structure - Update all tests for new type assertions
Update dataclass field names to follow Python naming conventions: - facetGroup → facet_group - activeFacet → active_facet - defaultFacet → default_facet - ratingValue → rating_value - additionalType → additional_type - clientToken → client_token - authorizationIdentifier → authorization_identifier - And other camelCase attributes The serializers now handle the conversion to camelCase for OPDS output.
Update the type hint for DataEntry.type to use the new enum.
Co-authored-by: Tim DiLauro <tdilauro@users.noreply.github.com>
572eecd to
b97c8eb
Compare
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.
Description
Refactors the feed types system to use strongly-typed dataclasses instead of the dynamic
FeedEntryTypebase class. This replaces arbitrary attribute handling with explicit, typed fields for better IDE support, type checking, and maintainability.Key changes:
FeedEntryTypeandBaseModelwith dedicated dataclasses:Series,Rating,Category,Distribution,PatronData,DRMLicensor,RichTextslots=Trueto all dataclasses for memory efficiencyadd_attributes()/getattr()patterns with direct attribute accessTypedDictdefinitions (LinkKwargs,LinkAttributes) for typed kwargsDataEntryTypestoStrEnumMotivation and Context
This refactoring lays the groundwork for updating OPDS2 output to use Pydantic models. The existing
FeedEntryTypepattern with dynamic attributes made type checking impossible and the code difficult to understand. The new strongly-typed approach enables proper mypy validation and IDE autocompletion.Relates to: PP-2728
How Has This Been Tested?
Checklist