Skip to content

🏗️ Architect: Strongly typed HTTPClientBase and model cleanup#723

Merged
fderuiter merged 3 commits intomainfrom
architect/refactor-http-client-and-models-14087093377179307493
Mar 2, 2026
Merged

🏗️ Architect: Strongly typed HTTPClientBase and model cleanup#723
fderuiter merged 3 commits intomainfrom
architect/refactor-http-client-and-models-14087093377179307493

Conversation

@fderuiter
Copy link
Owner

This PR addresses technical debt within the core HTTP client wrapper and multiple JSON models by strictly enforcing SOLID typing mechanics and code cleanliness.

🏗️ Design Change

Migrated the generic wrapper HTTPClientBase from a mixed loosely-typed structure to explicit Generic bounds. The subclasses Client and AsyncClient are now directly associated with httpx.Client/SyncRequestExecutor and httpx.AsyncClient/AsyncRequestExecutor respectively.

♻️ DRY Gains

Dropped multiple runtime cast(httpx.Response) and cast(Awaitable) operations in the base HTTP layer, relying entirely on compile-time type inference. Extinguished several useless pass lines from existing models.

🛡️ Solidity

Strictly separates the underlying HTTP engine context between synchronous and async flow via Generic[ClientT, ExecutorT].

⚠️ Breaking Changes

None. The external interface definitions remain completely functional with exactly equivalent runtime footprints.


PR created automatically by Jules for task 14087093377179307493 started by @fderuiter

- Refactored `HTTPClientBase` to inherit from `Generic[ClientT, ExecutorT]`, eliminating the weakly typed `HTTPX_CLIENT_CLS` property.
- Explicitly defined strict type boundaries for `Client` and `AsyncClient` by overriding generic class methods.
- Removed arbitrary `cast()` usages across synchronous and asynchronous `get`/`post` request chains.
- Removed redundant and unused `pass` statements from several JSON models to improve codebase cleanliness and cohesion (`users.py`, `studies.py`, `base.py`).

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

fderuiter and others added 2 commits February 28, 2026 16:20
- Refactored `HTTPClientBase` to inherit from `Generic[ClientT, ExecutorT]`, eliminating the weakly typed `HTTPX_CLIENT_CLS` property.
- Explicitly defined strict type boundaries for `Client` and `AsyncClient` by overriding generic class methods.
- Removed arbitrary `cast()` usages across synchronous and asynchronous `get`/`post` request chains.
- Removed redundant and unused `pass` statements from several JSON models to improve codebase cleanliness and cohesion (`users.py`, `studies.py`, `base.py`).
- Ran `isort` and `black` to ensure formatting passes CI tests.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
- Removed `Awaitable`, `cast`, and `BaseRequestExecutor` from `async_client.py`.
- Removed `cast` and `BaseRequestExecutor` from `client.py`.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@fderuiter fderuiter marked this pull request as ready for review March 2, 2026 15:38
Copilot AI review requested due to automatic review settings March 2, 2026 15:38
@fderuiter fderuiter merged commit 386dba4 into main Mar 2, 2026
13 checks passed
@fderuiter fderuiter deleted the architect/refactor-http-client-and-models-14087093377179307493 branch March 2, 2026 15:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces technical debt in the SDK’s HTTP layer by introducing a strongly-typed, generic HTTPClientBase that cleanly separates sync vs async client/executor wiring, and performs minor cleanup across several JSON models.

Changes:

  • Refactors HTTPClientBase to be Generic[ClientT, ExecutorT] and moves httpx client-class selection to _get_client_class().
  • Updates Client and AsyncClient to bind HTTPClientBase to httpx.Client/SyncRequestExecutor and httpx.AsyncClient/AsyncRequestExecutor, removing redundant cast() usage in request methods.
  • Removes no-op pass statements from multiple model classes.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/imednet/core/http_client_base.py Introduces generics and abstracts client-class selection for stricter typing across sync/async implementations.
src/imednet/core/client.py Specializes the base client for sync httpx usage and simplifies request return typing.
src/imednet/core/async_client.py Specializes the base client for async httpx usage and simplifies awaited request return typing.
src/imednet/models/base.py Removes redundant pass statements from model definitions.
src/imednet/models/studies.py Removes redundant pass statement from the Study model.
src/imednet/models/users.py Removes redundant pass statements from Role and User models.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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