Skip to content

Commit 5dd4952

Browse files
test lint
1 parent 3f8d10f commit 5dd4952

File tree

12 files changed

+271
-268
lines changed

12 files changed

+271
-268
lines changed

instrumentation-genai/opentelemetry-instrumentation-langchain/examples/manual/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,9 @@ def embedding_invocation_demo():
261261
mixed_vectors = embeddings.embed_documents(mixed_texts)
262262
print(f" ✓ Embedded {len(mixed_vectors)} mixed content texts")
263263
for i, text in enumerate(mixed_texts):
264-
print(f" - Text {i+1}: {text[:40]}... → {len(mixed_vectors[i])}D vector")
264+
print(
265+
f" - Text {i + 1}: {text[:40]}... → {len(mixed_vectors[i])}D vector"
266+
)
265267
except Exception as e:
266268
print(f" ✗ Error: {e}")
267269

instrumentation-genai/opentelemetry-instrumentation-langchain/tests/test_callback_handler_agent.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ def get_entity(self, run_id):
129129

130130

131131
@pytest.fixture(name="handler_with_stub")
132-
def _handler_with_stub_fixture() -> (
133-
Tuple[LangchainCallbackHandler, _StubTelemetryHandler]
134-
):
132+
def _handler_with_stub_fixture() -> Tuple[
133+
LangchainCallbackHandler, _StubTelemetryHandler
134+
]:
135135
stub = _StubTelemetryHandler()
136136
handler = LangchainCallbackHandler(telemetry_handler=stub)
137137
return handler, stub
@@ -389,9 +389,9 @@ def _invoke_with_env(env_value: Optional[str]):
389389
invocation_default = _invoke_with_env(None)
390390
invocation_traceloop = _invoke_with_env("traceloop_compat")
391391

392-
assert (
393-
invocation_default.attributes == invocation_traceloop.attributes
394-
), "Emitter env toggle should not change recorded attributes"
392+
assert invocation_default.attributes == invocation_traceloop.attributes, (
393+
"Emitter env toggle should not change recorded attributes"
394+
)
395395

396396
attrs = invocation_default.attributes
397397
assert invocation_default.request_model == "gpt-5-nano"

util/opentelemetry-util-genai-traceloop-translator/tests/test_agent_task_message_reconstruction.py

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ def test_agent_span_reconstructs_messages(self, setup_tracer_with_handler):
110110
provider.force_flush()
111111

112112
# Verify that messages were cached (indicating reconstruction happened)
113-
assert (
114-
span_id in processor._message_cache
115-
), "Messages should be cached for agent span"
113+
assert span_id in processor._message_cache, (
114+
"Messages should be cached for agent span"
115+
)
116116

117117
cached_input, cached_output = processor._message_cache[span_id]
118118

@@ -122,31 +122,31 @@ def test_agent_span_reconstructs_messages(self, setup_tracer_with_handler):
122122

123123
# Verify input message format
124124
input_msg = cached_input[0]
125-
assert isinstance(
126-
input_msg, InputMessage
127-
), "Should be InputMessage object"
125+
assert isinstance(input_msg, InputMessage), (
126+
"Should be InputMessage object"
127+
)
128128
assert input_msg.role == "user", "Should have user role"
129129
assert len(input_msg.parts) == 1, "Should have 1 part"
130-
assert isinstance(
131-
input_msg.parts[0], Text
132-
), "Part should be Text object"
133-
assert (
134-
input_msg.parts[0].content == "Plan a trip to Paris"
135-
), "Input content should match"
130+
assert isinstance(input_msg.parts[0], Text), (
131+
"Part should be Text object"
132+
)
133+
assert input_msg.parts[0].content == "Plan a trip to Paris", (
134+
"Input content should match"
135+
)
136136

137137
# Verify output message format
138138
output_msg = cached_output[0]
139-
assert isinstance(
140-
output_msg, OutputMessage
141-
), "Should be OutputMessage object"
139+
assert isinstance(output_msg, OutputMessage), (
140+
"Should be OutputMessage object"
141+
)
142142
assert output_msg.role == "assistant", "Should have assistant role"
143143
assert len(output_msg.parts) == 1, "Should have 1 part"
144-
assert isinstance(
145-
output_msg.parts[0], Text
146-
), "Part should be Text object"
147-
assert (
148-
"Paris" in output_msg.parts[0].content
149-
), "Output should mention Paris"
144+
assert isinstance(output_msg.parts[0], Text), (
145+
"Part should be Text object"
146+
)
147+
assert "Paris" in output_msg.parts[0].content, (
148+
"Output should mention Paris"
149+
)
150150

