Fix lint and test

This commit is contained in:
Dickson Tsai
2025-07-19 20:04:58 -07:00
parent b57e05afa5
commit 8e652d7d87
4 changed files with 14 additions and 11 deletions

View File

@@ -3,8 +3,8 @@
```bash
# Lint and style
# Check for issues and fix automatically
python -m ruff check src/ test/ --fix
python -m ruff format src/ test/
python -m ruff check src/ tests/ --fix
python -m ruff format src/ tests/
# Typecheck (only done for src/)
python -m mypy src/

View File

@@ -296,12 +296,9 @@ class SubprocessCLITransport(Transport):
yield data
except GeneratorExit:
return
except json.JSONDecodeError as e:
logger.warning(
f"Failed to parse JSON from CLI output: {e}. Buffer content: {json_buffer[:200]}..."
)
# Clear buffer to avoid repeated parse attempts on malformed data
json_buffer = ""
except json.JSONDecodeError:
# Don't clear buffer - we might be in the middle of a split JSON message
# The buffer will be cleared when we successfully parse or hit size limit
continue
except anyio.ClosedResourceError:

View File

@@ -98,7 +98,9 @@ class ClaudeSDKClient:
self._transport: Any | None = None
os.environ["CLAUDE_CODE_ENTRYPOINT"] = "sdk-py-client"
async def connect(self, prompt: str | AsyncIterable[dict[str, Any]] | None = None) -> None:
async def connect(
self, prompt: str | AsyncIterable[dict[str, Any]] | None = None
) -> None:
"""Connect to Claude with a prompt or message stream."""
from ._internal.transport.subprocess_cli import SubprocessCLITransport
@@ -128,7 +130,9 @@ class ClaudeSDKClient:
if message:
yield message
async def query(self, prompt: str | AsyncIterable[dict[str, Any]], session_id: str = "default") -> None:
async def query(
self, prompt: str | AsyncIterable[dict[str, Any]], session_id: str = "default"
) -> None:
"""
Send a new request in streaming mode.

View File

@@ -9,7 +9,9 @@ from .types import ClaudeCodeOptions, Message
async def query(
*, prompt: str | AsyncIterable[dict[str, Any]], options: ClaudeCodeOptions | None = None
*,
prompt: str | AsyncIterable[dict[str, Any]],
options: ClaudeCodeOptions | None = None,
) -> AsyncIterator[Message]:
"""
Query Claude Code for one-shot or unidirectional streaming interactions.