Skip to content

Types: KalshiClient.from_env(**kwargs: object) leaks Any-equivalent typing into a public constructor #266

Closed

Description

@TexasCoding

Summary

On a mypy --strict SDK that ships py.typed, the from_env entry point silently accepts arbitrary kwargs with arbitrary types — typos like time_out=10 aren't caught, and IDE completions on KalshiClient.from_env(...) give no signature help. The required # type: ignore[arg-type] internally is the smell.

Location

  • kalshi/client.py:126-144
  • kalshi/async_client.py:157-176

Evidence

@classmethod
def from_env(cls, **kwargs: object) -> KalshiClient:
    ...
    client = cls(auth=auth, demo=demo, base_url=base_url, **kwargs)  # type: ignore[arg-type]

README and docs/* show callers passing transport=RecordingTransport(...), timeout=, max_retries=, config=, etc. through this surface.

Recommended fix

Either spell out the forwarded kwargs explicitly (key_id/private_key/auth/config/demo/base_url/timeout/max_retries/transport) or expose a typing.Unpack-style TypedDict (ClientInitKwargs) so callers and mypy both get the real signature. The # type: ignore[arg-type] then drops.

Severity & category

medium / api-design

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions