What happened?
A bare Path works as an upload, but the tuple form accepted by FileTypes does not:
from pathlib import Path
client.sessions.uploads.create(
"session-id",
file=("custom.md", Path("README.md"), "text/markdown"),
)
On current main at 5f5274b, this raises:
APIConnectionError: Connection error.
The underlying cause is:
AttributeError: 'PosixPath' object has no attribute 'read'
The same path is shared by certificate, extension, and session uploads.
Why it happens
is_file_content() treats every tuple as terminal file content. That means _transform_file() returns the tuple unchanged before its tuple-handling branch can read the PathLike value inside it. HTTPX later receives the raw Path and tries to call .read() on it.
Expected behavior
A PathLike inside any supported upload tuple should be read just like a bare Path, while preserving the custom filename, content type, and optional headers.
I have a small fix ready that keeps tuples separate from direct file content and adds sync and async coverage for all three supported tuple shapes.
What happened?
A bare
Pathworks as an upload, but the tuple form accepted byFileTypesdoes not:On current main at
5f5274b, this raises:The underlying cause is:
The same path is shared by certificate, extension, and session uploads.
Why it happens
is_file_content()treats every tuple as terminal file content. That means_transform_file()returns the tuple unchanged before its tuple-handling branch can read thePathLikevalue inside it. HTTPX later receives the rawPathand tries to call.read()on it.Expected behavior
A
PathLikeinside any supported upload tuple should be read just like a barePath, while preserving the custom filename, content type, and optional headers.I have a small fix ready that keeps tuples separate from direct file content and adds sync and async coverage for all three supported tuple shapes.