Skip to content

Commit 9ae16b0

Browse files
authored
chore: format files with ruff 0.9 (#1360)
1 parent 5eb41e9 commit 9ae16b0

File tree

14 files changed

+63
-61
lines changed

14 files changed

+63
-61
lines changed

livekit-agents/livekit/agents/ipc/job_thread_executor.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ async def initialize(self) -> None:
140140
channel.arecv_message(self._pch, proto.IPC_MESSAGES),
141141
timeout=self._opts.initialize_timeout,
142142
)
143-
assert isinstance(
144-
init_res, proto.InitializeResponse
145-
), "first message must be InitializeResponse"
143+
assert isinstance(init_res, proto.InitializeResponse), (
144+
"first message must be InitializeResponse"
145+
)
146146
except asyncio.TimeoutError:
147147
self._initialize_fut.set_exception(
148148
asyncio.TimeoutError("runner initialization timed out")

livekit-agents/livekit/agents/ipc/proc_client.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ def initialize(self) -> None:
5353
cch = aio.duplex_unix._Duplex.open(self._mp_cch)
5454
first_req = recv_message(cch, IPC_MESSAGES)
5555

56-
assert isinstance(
57-
first_req, InitializeRequest
58-
), "first message must be proto.InitializeRequest"
56+
assert isinstance(first_req, InitializeRequest), (
57+
"first message must be proto.InitializeRequest"
58+
)
5959

6060
self._init_req = first_req
6161
self._initialize_fnc(self._init_req, self)

livekit-agents/livekit/agents/ipc/supervised_proc.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ async def initialize(self) -> None:
165165
channel.arecv_message(self._pch, proto.IPC_MESSAGES),
166166
timeout=self._opts.initialize_timeout,
167167
)
168-
assert isinstance(
169-
init_res, proto.InitializeResponse
170-
), "first message must be InitializeResponse"
168+
assert isinstance(init_res, proto.InitializeResponse), (
169+
"first message must be InitializeResponse"
170+
)
171171
except asyncio.TimeoutError:
172172
self._initialize_fut.set_exception(
173173
asyncio.TimeoutError("process initialization timed out")

livekit-agents/livekit/agents/pipeline/pipeline_agent.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -889,9 +889,9 @@ async def _execute_function_calls() -> None:
889889
return
890890

891891
assert isinstance(speech_handle.source, LLMStream)
892-
assert (
893-
not user_question or speech_handle.user_committed
894-
), "user speech should have been committed before using tools"
892+
assert not user_question or speech_handle.user_committed, (
893+
"user speech should have been committed before using tools"
894+
)
895895

896896
llm_stream = speech_handle.source
897897

@@ -1040,9 +1040,9 @@ def _synthesize_agent_speech(
10401040
speech_id: str,
10411041
source: str | LLMStream | AsyncIterable[str],
10421042
) -> SynthesisHandle:
1043-
assert (
1044-
self._agent_output is not None
1045-
), "agent output should be initialized when ready"
1043+
assert self._agent_output is not None, (
1044+
"agent output should be initialized when ready"
1045+
)
10461046

10471047
tk = SpeechDataContextVar.set(SpeechData(speech_id))
10481048

livekit-agents/livekit/agents/stt/stt.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ async def _metrics_monitor_task(
248248

249249
async for ev in event_aiter:
250250
if ev.type == SpeechEventType.RECOGNITION_USAGE:
251-
assert (
252-
ev.recognition_usage is not None
253-
), "recognition_usage must be provided for RECOGNITION_USAGE event"
251+
assert ev.recognition_usage is not None, (
252+
"recognition_usage must be provided for RECOGNITION_USAGE event"
253+
)
254254

255255
duration = time.perf_counter() - start_time
256256
stt_metrics = STTMetrics(

livekit-plugins/livekit-plugins-llama-index/livekit/plugins/llama_index/llm.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ async def _run(self) -> None:
7474
"The last message in the chat context must be from the user"
7575
)
7676

77-
assert isinstance(
78-
user_msg.content, str
79-
), "user message content must be a string"
77+
assert isinstance(user_msg.content, str), (
78+
"user message content must be a string"
79+
)
8080

8181
try:
8282
if not self._stream:

livekit-plugins/livekit-plugins-silero/livekit/plugins/silero/vad.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ async def entrypoint(ctx: JobContext):
8686
8787
8888
if __name__ == "__main__":
89-
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint, prewarm_fnc=prewarm))
89+
cli.run_app(
90+
WorkerOptions(entrypoint_fnc=entrypoint, prewarm_fnc=prewarm)
91+
)
9092
```
9193
9294
Args:

livekit-plugins/livekit-plugins-turn-detector/livekit/plugins/turn_detector/eou.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ async def predict_end_of_turn(
193193
timeout=timeout,
194194
)
195195

196-
assert (
197-
result is not None
198-
), "end_of_utterance prediction should always returns a result"
196+
assert result is not None, (
197+
"end_of_utterance prediction should always returns a result"
198+
)
199199

200200
result_json = json.loads(result.decode())
201201
return result_json["eou_probability"]

tests/test_create_func.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ def test_fn(
1616
pass
1717

1818
fnc_ctx = TestFunctionContext()
19-
assert (
20-
"test_function" in fnc_ctx.ai_functions
21-
), "Function should be registered in ai_functions"
19+
assert "test_function" in fnc_ctx.ai_functions, (
20+
"Function should be registered in ai_functions"
21+
)
2222

2323
fnc_info = fnc_ctx.ai_functions["test_function"]
2424
build_info = _oai_api.build_oai_function_description(fnc_info)
@@ -69,9 +69,9 @@ def test_fn(self):
6969
pass
7070

7171
fnc_ctx = TestFunctionContext()
72-
assert (
73-
"test_fn" in fnc_ctx.ai_functions
74-
), "Function should be registered in ai_functions"
72+
assert "test_fn" in fnc_ctx.ai_functions, (
73+
"Function should be registered in ai_functions"
74+
)
7575

7676
assert fnc_ctx.ai_functions["test_fn"].description == "A simple test function"
7777

@@ -92,9 +92,9 @@ def optional_fn(
9292
pass
9393

9494
fnc_ctx = TestFunctionContext()
95-
assert (
96-
"optional_function" in fnc_ctx.ai_functions
97-
), "Function should be registered in ai_functions"
95+
assert "optional_function" in fnc_ctx.ai_functions, (
96+
"Function should be registered in ai_functions"
97+
)
9898

9999
fnc_info = fnc_ctx.ai_functions["optional_function"]
100100
build_info = _oai_api.build_oai_function_description(fnc_info)
@@ -159,9 +159,9 @@ def list_fn(
159159
pass
160160

161161
fnc_ctx = TestFunctionContext()
162-
assert (
163-
"list_function" in fnc_ctx.ai_functions
164-
), "Function should be registered in ai_functions"
162+
assert "list_function" in fnc_ctx.ai_functions, (
163+
"Function should be registered in ai_functions"
164+
)
165165

166166
fnc_info = fnc_ctx.ai_functions["list_function"]
167167
build_info = _oai_api.build_oai_function_description(fnc_info)
@@ -202,9 +202,9 @@ def enum_fn(
202202
pass
203203

204204
fnc_ctx = TestFunctionContext()
205-
assert (
206-
"enum_function" in fnc_ctx.ai_functions
207-
), "Function should be registered in ai_functions"
205+
assert "enum_function" in fnc_ctx.ai_functions, (
206+
"Function should be registered in ai_functions"
207+
)
208208

209209
fnc_info = fnc_ctx.ai_functions["enum_function"]
210210
build_info = _oai_api.build_oai_function_description(fnc_info)

tests/test_ipc.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,9 @@ async def test_shutdown_no_job():
354354

355355
assert proc.exitcode == 0
356356
assert not proc.killed
357-
assert (
358-
start_args.shutdown_counter.value == 0
359-
), "shutdown_cb isn't called when there is no job"
357+
assert start_args.shutdown_counter.value == 0, (
358+
"shutdown_cb isn't called when there is no job"
359+
)
360360

361361

362362
async def test_job_slow_shutdown():

tests/test_llm.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ async def test_cancelled_calls(llm_factory: Callable[[], llm.LLM]):
194194
await stream.aclose()
195195

196196
assert len(calls) == 1
197-
assert isinstance(
198-
calls[0].exception, asyncio.CancelledError
199-
), "toggle_light should have been cancelled"
197+
assert isinstance(calls[0].exception, asyncio.CancelledError), (
198+
"toggle_light should have been cancelled"
199+
)
200200

201201

202202
@pytest.mark.parametrize("llm_factory", LLMS)
@@ -219,9 +219,9 @@ async def test_calls_arrays(llm_factory: Callable[[], llm.LLM]):
219219
call = calls[0]
220220
currencies = call.call_info.arguments["currencies"]
221221
assert len(currencies) == 3, "select_currencies should have 3 currencies"
222-
assert (
223-
"eur" in currencies and "gbp" in currencies and "sek" in currencies
224-
), "select_currencies should have eur, gbp, sek"
222+
assert "eur" in currencies and "gbp" in currencies and "sek" in currencies, (
223+
"select_currencies should have eur, gbp, sek"
224+
)
225225

226226

227227
@pytest.mark.parametrize("llm_factory", LLMS)
@@ -341,9 +341,9 @@ async def test_tool_choice_options(
341341
if tool_choice == "none" and isinstance(input_llm, anthropic.LLM):
342342
assert True
343343
else:
344-
assert (
345-
call_names == expected_calls
346-
), f"Test '{description}' failed: Expected calls {expected_calls}, but got {call_names}"
344+
assert call_names == expected_calls, (
345+
f"Test '{description}' failed: Expected calls {expected_calls}, but got {call_names}"
346+
)
347347

348348

349349
async def _request_fnc_call(

tests/test_message_change.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ def test_find_longest_increasing_subsequence(indices, expected_seq, desc):
4343
assert result[0] == 0, f"First index not included in {desc}"
4444

4545
# Verify sequence matches expected
46-
assert (
47-
result_seq == expected_seq
48-
), f"Wrong sequence in {desc}: expected {expected_seq}, got {result_seq}"
46+
assert result_seq == expected_seq, (
47+
f"Wrong sequence in {desc}: expected {expected_seq}, got {result_seq}"
48+
)
4949

5050

5151
@pytest.mark.parametrize(

tests/test_stt.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ async def _stream_output():
9999

100100
async for event in stream:
101101
if event.type == agents.stt.SpeechEventType.START_OF_SPEECH:
102-
assert (
103-
recv_end
104-
), "START_OF_SPEECH recv but no END_OF_SPEECH has been sent before"
102+
assert recv_end, (
103+
"START_OF_SPEECH recv but no END_OF_SPEECH has been sent before"
104+
)
105105
assert not recv_start
106106
recv_end = False
107107
recv_start = True

tests/test_tts.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ async def _assert_valid_synthesized_audio(
3737

3838
merged_frame = merge_frames(frames)
3939
assert merged_frame.sample_rate == tts.sample_rate, "sample rate should be the same"
40-
assert (
41-
merged_frame.num_channels == tts.num_channels
42-
), "num channels should be the same"
40+
assert merged_frame.num_channels == tts.num_channels, (
41+
"num channels should be the same"
42+
)
4343

4444

4545
SYNTHESIZE_TTS: list[Callable[[], tts.TTS]] = [

0 commit comments

Comments
 (0)