Skip to content

Commit 9adbb37

Browse files
committed
Reformat with ruff.
1 parent dbfcbe2 commit 9adbb37

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

instrumentation-genai/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/tool_call_wrapper.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def _to_otel_value(python_value):
5050
if isinstance(python_value, list):
5151
return [_to_otel_value(x) for x in python_value]
5252
if isinstance(python_value, dict):
53-
return {key:_to_otel_value(val) for (key, val) in python_value.items()}
53+
return {
54+
key: _to_otel_value(val) for (key, val) in python_value.items()
55+
}
5456
if hasattr(python_value, "model_dump"):
5557
return python_value.model_dump()
5658
if hasattr(python_value, "__dict__"):
@@ -235,7 +237,10 @@ def wrapped(
235237
wrapped(item, otel_wrapper, **kwargs) for item in tool_or_tools
236238
]
237239
if isinstance(tool_or_tools, dict):
238-
return {key: wrapped(value, otel_wrapper, **kwargs) for (key, value) in tool_or_tools.items()}
240+
return {
241+
key: wrapped(value, otel_wrapper, **kwargs)
242+
for (key, value) in tool_or_tools.items()
243+
}
239244
if callable(tool_or_tools):
240245
return _wrap_tool_function(tool_or_tools, otel_wrapper, **kwargs)
241246
return tool_or_tools

instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/generate_content/test_tool_call_instrumentation.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ def somefunction(someparam, otherparam=2):
114114
generated_span.attributes["code.function.params.someparam"], "123"
115115
)
116116
self.assertEqual(
117-
generated_span.attributes["code.function.params.otherparam"], "'abc'"
117+
generated_span.attributes["code.function.params.otherparam"],
118+
"'abc'",
118119
)
119120

120121
def test_tool_calls_do_not_record_parameter_values_if_not_enabled(self):
@@ -145,8 +146,12 @@ def somefunction(someparam, otherparam=2):
145146
wrapped_somefunction(123, otherparam="abc")
146147
self.otel.assert_has_span_named("tool_call somefunction")
147148
generated_span = self.otel.get_span_named("tool_call somefunction")
148-
self.assertNotIn("code.function.params.someparam", generated_span.attributes)
149-
self.assertNotIn("code.function.params.otherparam", generated_span.attributes)
149+
self.assertNotIn(
150+
"code.function.params.someparam", generated_span.attributes
151+
)
152+
self.assertNotIn(
153+
"code.function.params.otherparam", generated_span.attributes
154+
)
150155

151156
def test_tool_calls_record_return_values_on_span_if_enabled(self):
152157
os.environ["OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT"] = (

instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/utils/test_tool_call_wrapper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ def somefunction():
9595
def otherfunction():
9696
pass
9797

98-
wrapped_functions = self.wrap({"somefunction": somefunction, "otherfunction": otherfunction})
98+
wrapped_functions = self.wrap(
99+
{"somefunction": somefunction, "otherfunction": otherfunction}
100+
)
99101
wrapped_somefunction = wrapped_functions["somefunction"]
100102
wrapped_otherfunction = wrapped_functions["otherfunction"]
101103
self.otel.assert_does_not_have_span_named("tool_call somefunction")

0 commit comments

Comments
 (0)