Skip to content

Audit response models for consistent extra= policy #114

Description

@TexasCoding

Spotted during code review of PR #112.

Order (kalshi/models/orders.py) has no model_config, so it falls back to Pydantic's default (extra="ignore"). Several sibling response models explicitly set extra="allow". The result is inconsistent forwards-compatibility behavior when the Kalshi API adds a new field:

  • Models with extra="allow" silently accept and expose the new field via __pydantic_extra__.
  • Models with the implicit extra="ignore" silently drop the new field.
  • Models with explicit extra="forbid" (request bodies, per the v0.8.0+ convention) hard-fail — correct, since these are user-built.

The desired policy for response models is probably one of:

  1. extra="allow" everywhere (forwards-compatible by default; matches the majority pattern).
  2. extra="ignore" everywhere (current Pydantic default; matches Order).

This issue is to:

  1. Survey every response model in kalshi/models/ and list which extra= policy each uses.
  2. Pick a single policy.
  3. Apply it uniformly. Add a test that asserts the chosen policy for every model in kalshi.models.__all__ minus the request bodies.

Out of scope: request bodies, which must stay extra="forbid" per CLAUDE.md / v0.8.0+ convention.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpolishCode-quality and DX improvements; non-functional

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions