Skip to content

docs: note TypedDict runtime dict behavior in types.py#664

Open
kvr06-ai wants to merge 1 commit intoanthropics:mainfrom
kvr06-ai:docs/623-typeddict-runtime-behavior
Open

docs: note TypedDict runtime dict behavior in types.py#664
kvr06-ai wants to merge 1 commit intoanthropics:mainfrom
kvr06-ai:docs/623-typeddict-runtime-behavior

Conversation

@kvr06-ai
Copy link

Summary

Fixes #623

TypedDict classes in types.py are plain dict objects at runtime, but this wasn't documented. Since the same file mixes @dataclass and TypedDict, users (and LLMs writing integration code) naturally try config.budget_tokens instead of config["budget_tokens"] and hit AttributeError.

This PR adds:

  • A module-level note explaining the two type categories and their access patterns
  • Per-class "Note: This is a TypedDict" reminders on the user-facing classes that lacked them (ThinkingConfig*, McpStdioServerConfig, McpSSEServerConfig, McpHttpServerConfig, SandboxNetworkConfig, SandboxSettings, AsyncHookJSONOutput, SyncHookJSONOutput)

Changes

  • src/claude_agent_sdk/types.py: Expanded module docstring, added/updated docstrings on 10 TypedDict classes

Testing

  • Docs-only change (no behavior change). Verified ruff check passes.

TypedDict instances are plain dicts at runtime, but the existing
docstrings don't warn about this. Adds a module-level note and
per-class reminders to prevent AttributeError from dot-access.
@kvr06-ai
Copy link
Author

@qing-ant Would you mind taking a look? Small docs-only change to types.py, adding TypedDict runtime behavior notes per #623.

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.

docs: ThinkingConfig, SyncHookJSONOutput and other TypedDicts behave as plain dicts at runtime — not documented

1 participant