Refactor/http session interface#35
Merged
Merged
Conversation
…eter of RestApiRepository class to be more flexible in choosing a http client
…ory class which better describes its purpose
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new HTTPClient protocol to make RestApiRepository work with pluggable HTTP client implementations, shifts the repository constructor to prefer a new client parameter (with session deprecated), updates internal request call sites to use self.client, and bumps the package version to 0.7.0 with accompanying documentation updates.
Changes:
- Added
HTTPClientprotocol and documentation page for it. - Refactored
RestApiRepositoryto accept aclientparameter and route HTTP calls throughself.client. - Bumped package version to
0.7.0and updated changelog + docs index.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Updates locked package version to 0.7.0. |
| src/alpha/repositories/rest_api_repository.py | Introduces client parameter, switches HTTP calls to self.client, and adjusts response-handling type hints. |
| src/alpha/interfaces/http_client.py | Adds HTTPClient protocol for pluggable HTTP client implementations. |
| pyproject.toml | Bumps project version to 0.7.0. |
| docs/reference/interfaces/index.md | Links to the new HTTPClient interface docs page. |
| docs/reference/interfaces/http_client.md | Adds the reference page for the HTTPClient protocol. |
| CHANGELOG.md | Documents the new interface and deprecation of session. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 introduces a new
HTTPClientinterface to provide a flexible, pluggable way to handle HTTP requests in theRestApiRepository. TheRestApiRepositoryclass is updated to use a newclientparameter (replacing the oldersessionparameter, which is now deprecated), and all HTTP operations now use this interface. Documentation and type hints are updated accordingly, and the package version is bumped to reflect these significant changes.Key changes:
HTTP Client Abstraction
HTTPClientinterface (as aProtocol) insrc/alpha/interfaces/http_client.py, defining the expected methods and attributes for HTTP clients. This allows using different HTTP libraries (likerequests,httpx, or custom implementations) interchangeably with the repository.RestApiRepositoryto accept aclientparameter of typeHTTPClient, deprecating the oldsessionparameter. All internal HTTP calls now useself.client. [1] [2] [3] [4] [5] [6] [7]RestApiRepositoryto reflect the newclientparameter and the deprecation ofsession.API and Type Consistency
RestApiRepositoryto consistently returndict[str, Any] | None, improving type safety and clarity. [1] [2] [3] [4]Documentation
HTTPClientinterface (docs/reference/interfaces/http_client.md) and linked it from the interfaces index. [1] [2]session, and the recommendation to useclientgoing forward.Versioning
0.7.0inpyproject.tomlto indicate a backward-incompatible change.