Read PathLike inside (name, content) file tuples - #1788
Draft
kilanassah wants to merge 1 commit into
Draft
Conversation
`_transform_file` checked `is_file_content` before `is_tuple_t`, but `is_file_content` returns True for any tuple. A `(name, Path)` tuple therefore matched the file-content branch, was not itself a PathLike, and was returned unchanged — leaving the Path for httpx to call `.read()` on, raising `AttributeError: 'WindowsPath' object has no attribute 'read'`. Check `is_tuple_t` first so the tuple's inner content is read via `read_file_content`. Applies to both sync and async transforms. Adds regression tests covering a (name, Path) tuple. Fixes anthropics#1769
kilanassah
force-pushed
the
fix/1769-pathlike-in-file-tuple
branch
from
July 30, 2026 05:59
1aba085 to
dda4491
Compare
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.
Fixes #1769.
Check tuple inputs before generic
FileContentinputs in_transform_file(and the async version).Pathis valid file content, but the current check order returns a(filename, Path)tuple without reading the inner path, so httpx later calls.read()on it and raisesAttributeError.Adds sync and async regression tests for filename +
Pathtuples.