Skip to content

Commit d9c6f40

Browse files
yashwantbezawadaRobertCraigie
authored andcommitted
fix: use posix paths in file collection for cross-platform compatibility
On Windows, str(Path) produces backslash-separated paths which the API rejects. Use .as_posix() to ensure forward slashes on all platforms. Fixes #1051
1 parent 19eceac commit d9c6f40

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/anthropic/lib/_files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def _collect_files(directory: Path, relative_to: Path, files: list[FileTypes]) -
2222
_collect_files(path, relative_to, files)
2323
continue
2424

25-
files.append((str(path.relative_to(relative_to)), path.read_bytes()))
25+
files.append((path.relative_to(relative_to).as_posix(), path.read_bytes()))
2626

2727

2828
async def async_files_from_dir(directory: str | os.PathLike[str]) -> list[FileTypes]:
@@ -39,4 +39,4 @@ async def _async_collect_files(directory: anyio.Path, relative_to: anyio.Path, f
3939
await _async_collect_files(path, relative_to, files)
4040
continue
4141

42-
files.append((str(path.relative_to(relative_to)), await path.read_bytes()))
42+
files.append((path.relative_to(relative_to).as_posix(), await path.read_bytes()))

0 commit comments

Comments
 (0)