Skip to content

Conversation

@drgroot
Copy link
Member

@drgroot drgroot commented May 24, 2025

No description provided.

@drgroot drgroot enabled auto-merge May 24, 2025 12:24
@drgroot drgroot requested a review from Copilot May 24, 2025 12:26
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 introduces a reusable utility for finding a specific Middleware type in a list and refactors existing code to use it, while updating component type hints.

  • Adds findType in servc/util.py to locate a middleware instance by its class.
  • Refactors HTTP blob component lookup in blob.py to use findType.
  • Updates _components type annotations from List[type[Middleware]] to List[Middleware] in HTTP classes.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
servc/util.py Add generic findType helper for Middleware lookup
servc/svc/com/http/blob.py Replace manual blob lookup with findType and import adjustment
servc/svc/com/http/init.py Change _components annotation to List[Middleware]
Comments suppressed due to low confidence (5)

servc/util.py:8

  • Function names should follow PEP8 snake_case; consider renaming findType to find_type.
def findType(c: List[Middleware], type: type[T]) -> T:

servc/util.py:8

  • Avoid shadowing the built-in type; rename this parameter to something like middleware_type for clarity.
def findType(c: List[Middleware], type: type[T]) -> T:

servc/util.py:11

  • Improve the error message by using middleware_type.__name__ to display the class name, e.g., f"Middleware {middleware_type.__name__} not found".
raise ValueError(f"Middleware {type} not found")

servc/util.py:1

  • The new findType utility lacks unit tests; add tests covering successful lookups and the error case.
from typing import List, TypeVar

servc/svc/com/http/blob.py:45

  • BlobStorage is not imported in this module, which will cause a NameError. Please add the correct import for BlobStorage.
self._blobStorage = findType(components, BlobStorage)

@drgroot drgroot merged commit d5c9fab into main May 24, 2025
23 checks passed
@drgroot drgroot deleted the feature/blob branch May 24, 2025 12:29
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