Refactor DataProvider and implement Search class#24
Draft
mekarpeles wants to merge 2 commits intomainfrom
Draft
Conversation
* Introduce Search dataclass for query handling Added a Search dataclass to facilitate search queries.
Member
Author
|
@copilot can you please fix the tests based on this new setup? |
Contributor
|
@mekarpeles I've opened a new pull request, #25, to work on those changes. Once the pull request is ready, I'll request review from you. |
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.
This pull request refactors and modernizes the OPDS 2.0 data provider interface in
pyopds2/provider.py. The main focus is on improving the structure and clarity of search-related classes by leveraging Pydantic models, simplifying pagination logic, and clarifying the responsibilities of each class. The changes also enhance type safety and make the codebase easier to extend and maintain.Refactoring and Modernization of Search Classes:
Searchclass as aBaseModelthat encapsulates search parameters and implements theMappinginterface for more flexible parameter handling. ([pyopds2/provider.pyL47-L144](https://github.com/ArchiveLabs/pyopds2/pull/24/files#diff-3c4eb5693ca60f8c4cdee0fb8a7c7df6abf3722fd9954166b46f92a6e27ec8b0L47-L144))SearchResponsedataclass with a top-levelSearchResponsePydantic model, which now references the newSearchobject and simplifies parameter and pagination logic. ([pyopds2/provider.pyL47-L144](https://github.com/ArchiveLabs/pyopds2/pull/24/files#diff-3c4eb5693ca60f8c4cdee0fb8a7c7df6abf3722fd9954166b46f92a6e27ec8b0L47-L144))Simplification and Clarification of DataProvider Interface:
DataProviderabstract base class: moved search logic to a@classmethod, removed unnecessary attributes, and clarified documentation for easier extension by consumers. ([pyopds2/provider.pyL47-L144](https://github.com/ArchiveLabs/pyopds2/pull/24/files#diff-3c4eb5693ca60f8c4cdee0fb8a7c7df6abf3722fd9954166b46f92a6e27ec8b0L47-L144))dataclasses,functools) and replaced them with necessary imports (Mapping) to support the new class structures. ([pyopds2/provider.pyL7-R7](https://github.com/ArchiveLabs/pyopds2/pull/24/files#diff-3c4eb5693ca60f8c4cdee0fb8a7c7df6abf3722fd9954166b46f92a6e27ec8b0L7-R7))