mirror of
https://github.com/anthropics/claude-agent-sdk-python.git
synced 2025-10-06 01:00:03 +03:00
Fix lint and test
This commit is contained in:
@@ -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/
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user