Skip to content

Commit 6301535

Browse files
fix: ruff format client.py and session.py
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent bd9ec8c commit 6301535

2 files changed

Lines changed: 27 additions & 22 deletions

File tree

python/copilot/client.py

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -686,10 +686,12 @@ class CopilotClient:
686686
>>> await client.start()
687687
>>>
688688
>>> # Create a session and send a message
689-
>>> session = await client.create_session({
690-
... "on_permission_request": PermissionHandler.approve_all,
691-
... "model": "gpt-4",
692-
... })
689+
>>> session = await client.create_session(
690+
... {
691+
... "on_permission_request": PermissionHandler.approve_all,
692+
... "model": "gpt-4",
693+
... }
694+
... )
693695
>>> session.on(lambda event: print(event.type))
694696
>>> await session.send("Hello!")
695697
>>>
@@ -728,10 +730,12 @@ def __init__(
728730
>>> client = CopilotClient(ExternalServerConfig(url="localhost:3000"))
729731
>>>
730732
>>> # Custom CLI path with specific log level
731-
>>> client = CopilotClient(SubprocessConfig(
732-
... cli_path="/usr/local/bin/copilot",
733-
... log_level="debug",
734-
... ))
733+
>>> client = CopilotClient(
734+
... SubprocessConfig(
735+
... cli_path="/usr/local/bin/copilot",
736+
... log_level="debug",
737+
... )
738+
... )
735739
"""
736740
if config is None:
737741
config = SubprocessConfig()
@@ -1033,11 +1037,13 @@ async def create_session(self, config: SessionConfig) -> CopilotSession:
10331037
>>> session = await client.create_session(config)
10341038
>>>
10351039
>>> # Session with model and streaming
1036-
>>> session = await client.create_session({
1037-
... "on_permission_request": PermissionHandler.approve_all,
1038-
... "model": "gpt-4",
1039-
... "streaming": True
1040-
... })
1040+
>>> session = await client.create_session(
1041+
... {
1042+
... "on_permission_request": PermissionHandler.approve_all,
1043+
... "model": "gpt-4",
1044+
... "streaming": True,
1045+
... }
1046+
... )
10411047
"""
10421048
if not self._client:
10431049
if self._auto_start:
@@ -1230,10 +1236,13 @@ async def resume_session(self, session_id: str, config: ResumeSessionConfig) ->
12301236
>>> session = await client.resume_session("session-123", config)
12311237
>>>
12321238
>>> # Resume with new tools
1233-
>>> session = await client.resume_session("session-123", {
1234-
... "on_permission_request": PermissionHandler.approve_all,
1235-
... "tools": [my_new_tool]
1236-
... })
1239+
>>> session = await client.resume_session(
1240+
... "session-123",
1241+
... {
1242+
... "on_permission_request": PermissionHandler.approve_all,
1243+
... "tools": [my_new_tool],
1244+
... },
1245+
... )
12371246
"""
12381247
if not self._client:
12391248
if self._auto_start:

python/copilot/session.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -757,9 +757,7 @@ def on(self, handler: Callable[[SessionEvent], None]) -> Callable[[], None]:
757757
... print(f"Assistant: {event.data.content}")
758758
... elif event.type == "session.error":
759759
... print(f"Error: {event.data.message}")
760-
...
761760
>>> unsubscribe = session.on(handle_event)
762-
...
763761
>>> # Later, to stop receiving events:
764762
>>> unsubscribe()
765763
"""
@@ -1242,9 +1240,7 @@ async def abort(self) -> None:
12421240
>>> import asyncio
12431241
>>>
12441242
>>> # Start a long-running request
1245-
>>> task = asyncio.create_task(
1246-
... session.send("Write a very long story...")
1247-
... )
1243+
>>> task = asyncio.create_task(session.send("Write a very long story..."))
12481244
>>>
12491245
>>> # Abort after 5 seconds
12501246
>>> await asyncio.sleep(5)

0 commit comments

Comments
 (0)