Skip to content

Type resource client params via TYPE_CHECKING instead of Any #18

Description

@MitulShah1

All resource __init__ methods type the client as Any:

class Completions:
    def __init__(self, client: Any) -> None:

This loses type safety on self._client._request(...) across every resource (completions, embeddings, images, models, admin).

What to do

Use TYPE_CHECKING imports to type the client as FerroClient (sync) / AsyncFerroClient (async) without circular imports:

from typing import TYPE_CHECKING
if TYPE_CHECKING:
    from ferrolabsai.client import FerroClient

class Completions:
    def __init__(self, client: "FerroClient") -> None: ...

There is currently no TYPE_CHECKING usage in the package, so this establishes the pattern repo-wide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttypingType annotations / mypy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions