Skip to content

Commit 26026fa

Browse files
committed
Please pylint
1 parent 92f9841 commit 26026fa

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/bedrock_utils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def __iter__(self):
7575
raise
7676

7777
def _process_event(self, event):
78+
# pylint: disable=too-many-branches
7879
if "messageStart" in event:
7980
# {'messageStart': {'role': 'assistant'}}
8081
if event["messageStart"].get("role") == "assistant":
@@ -214,6 +215,7 @@ def _process_amazon_titan_chunk(self, chunk):
214215
self._stream_done_callback(self._response)
215216

216217
def _process_amazon_nova_chunk(self, chunk):
218+
# pylint: disable=too-many-branches
217219
# TODO: handle tool calls!
218220
if "messageStart" in chunk:
219221
# {'messageStart': {'role': 'assistant'}}
@@ -262,7 +264,7 @@ def _process_amazon_nova_chunk(self, chunk):
262264
return
263265

264266
def _process_anthropic_claude_chunk(self, chunk):
265-
# pylint: disable=too-many-return-statements
267+
# pylint: disable=too-many-return-statements,too-many-branches
266268
if not (message_type := chunk.get("type")):
267269
return
268270

@@ -343,10 +345,10 @@ def genai_capture_message_content() -> bool:
343345

344346
def extract_tool_calls(
345347
message: dict[str, Any], capture_content: bool
346-
) -> Sequence[Dict[str, Any]]:
348+
) -> Sequence[Dict[str, Any]] | None:
347349
content = message.get("content")
348350
if not content:
349-
return
351+
return None
350352

351353
tool_uses = [item["toolUse"] for item in content if "toolUse" in item]
352354
if not tool_uses:
@@ -358,7 +360,7 @@ def extract_tool_calls(
358360
tool_id_key = "toolUseId"
359361

360362
if not tool_uses:
361-
return
363+
return None
362364

363365
tool_calls = []
364366
for tool_use in tool_uses:

instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_bedrock.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ def test_converse_with_content_different_events(
154154
def converse_tool_call(
155155
span_exporter, log_exporter, bedrock_runtime_client, expect_content
156156
):
157+
# pylint:disable=too-many-locals
157158
messages = [
158159
{
159160
"role": "user",
@@ -648,6 +649,7 @@ def _rebuild_stream_message(response):
648649
def converse_stream_tool_call(
649650
span_exporter, log_exporter, bedrock_runtime_client, expect_content
650651
):
652+
# pylint:disable=too-many-locals,too-many-statements
651653
messages = [
652654
{
653655
"role": "user",
@@ -1294,6 +1296,7 @@ def invoke_model_tool_call(
12941296
llm_model_value,
12951297
expect_content,
12961298
):
1299+
# pylint:disable=too-many-locals,too-many-statements
12971300
messages = [
12981301
{
12991302
"role": "user",
@@ -1862,6 +1865,7 @@ def invoke_model_with_response_stream_tool_call(
18621865
llm_model_value,
18631866
expect_content,
18641867
):
1868+
# pylint:disable=too-many-locals,too-many-statements,too-many-branches
18651869
messages = [
18661870
{
18671871
"role": "user",

0 commit comments

Comments
 (0)