Skip to content

Claude/explore python sdk hg3 zy#1283

Open
gmy77 wants to merge 2 commits intoanthropics:mainfrom
gmy77:claude/explore-python-sdk-hg3ZY
Open

Claude/explore python sdk hg3 zy#1283
gmy77 wants to merge 2 commits intoanthropics:mainfrom
gmy77:claude/explore-python-sdk-hg3ZY

Conversation

@gmy77
Copy link
Copy Markdown

@gmy77 gmy77 commented Mar 23, 2026

No description provided.

claude added 2 commits March 23, 2026 14:34
…et serialization

- _transform.py: `_async_transform_recursive` was calling the *sync*
  `_transform_recursive` when the annotated type was `Dict[str, T]`.
  This meant type aliases inside the dict values were never applied in
  the async path. Fixed by awaiting `_async_transform_recursive` instead.

- _utils.py: `required_args` built the list of missing arguments from a
  `set` subtraction, producing a non-deterministic error message across
  Python runs. Changed to `sorted(...)` so the message is always stable.

- _utils.py: `json_safe` now converts `set` and `frozenset` to a sorted
  list so they can be serialised to JSON without raising a TypeError.

- _utils.py: clarify `deepcopy_minimal` docstring — tuples are
  intentionally not copied because they are immutable containers.

- _compat.py: `ConfigDict` under Pydantic v1 was silently set to `None`.
  It now raises a clear `RuntimeError` if instantiated, pointing users
  towards upgrading to Pydantic v2.

Tests added for all of the above changes.

https://claude.ai/code/session_01CqXN7tjqqv1rCwTMkEmbFb
…k, and more

Bug fixes:
- _files.py: fix missing f-prefix on f-string in async_to_httpx_files error message
- _streaming.py: narrow broad `except Exception` to `except json.JSONDecodeError`
  when parsing error body from SSE, preventing accidental swallowing of errors
- _qs.py: raise NotImplementedError for unknown nested_format values
  (resolves existing TODO comment)

Streaming improvements:
- lib/streaming/_messages.py: add index bounds validation for content_block_start
  and content_block_delta events; align input_json_delta error handling with beta
- lib/streaming/_beta_messages.py: add same index bounds validation

New feature — on_retry callback:
- _base_client.py: add `RetryInfo` dataclass (attempt, max_retries, url,
  wait_seconds, response, error) and `on_retry` callback parameter to BaseClient,
  SyncAPIClient, and AsyncAPIClient; callback is invoked before each retry sleep
- _client.py: thread `on_retry` through Anthropic and AsyncAnthropic constructors
  and copy() / with_options() methods
- __init__.py: export RetryInfo in public API

Tests:
- tests/test_qs.py: add test_unknown_nested_format

https://claude.ai/code/session_01CqXN7tjqqv1rCwTMkEmbFb
@gmy77 gmy77 requested a review from a team as a code owner March 23, 2026 15:18
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.

2 participants