Skip to content

Commit 8e652d7

Browse files
committed
Fix lint and test
1 parent b57e05a commit 8e652d7

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

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
@@ -296,12 +296,9 @@ async def receive_messages(self) -> AsyncIterator[dict[str, Any]]:
296296
yield data
297297
except GeneratorExit:
298298
return
299-
except json.JSONDecodeError as e:
300-
logger.warning(
301-
f"Failed to parse JSON from CLI output: {e}. Buffer content: {json_buffer[:200]}..."
302-
)
303-
# Clear buffer to avoid repeated parse attempts on malformed data
304-
json_buffer = ""
299+
except json.JSONDecodeError:
300+
# Don't clear buffer - we might be in the middle of a split JSON message
301+
# The buffer will be cleared when we successfully parse or hit size limit
305302
continue
306303

307304
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)