fix: extract tuple file arrays in multipart uploads - #1881
Open
jstar0 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Multipart file extraction accepts a sequence of file tuples, but tuple arrays can be silently skipped because the generic sequence branch only recognizes individual file-like values. This change normalizes tuple entries before the generic file-content path so tuple arrays are extracted consistently for both sync and async uploads.
The change also preserves tuple deepcopy isolation for nested extraction. Existing filename and content-type handling remains unchanged.
Testing
uv run pytest tests/test_extract_files.py tests/test_files.py -q- 29 passed.uv run ruff check src/anthropic/_files.py src/anthropic/_utils/_utils.py tests/test_extract_files.py tests/test_files.py- passed.uv run ruff format --check src/anthropic/_files.py src/anthropic/_utils/_utils.py tests/test_extract_files.py tests/test_files.py- passed.uv run pyright src/anthropic/_files.py src/anthropic/_utils/_utils.py tests/test_extract_files.py tests/test_files.py- 0 errors, 0 warnings, 0 informations.git diff --check origin/main...HEAD- passed.The repository
scripts/lintruff and dependency-cap stages passed. Its full-repository pyright stage still reports existing optional-extra/provider typing and missing-import errors outside the changed files; the changed-file pyright run above is the relevant type evidence for this patch. No network calls or live credentials are required for the regression.The submitted commit is SSH-signed and GitHub exposes the required verified signature on the exact head.
Compatibility
This is backward compatible. It changes only which already-supported tuple-array inputs are extracted for multipart uploads; existing individual file values, filenames, content types, and async behavior retain their prior contracts.