Skip to content

chore: regenerate Python SDK with typed query params, response models, datetime, hoisted nested types - #7

Closed
calvin-archastro wants to merge 1 commit into
mainfrom
feat/typed-sdk-regen
Closed

chore: regenerate Python SDK with typed query params, response models, datetime, hoisted nested types#7
calvin-archastro wants to merge 1 commit into
mainfrom
feat/typed-sdk-regen

Conversation

@calvin-archastro

Copy link
Copy Markdown
Contributor

Summary

Regenerated the SDK against the four Python typing improvements in ArchAstro/archastro-openapi#14. Held as a draft until that PR merges and a generator release ships (0.1.6) — at which point I'll re-run `./scripts/regenerate_sdk.sh` from a clean state so the diff is reproducible from npm.

What changes

Inputs (TypedDicts): every nested inline object now has a real type. ACL grants, profile pictures, thread attributes, etc. used to be `dict[str, object] | None` — now they're concrete classes:

```python
class TeamCreateInputAclAddItem(TypedDict, total=False):
actions: Required[list[str]]
principal: str | None
principal_type: Required[str]

class TeamCreateInputAcl(TypedDict, total=False):
add: list[TeamCreateInputAclAddItem] | None
remove: list[TeamCreateInputAclRemoveItem] | None

class TeamCreateInput(TypedDict, total=False):
name: Required[str]
acl: TeamCreateInputAcl | None
metadata: dict[str, object] | None # genuinely freeform — kept as-is
```

Responses (Pydantic models): ~30 ops that returned `dict[str, object]` because their response was inline now produce typed models. Callers go from `result["data"][0]["name"]` (untyped) to `result.data[0].name` (full IDE help).

Query params: drop `**params` for typed kw-only args.

```python

before

async def list(self, **params) -> dict[str, object]: ...

after

async def list(
self, *, page: int | None = None, page_size: int | None = None
) -> TeamListResponse: ...
```

The call site builds the query dict conditionally, so `None` kwargs never hit the wire as `?key=null`.

Datetime fields: every `created_at` / `updated_at` / etc. across `types/*.py` is now `datetime | None` instead of `str | None`. Pydantic v2 already auto-parsed the ISO strings at runtime, so behavior is unchanged — only the static types get more accurate.

Verified

  • `uv run pytest tests/test_http_client.py src/archastro/phx_channel/tests/test_unit.py tests/harness` — 51/51
  • `uv run pytest tests/contract` — 670/670 (REST contract)
  • `ARCHASTRO_RUN_CHANNEL_CONTRACT_TESTS=1 uv run pytest tests/contract/channels` — 51/51
  • `uv run ruff check && uv run ruff format --check` — clean
  • `uv build` → working `archastro_sdk-0.1.0-py3-none-any.whl`
  • Total: 772/772 passing

Quantified improvements

Surface Before After
Resource methods using `**params` 30 0
Resource methods returning `dict[str, object]` (inline schema) 31 0
`datetime` fields typed as `str` dozens 0
Nested inline objects collapsed to `dict[str, object]` dozens 0 (only true freeform metadata bags)

Blocked on

  • archastro-openapi#14 merges
  • `Release` workflow dispatched for sdk-generator → 0.1.6 publishes to npm

Once those land, I'll regen from clean and mark this PR ready for review.

🤖 Generated with Claude Code

…, datetime, and hoisted nested types

Picks up the four typing improvements landing in
ArchAstro/archastro-openapi#14:

  - `format: date-time` fields are typed as `datetime` (ruff
    rewrites the post-emit `Optional[datetime]` to `datetime | None`).
  - Resource methods drop `**params` for typed kw-only query args
    (`page: int | None = None`, etc.); the call site builds a
    `query: dict[str, object] = {}` so `None` kwargs never hit the
    wire as `?key=null`.
  - Inline-object response schemas produce sibling
    `{ResourceShort}{Op}Response` Pydantic models, replacing every
    `dict[str, object]` return for ops whose response shape was
    described in the spec.
  - Nested inline objects in inputs / response models / channel
    payloads are hoisted as named sibling types (`{Parent}{FieldPascal}`,
    `…Item` for arrays, `…Value` for maps). Empty objects keep
    `dict[str, object]` (genuine freeform metadata bags).

Net effect across the SDK: zero `**params` and zero `dict[str, object]`
returns from inline schemas remain; deeply-nested shapes like ACL
grants and pagination wrappers are now fully typed.

Verified: 51 unit + harness, 670 REST contract, 51 channel contract
= 772 tests passing. ruff clean. `uv build` produces a working wheel.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@calvin-archastro
calvin-archastro marked this pull request as ready for review April 25, 2026 20:55
@archastro

archastro Bot commented Apr 25, 2026

Copy link
Copy Markdown

Reviewed 445cda5. No findings.

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.

1 participant