151151
def test_agent_span_has_genai_attributes(self, setup_tracer_with_handler):
152152
"""Test that agent spans get gen_ai.input.messages and gen_ai.output.messages."""
@@ -176,18 +176,18 @@ def test_agent_span_has_genai_attributes(self, setup_tracer_with_handler):
176176
assert agent_span.attributes is not None, "Span should have attributes"
177177

178178
# Verify gen_ai attributes are present
179-
assert (
180-
"gen_ai.input.messages" in agent_span.attributes
181-
), "Should have gen_ai.input.messages"
182-
assert (
183-
"gen_ai.output.messages" in agent_span.attributes
184-
), "Should have gen_ai.output.messages"
185-
assert (
186-
"gen_ai.span.kind" in agent_span.attributes
187-
), "Should have gen_ai.span.kind"
188-
assert (
189-
agent_span.attributes["gen_ai.span.kind"] == "agent"
190-
), "Should preserve agent kind"
179+
assert "gen_ai.input.messages" in agent_span.attributes, (
180+
"Should have gen_ai.input.messages"
181+
)
182+
assert "gen_ai.output.messages" in agent_span.attributes, (
183+
"Should have gen_ai.output.messages"
184+
)
185+
assert "gen_ai.span.kind" in agent_span.attributes, (
186+
"Should have gen_ai.span.kind"
187+
)
188+
assert agent_span.attributes["gen_ai.span.kind"] == "agent", (
189+
"Should preserve agent kind"
190+
)
191191

192192

193193
class TestTaskMessageReconstruction:
@@ -232,9 +232,9 @@ def test_task_span_reconstructs_messages(self, setup_tracer_with_handler):
232232
provider.force_flush()
233233

234234
# Verify that messages were cached (indicating reconstruction happened)
235-
assert (
236-
span_id in processor._message_cache
237-
), "Messages should be cached for task span"
235+
assert span_id in processor._message_cache, (
236+
"Messages should be cached for task span"
237+
)
238238

239239
cached_input, cached_output = processor._message_cache[span_id]
240240

@@ -247,9 +247,9 @@ def test_task_span_reconstructs_messages(self, setup_tracer_with_handler):
247247
cached_input[0].parts[0].content
248248
== "Search for flights from Seattle to Paris"
249249
), "Input should match"
250-
assert (
251-
"5 flights" in cached_output[0].parts[0].content
252-
), "Output should mention flights"
250+
assert "5 flights" in cached_output[0].parts[0].content, (
251+
"Output should mention flights"
252+
)
253253

