Skip to content

Conversation

@mekarpeles
Copy link
Member

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:

  • Introduced a new Search class as a BaseModel that encapsulates search parameters and implements the Mapping interface for more flexible parameter handling. ([pyopds2/provider.pyL47-L144](https://github.com/ArchiveLabs/pyopds2/pull/24/files#diff-3c4eb5693ca60f8c4cdee0fb8a7c7df6abf3722fd9954166b46f92a6e27ec8b0L47-L144))
  • Replaced the inner SearchResponse dataclass with a top-level SearchResponse Pydantic model, which now references the new Search object 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:

  • Refactored the DataProvider abstract 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))
  • Removed unused imports (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))

* Introduce Search dataclass for query handling

Added a Search dataclass to facilitate search queries.
@mekarpeles mekarpeles marked this pull request as draft November 24, 2025 00:43
@mekarpeles
Copy link
Member Author

@copilot can you please fix the tests based on this new setup?

Copy link
Contributor

Copilot AI commented Nov 24, 2025

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants