Commit graph

15 commits

Author SHA1 Message Date
Lina Tawfik
343ec4812c
Merge pull request #42 from RomainGehrig/fix/cwd-not-exists
Some checks failed
Test / test (3.13) (push) Has been cancelled
Lint / lint (push) Has been cancelled
Test / test (3.10) (push) Has been cancelled
Test / test (3.11) (push) Has been cancelled
Test / test (3.12) (push) Has been cancelled
Explicit error if the cwd does not exist
2025-07-05 14:29:03 -07:00
Lina Tawfik
67193350e2
Remove implementation-specific test
The test was checking source code for specific strings rather than
testing behavior. The existing subprocess tests already verify the
functionality works correctly.
2025-07-01 15:23:55 -07:00
Lina Tawfik
9ef9da9ab6
Fix linting issues 2025-07-01 15:12:26 -07:00
Romain Gehrig
d336a22ab4
Explicit error if the cwd does not exist
Previously was raised as a CLINotFoundError
2025-07-01 16:33:30 +02:00
Lina Tawfik
404c50bce0
Fix FastAPI SSE streaming compatibility (fixes #4)
Remove anyio.create_task_group() from receive_messages() to fix the
RuntimeError "Attempted to exit cancel scope in a different task than
it was entered in" when using the SDK with FastAPI's SSE streaming.

The issue occurred because FastAPI can move async generators between
different asyncio tasks during the streaming lifecycle, which conflicts
with anyio's cancel scope tracking.

Changes:
- Remove task group usage from receive_messages()
- Read stderr sequentially after stdout completes
- Add test to ensure no task groups are used
- Fix existing test expectation for buffer overflow

This is a minimal fix that maintains compatibility while solving the
core issue. The trade-off is that stderr is read after stdout instead
of concurrently, but this is unlikely to cause issues in practice.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-01 00:04:50 -07:00
Lina Tawfik
1791031d20
chore: Remove obvious comments from code
Removed redundant comments that simply restate what the code is doing.
Kept only comments that provide valuable context or explain complex behavior.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-30 22:27:48 -07:00
Lina Tawfik
977bf6438b
style: apply ruff formatting 2025-06-30 21:58:37 -07:00
Lina Tawfik
24295417ac
fix: handle JSON messages split across multiple stream reads
Adds buffering to accumulate incomplete JSON messages that are split
across multiple stream reads due to asyncio's 64KB default buffer limit.

- Implement 1MB buffer to accumulate partial JSON
- Clear buffer on successful parse or size limit exceeded
- Add comprehensive tests for split JSON scenarios

Fixes CLIJSONDecodeError when reading large minified JSON files.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-30 21:55:06 -07:00
Lina Tawfik
7610791803
Apply ruff formatting
- Fixed quotes to use double quotes consistently
- Adjusted line breaks per ruff formatter rules
- No functional changes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-27 15:08:20 -07:00
Lina Tawfik
ecad93a0c0
Apply ruff linting fixes
- Fixed formatting in test_subprocess_buffering.py
- No functional changes, only code style improvements

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-27 15:06:28 -07:00
Lina Tawfik
3f25c3bb83
Fix test to use anyio.run() pattern and add edge case tests
- Convert async test to use anyio.run() pattern consistent with other tests
- Remove unused CLIJSONDecodeError import
- Add tests for JSON with embedded newlines
- Add tests for multiple newlines between objects
- All tests passing

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-27 15:06:28 -07:00
Bradley-Butcher
87e2699f6a
fix multi-line buffering issue
Signed-off-by: Bradley-Butcher <brad@phoebe.ai>
2025-06-19 11:39:44 +01:00
Lina Tawfik
b3448f4baa
Fix tests to match updated ResultMessage type
- Remove cost_usd field from test expectations
- Update to use total_cost_usd instead of total_cost
- All 30 tests now pass

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-17 16:51:28 -07:00
Lina Tawfik
63ef121e18
Fix code formatting for CI 2025-06-12 00:20:28 -07:00
Lina Tawfik
6ca3514261
Initial Python SDK import 2025-06-12 00:16:19 -07:00