254254
def test_task_span_without_messages_skips_reconstruction(
255255
self, setup_tracer_with_handler
@@ -267,9 +267,9 @@ def test_task_span_without_messages_skips_reconstruction(
267267
provider.force_flush()
268268

269269
# Should not crash, and span_id should NOT be in cache
270-
assert (
271-
span_id not in processor._message_cache
272-
), "Empty task should not be cached"
270+
assert span_id not in processor._message_cache, (
271+
"Empty task should not be cached"
272+
)
273273

274274

275275
class TestLLMOperationMessageReconstruction:
@@ -298,9 +298,9 @@ def test_chat_operation_reconstructs_messages(
298298
provider.force_flush()
299299

300300
# Verify messages were cached
301-
assert (
302-
span_id in processor._message_cache
303-
), "Messages should be cached for chat operation"
301+
assert span_id in processor._message_cache, (
302+
"Messages should be cached for chat operation"
303+
)
304304

305305
cached_input, cached_output = processor._message_cache[span_id]
306306
assert len(cached_input) == 1, "Should have 1 input message"
@@ -328,9 +328,9 @@ def test_completion_operation_reconstructs_messages(
328328

329329
provider.force_flush()
330330

331-
assert (
332-
span_id in processor._message_cache
333-
), "Messages should be cached for completion operation"
331+
assert span_id in processor._message_cache, (
332+
"Messages should be cached for completion operation"
333+
)
334334

335335

336336
class TestNonLLMSpanSkipsReconstruction:
@@ -351,9 +351,9 @@ def test_workflow_span_skips_reconstruction(
351351
provider.force_flush()
352352

353353
# Workflow spans should NOT trigger message reconstruction
354-
assert (
355-
span_id not in processor._message_cache
356-
), "Workflow spans should not cache messages"
354+
assert span_id not in processor._message_cache, (
355+
"Workflow spans should not cache messages"
356+
)
357357

358358
def test_tool_span_skips_reconstruction(self, setup_tracer_with_handler):
359359
"""Test that tool spans skip message reconstruction."""
@@ -367,9 +367,9 @@ def test_tool_span_skips_reconstruction(self, setup_tracer_with_handler):
367367
provider.force_flush()
368368

369369
# Tool spans should NOT trigger message reconstruction
370-
assert (
371-
span_id not in processor._message_cache
372-
), "Tool spans should not cache messages"
370+
assert span_id not in processor._message_cache, (
371+
"Tool spans should not cache messages"
372+
)
373373

374374
def test_unknown_span_skips_reconstruction(
375375
self, setup_tracer_with_handler
@@ -384,9 +384,9 @@ def test_unknown_span_skips_reconstruction(
384384
provider.force_flush()
385385

386386
# Random spans should NOT trigger message reconstruction
387-
assert (
388-
span_id not in processor._message_cache
389-
), "Unknown spans should not cache messages"
387+
assert span_id not in processor._message_cache, (
388+
"Unknown spans should not cache messages"
389+
)
390390

391391

392392
class TestEdgeCases:
@@ -407,9 +407,9 @@ def test_agent_with_malformed_json(self, setup_tracer_with_handler):
407407
provider.force_flush()
408408

409409
# Malformed data should not be cached
410-
assert (
411-
span_id not in processor._message_cache
412-
), "Malformed JSON should not be cached"
410+
assert span_id not in processor._message_cache, (
411+
"Malformed JSON should not be cached"
412+
)
413413

414414
def test_task_with_empty_messages(self, setup_tracer_with_handler):
415415
"""Test that task with empty message arrays is handled."""
@@ -431,12 +431,12 @@ def test_task_with_empty_messages(self, setup_tracer_with_handler):
431431
# Empty messages should still be cached (as empty lists)
432432
if span_id in processor._message_cache:
433433
cached_input, cached_output = processor._message_cache[span_id]
434-
assert (
435-
cached_input == []
436-
), "Empty input should be cached as empty list"
437-
assert (
438-
cached_output == []
439-
), "Empty output should be cached as empty list"
434+
assert cached_input == [], (
435+
"Empty input should be cached as empty list"
436+
)
437+
assert cached_output == [], (
438+
"Empty output should be cached as empty list"
439+
)
440440

441441
def test_mixed_span_kinds(self, setup_tracer_with_handler):
442442
"""Test different span kinds in same workflow."""
@@ -473,15 +473,15 @@ def test_mixed_span_kinds(self, setup_tracer_with_handler):
473473
provider.force_flush()
474474

475475
# Verify caching behavior
476-
assert (
477-
span_ids["agent"] in processor._message_cache
478-
), "Agent span should cache messages"
479-
assert (
480-
span_ids["task"] in processor._message_cache
481-
), "Task span should cache messages"
482-
assert (
483-
span_ids["workflow"] not in processor._message_cache
484-
), "Workflow span should not cache messages"
476+
assert span_ids["agent"] in processor._message_cache, (
477+
"Agent span should cache messages"
478+
)
479+
assert span_ids["task"] in processor._message_cache, (
480+
"Task span should cache messages"
481+
)
482+
assert span_ids["workflow"] not in processor._message_cache, (
483+
"Workflow span should not cache messages"
484+
)
485485

486486

487487
if __name__ == "__main__":

util/opentelemetry-util-genai-traceloop-translator/tests/test_args_wrapper_format.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,22 @@ def test_args_wrapper_with_messages(self):
5757
assert len(result) == 1, f"Should have 1 message, got {len(result)}"
5858

5959
message = result[0]
60-
assert (
61-
message["role"] == "user"
62-
), f"Role should be 'user', got {message['role']}"
63-
assert (
64-
len(message["parts"]) == 1
65-
), f"Should have 1 part, got {len(message['parts'])}"
60+
assert message["role"] == "user", (
61+
f"Role should be 'user', got {message['role']}"
62+
)
63+
assert len(message["parts"]) == 1, (
64+
f"Should have 1 part, got {len(message['parts'])}"
65+
)
6666

6767
part = message["parts"][0]
68-
assert (
69-
part["type"] == "text"
70-
), f"Part type should be 'text', got {part['type']}"
68+
assert part["type"] == "text", (
69+
f"Part type should be 'text', got {part['type']}"
70+
)
7171
assert "Paris" in part["content"], "Content should mention Paris"
7272
assert "Seattle" in part["content"], "Content should mention Seattle"
73-
assert (
74-
"boutique hotel" in part["content"]
75-
), "Content should mention boutique hotel"
73+
assert "boutique hotel" in part["content"], (
74+
"Content should mention boutique hotel"
75+
)
7676

7777
def test_args_wrapper_with_multiple_messages(self):
7878
"""Test args wrapper with conversation history."""

0 commit comments

Comments
 (0)