Skip to content

Commit 8796e2d

Browse files
dicksontsairushilpatel0
authored andcommitted
Fix types
Signed-off-by: Rushil Patel <[email protected]>
1 parent 5ffc20f commit 8796e2d

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/claude_code_sdk/_internal/transport/subprocess_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(
4343
self._stdout_stream: TextReceiveStream | None = None
4444
self._stderr_stream: TextReceiveStream | None = None
4545
self._stdin_stream: TextSendStream | None = None
46-
self._pending_control_responses: dict[str, Any] = {}
46+
self._pending_control_responses: dict[str, dict[str, Any]] = {}
4747
self._request_counter = 0
4848
self._close_stdin_after_prompt = close_stdin_after_prompt
4949

src/claude_code_sdk/client.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import os
44
from collections.abc import AsyncIterable, AsyncIterator
5+
from typing import Any
56

67
from ._errors import CLIConnectionError
78
from .types import ClaudeCodeOptions, Message, ResultMessage
@@ -94,19 +95,20 @@ def __init__(self, options: ClaudeCodeOptions | None = None):
9495
if options is None:
9596
options = ClaudeCodeOptions()
9697
self.options = options
97-
self._transport = None
98+
self._transport: Any | None = None
9899
os.environ["CLAUDE_CODE_ENTRYPOINT"] = "sdk-py-client"
99100

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

104105
# Auto-connect with empty async iterable if no prompt is provided
105-
async def _empty_stream():
106+
async def _empty_stream() -> AsyncIterator[dict[str, Any]]:
106107
# Never yields, but indicates that this function is an iterator and
107108
# keeps the connection open.
108-
if False:
109-
yield
109+
# This yield is never reached but makes this an async generator
110+
return
111+
yield {} # type: ignore[unreachable]
110112

111113
self._transport = SubprocessCLITransport(
112114
prompt=_empty_stream() if prompt is None else prompt,
@@ -190,12 +192,12 @@ async def disconnect(self) -> None:
190192
await self._transport.disconnect()
191193
self._transport = None
192194

193-
async def __aenter__(self):
195+
async def __aenter__(self) -> "ClaudeSDKClient":
194196
"""Enter async context - automatically connects with empty stream for interactive use."""
195197
await self.connect()
196198
return self
197199

198-
async def __aexit__(self, exc_type, exc_val, exc_tb):
200+
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool:
199201
"""Exit async context - always disconnects."""
200202
await self.disconnect()
201203
return False

src/claude_code_sdk/query.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
import os
44
from collections.abc import AsyncIterable, AsyncIterator
5+
from typing import Any
56

67
from ._internal.client import InternalClient
78
from .types import ClaudeCodeOptions, Message
89

910

1011
async def query(
11-
*, prompt: str | AsyncIterable[dict], options: ClaudeCodeOptions | None = None
12+
*, prompt: str | AsyncIterable[dict[str, Any]], options: ClaudeCodeOptions | None = None
1213
) -> AsyncIterator[Message]:
1314
"""
1415
Query Claude Code for one-shot or unidirectional streaming interactions.

0 commit comments

Comments
 (0)