Skip to content

Commit bce29e4

Browse files
dicksontsairushilpatel0
authored andcommitted
Fix lint and test
Signed-off-by: Rushil Patel <[email protected]>
1 parent ccdb272 commit bce29e4

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
```bash
44
# Lint and style
55
# Check for issues and fix automatically
6-
python -m ruff check src/ test/ --fix
7-
python -m ruff format src/ test/
6+
python -m ruff check src/ tests/ --fix
7+
python -m ruff format src/ tests/
88

99
# Typecheck (only done for src/)
1010
python -m mypy src/

src/claude_code_sdk/_internal/transport/subprocess_cli.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,9 @@ async def receive_messages(self) -> AsyncIterator[dict[str, Any]]:
306306
yield data
307307
except GeneratorExit:
308308
return
309-
except json.JSONDecodeError as e:
310-
logger.warning(
311-
f"Failed to parse JSON from CLI output: {e}. Buffer content: {json_buffer[:200]}..."
312-
)
313-
# Clear buffer to avoid repeated parse attempts on malformed data
314-
json_buffer = ""
309+
except json.JSONDecodeError:
310+
# Don't clear buffer - we might be in the middle of a split JSON message
311+
# The buffer will be cleared when we successfully parse or hit size limit
315312
continue
316313

317314
except anyio.ClosedResourceError:

src/claude_code_sdk/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ def __init__(self, options: ClaudeCodeOptions | None = None):
9898
self._transport: Any | None = None
9999
os.environ["CLAUDE_CODE_ENTRYPOINT"] = "sdk-py-client"
100100

101-
async def connect(self, prompt: str | AsyncIterable[dict[str, Any]] | None = None) -> None:
101+
async def connect(
102+
self, prompt: str | AsyncIterable[dict[str, Any]] | None = None
103+
) -> None:
102104
"""Connect to Claude with a prompt or message stream."""
103105
from ._internal.transport.subprocess_cli import SubprocessCLITransport
104106

@@ -128,7 +130,9 @@ async def receive_messages(self) -> AsyncIterator[Message]:
128130
if message:
129131
yield message
130132

131-
async def query(self, prompt: str | AsyncIterable[dict[str, Any]], session_id: str = "default") -> None:
133+
async def query(
134+
self, prompt: str | AsyncIterable[dict[str, Any]], session_id: str = "default"
135+
) -> None:
132136
"""
133137
Send a new request in streaming mode.
134138

src/claude_code_sdk/query.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010

1111
async def query(
12-
*, prompt: str | AsyncIterable[dict[str, Any]], options: ClaudeCodeOptions | None = None
12+
*,
13+
prompt: str | AsyncIterable[dict[str, Any]],
14+
options: ClaudeCodeOptions | None = None,
1315
) -> AsyncIterator[Message]:
1416
"""
1517
Query Claude Code for one-shot or unidirectional streaming interactions.

0 commit comments

Comments
 (0)