Skip to content

Commit 07401b0

Browse files
committed
Fix lint error
Change-Id: I5fa1e061f3a49c1f2defdb2884c2ac3fde4ab4d7 Co-developed-by: Cursor <noreply@cursor.com>
1 parent 18b37fc commit 07401b0

File tree

12 files changed

+257
-259
lines changed

12 files changed

+257
-259
lines changed

util/opentelemetry-util-genai/src/opentelemetry/util/genai/_multimodal_processing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self, ...):
7777
OutputMessage,
7878
Uri,
7979
)
80-
from opentelemetry.util.genai.utils import (
80+
from opentelemetry.util.genai.utils import ( # pylint: disable=no-name-in-module
8181
gen_ai_json_dumps,
8282
get_content_capturing_mode,
8383
get_multimodal_upload_mode,
@@ -750,7 +750,7 @@ def _get_uploader_and_pre_uploader( # pylint: disable=no-self-use
750750
Note: Keep as instance method for consistency with other methods in this mixin
751751
"""
752752
try:
753-
from opentelemetry.util.genai._multimodal_upload import ( # pylint: disable=import-outside-toplevel # noqa: PLC0415
753+
from opentelemetry.util.genai._multimodal_upload import ( # pylint: disable=import-outside-toplevel,no-name-in-module # noqa: PLC0415
754754
get_or_load_uploader_pair,
755755
)
756756

util/opentelemetry-util-genai/src/opentelemetry/util/genai/_multimodal_upload/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Uploader,
2323
UploadItem,
2424
)
25-
from opentelemetry.util.genai._multimodal_upload.multimodal_upload_hook import (
25+
from opentelemetry.util.genai._multimodal_upload.multimodal_upload_hook import ( # pylint: disable=no-name-in-module
2626
get_or_load_pre_uploader,
2727
get_or_load_uploader,
2828
get_or_load_uploader_pair,

util/opentelemetry-util-genai/src/opentelemetry/util/genai/_multimodal_upload/multimodal_upload_hook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import Any, Optional, Protocol, runtime_checkable
66

77
from opentelemetry.util._once import Once
8-
from opentelemetry.util.genai.utils import (
8+
from opentelemetry.util.genai.utils import ( # pylint: disable=no-name-in-module
99
get_multimodal_pre_uploader_hook_name,
1010
get_multimodal_upload_mode,
1111
get_multimodal_uploader_hook_name,

util/opentelemetry-util-genai/src/opentelemetry/util/genai/_multimodal_upload/pre_uploader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_STORAGE_BASE_PATH,
5555
)
5656
from opentelemetry.util.genai.types import Base64Blob, Blob, Modality, Uri
57-
from opentelemetry.util.genai.utils import (
57+
from opentelemetry.util.genai.utils import ( # pylint: disable=no-name-in-module
5858
get_multimodal_allowed_root_paths,
5959
get_multimodal_storage_base_path,
6060
is_multimodal_audio_conversion_enabled,

util/opentelemetry-util-genai/src/opentelemetry/util/genai/extended_handler.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def __init__(
143143

144144
# Initialize multimodal processing (from Mixin)
145145
self._init_multimodal()
146-
self.__class__._ensure_multimodal_shutdown_atexit_registered()
146+
self.__class__._ensure_multimodal_shutdown_atexit_registered() # pylint: disable=no-member
147147

148148
# ==================== Metrics Helper ====================
149149

@@ -192,7 +192,7 @@ def stop_llm(self, invocation: LLMInvocation) -> LLMInvocation:
192192
invocation.monotonic_end_s = timeit.default_timer()
193193

194194
# Try async multimodal processing
195-
if self.process_multimodal_stop(invocation, method="stop_llm"):
195+
if self.process_multimodal_stop(invocation, method="stop_llm"): # pylint: disable=unexpected-keyword-arg
196196
return invocation
197197

198198
# No multimodal: use parent's sync path
@@ -212,7 +212,7 @@ def fail_llm(
212212
invocation.monotonic_end_s = timeit.default_timer()
213213

214214
# Try async multimodal processing
215-
if self.process_multimodal_fail(invocation, error, method="fail_llm"):
215+
if self.process_multimodal_fail(invocation, error, method="fail_llm"): # pylint: disable=unexpected-keyword-arg
216216
return invocation
217217

218218
# No multimodal: use parent's sync path
@@ -462,7 +462,7 @@ def stop_invoke_agent(
462462
invocation.monotonic_end_s = timeit.default_timer()
463463

464464
# Try async multimodal processing
465-
if self.process_multimodal_stop(invocation, method="stop_agent"):
465+
if self.process_multimodal_stop(invocation, method="stop_agent"): # pylint: disable=unexpected-keyword-arg
466466
return invocation
467467

468468
# No multimodal: sync path
@@ -487,7 +487,7 @@ def fail_invoke_agent( # pylint: disable=no-self-use
487487
invocation.monotonic_end_s = timeit.default_timer()
488488

489489
# Try async multimodal processing
490-
if self.process_multimodal_fail(
490+
if self.process_multimodal_fail( # pylint: disable=unexpected-keyword-arg
491491
invocation, error, method="fail_agent"
492492
):
493493
return invocation

util/opentelemetry-util-genai/src/opentelemetry/util/genai/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
from typing_extensions import TypeAlias
2323

24-
from opentelemetry.context import Context
24+
from opentelemetry.context import Context # pylint: disable=unused-import
2525
from opentelemetry.semconv._incubating.attributes import (
2626
gen_ai_attributes as GenAI,
2727
)

util/opentelemetry-util-genai/src/opentelemetry/util/genai/utils.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import json
1616
import logging
1717
import os
18-
import re
18+
import re # LoongSuite Extension
1919
from base64 import b64encode
2020
from functools import partial
2121
from typing import Any, List, Optional
@@ -29,16 +29,16 @@
2929
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT,
3030
OTEL_INSTRUMENTATION_GENAI_EMIT_EVENT,
3131
)
32-
from opentelemetry.util.genai.extended_environment_variables import (
33-
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_ALLOWED_ROOT_PATHS,
34-
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_AUDIO_CONVERSION_ENABLED,
35-
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_DOWNLOAD_ENABLED,
36-
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_DOWNLOAD_SSL_VERIFY,
37-
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_LOCAL_FILE_ENABLED,
38-
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_PRE_UPLOADER,
39-
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_STORAGE_BASE_PATH,
40-
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_UPLOAD_MODE,
41-
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_UPLOADER,
32+
from opentelemetry.util.genai.extended_environment_variables import ( # pylint: disable=no-name-in-module
33+
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_ALLOWED_ROOT_PATHS, # LoongSuite Extension
34+
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_AUDIO_CONVERSION_ENABLED, # LoongSuite Extension
35+
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_DOWNLOAD_ENABLED, # LoongSuite Extension
36+
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_DOWNLOAD_SSL_VERIFY, # LoongSuite Extension
37+
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_LOCAL_FILE_ENABLED, # LoongSuite Extension
38+
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_PRE_UPLOADER, # LoongSuite Extension
39+
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_STORAGE_BASE_PATH, # LoongSuite Extension
40+
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_UPLOAD_MODE, # LoongSuite Extension
41+
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_UPLOADER, # LoongSuite Extension
4242
)
4343
from opentelemetry.util.genai.types import ContentCapturingMode
4444

@@ -123,6 +123,9 @@ def should_emit_event() -> bool:
123123
return False
124124

125125

126+
# LoongSuite Extension
127+
128+
126129
def _parse_env_bool(value: Optional[str], default: bool) -> bool:
127130
if not value:
128131
return default

util/opentelemetry-util-genai/tests/_multimodal_upload/test_default_hooks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
from unittest import TestCase
1717
from unittest.mock import patch
1818

19-
from opentelemetry.util.genai._multimodal_upload.fs_uploader import (
19+
from opentelemetry.util.genai._multimodal_upload.fs_uploader import ( # pylint: disable=no-name-in-module
2020
FsUploader,
2121
fs_uploader_hook,
2222
)
23-
from opentelemetry.util.genai._multimodal_upload.pre_uploader import (
23+
from opentelemetry.util.genai._multimodal_upload.pre_uploader import ( # pylint: disable=no-name-in-module
2424
MultimodalPreUploader,
2525
fs_pre_uploader_hook,
2626
)

util/opentelemetry-util-genai/tests/_multimodal_upload/test_multimodal_upload_hook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
Uploader,
2525
UploadItem,
2626
)
27-
from opentelemetry.util.genai.extended_environment_variables import (
27+
from opentelemetry.util.genai.extended_environment_variables import ( # pylint: disable=no-name-in-module
2828
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_PRE_UPLOADER,
2929
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_UPLOAD_MODE,
3030
OTEL_INSTRUMENTATION_GENAI_MULTIMODAL_UPLOADER,

util/opentelemetry-util-genai/tests/test_extended_handler.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,18 +1293,18 @@ def test_process_multimodal_returns_false_on_precondition_failure(self):
12931293
inv1.context_token = None
12941294
inv1.span = MagicMock()
12951295
self.assertFalse(
1296-
handler.process_multimodal_stop(inv1, method="stop_llm")
1296+
handler.process_multimodal_stop(inv1, method="stop_llm") # pylint: disable=unexpected-keyword-arg
12971297
)
12981298
self.assertFalse(
1299-
handler.process_multimodal_fail(inv1, error, method="fail_llm")
1299+
handler.process_multimodal_fail(inv1, error, method="fail_llm") # pylint: disable=unexpected-keyword-arg
13001300
)
13011301

13021302
# span is None
13031303
inv2 = self._create_invocation_with_multimodal()
13041304
inv2.context_token = MagicMock()
13051305
inv2.span = None
13061306
self.assertFalse(
1307-
handler.process_multimodal_stop(inv2, method="stop_llm")
1307+
handler.process_multimodal_stop(inv2, method="stop_llm") # pylint: disable=unexpected-keyword-arg
13081308
)
13091309

13101310
# No multimodal data
@@ -1315,14 +1315,14 @@ def test_process_multimodal_returns_false_on_precondition_failure(self):
13151315
InputMessage(role="user", parts=[Text(content="Hi")])
13161316
]
13171317
self.assertFalse(
1318-
handler.process_multimodal_stop(inv3, method="stop_llm")
1318+
handler.process_multimodal_stop(inv3, method="stop_llm") # pylint: disable=unexpected-keyword-arg
13191319
)
13201320

13211321
# multimodal_enabled=False
13221322
handler_disabled = self._create_mock_handler(enabled=False)
13231323
inv4 = self._create_invocation_with_multimodal(with_context=True)
13241324
self.assertFalse(
1325-
handler_disabled.process_multimodal_stop(inv4, method="stop_llm")
1325+
handler_disabled.process_multimodal_stop(inv4, method="stop_llm") # pylint: disable=unexpected-keyword-arg
13261326
)
13271327

13281328
@patch_env_vars(
@@ -1341,15 +1341,15 @@ def test_process_multimodal_fallback_on_queue_issues(self):
13411341
MultimodalProcessingMixin._async_queue = None
13421342
with patch.object(handler, "_fallback_stop") as mock_end:
13431343
self.assertTrue(
1344-
handler.process_multimodal_stop(inv, method="stop_llm")
1344+
handler.process_multimodal_stop(inv, method="stop_llm") # pylint: disable=unexpected-keyword-arg
13451345
)
13461346
mock_end.assert_called_once()
13471347

13481348
# Reset invocation context token
13491349
inv.context_token = MagicMock()
13501350
with patch.object(handler, "_fallback_fail") as mock_fail:
13511351
self.assertTrue(
1352-
handler.process_multimodal_fail(
1352+
handler.process_multimodal_fail( # pylint: disable=unexpected-keyword-arg
13531353
inv, error, method="fail_llm"
13541354
)
13551355
)
@@ -1361,7 +1361,7 @@ def test_process_multimodal_fallback_on_queue_issues(self):
13611361
inv.context_token = MagicMock()
13621362
with patch.object(handler, "_fallback_stop") as mock_end2:
13631363
self.assertTrue(
1364-
handler.process_multimodal_stop(inv, method="stop_llm")
1364+
handler.process_multimodal_stop(inv, method="stop_llm") # pylint: disable=unexpected-keyword-arg
13651365
)
13661366
mock_end2.assert_called_once()
13671367

@@ -1381,15 +1381,15 @@ def test_process_multimodal_enqueues_task(self):
13811381
# stop
13821382
inv1 = self._create_invocation_with_multimodal(with_context=True)
13831383
self.assertTrue(
1384-
handler.process_multimodal_stop(inv1, method="stop_llm")
1384+
handler.process_multimodal_stop(inv1, method="stop_llm") # pylint: disable=unexpected-keyword-arg
13851385
)
13861386
task = MultimodalProcessingMixin._async_queue.get_nowait()
13871387
self.assertEqual(task.method, "stop_llm")
13881388

13891389
# fail
13901390
inv2 = self._create_invocation_with_multimodal(with_context=True)
13911391
self.assertTrue(
1392-
handler.process_multimodal_fail(inv2, error, method="fail_llm")
1392+
handler.process_multimodal_fail(inv2, error, method="fail_llm") # pylint: disable=unexpected-keyword-arg
13931393
)
13941394
task = MultimodalProcessingMixin._async_queue.get_nowait()
13951395
self.assertEqual(task.method, "fail_llm")
@@ -1404,8 +1404,8 @@ def test_fallback_and_async_methods_handle_span_none(self):
14041404
inv.span = None
14051405

14061406
# Should not raise
1407-
handler._fallback_stop(inv, "stop_llm")
1408-
handler._fallback_fail(
1407+
handler._fallback_stop(inv, "stop_llm") # pylint: disable=no-member
1408+
handler._fallback_fail( # pylint: disable=no-member
14091409
inv, Error(message="err", type=RuntimeError), "fail_llm"
14101410
)
14111411
handler._async_stop_llm(
@@ -1448,12 +1448,12 @@ def test_fallback_methods_apply_attributes(self):
14481448
) as m2, patch(
14491449
"opentelemetry.util.genai._multimodal_processing._maybe_emit_llm_event"
14501450
): # fmt: skip
1451-
handler._fallback_stop(inv, "stop_llm")
1451+
handler._fallback_stop(inv, "stop_llm") # pylint: disable=no-member
14521452
m1.assert_called_with(mock_span, inv)
14531453
mock_span.end.assert_called_once()
14541454

14551455
mock_span.reset_mock()
1456-
handler._fallback_fail(inv, error, "fail_llm")
1456+
handler._fallback_fail(inv, error, "fail_llm") # pylint: disable=no-member
14571457
m2.assert_called_with(mock_span, error)
14581458
mock_span.end.assert_called_once()
14591459

@@ -1565,7 +1565,7 @@ def test_dispatch_task_routes_agent_methods(self):
15651565
"opentelemetry.util.genai._multimodal_processing._maybe_emit_invoke_agent_event"
15661566
): # fmt: skip
15671567
# stop_agent
1568-
handler._dispatch_task(
1568+
handler._dispatch_task( # pylint: disable=no-member
15691569
_MultimodalAsyncTask(
15701570
invocation=inv, method="stop_agent", handler=handler
15711571
)
@@ -1577,7 +1577,7 @@ def test_dispatch_task_routes_agent_methods(self):
15771577
m_attr.reset_mock()
15781578

15791579
# fail_agent
1580-
handler._dispatch_task(
1580+
handler._dispatch_task( # pylint: disable=no-member
15811581
_MultimodalAsyncTask(
15821582
invocation=inv,
15831583
method="fail_agent",
@@ -1605,7 +1605,7 @@ def test_async_stop_and_fail_agent_process_correctly(self):
16051605
) as m2, patch(
16061606
"opentelemetry.util.genai._multimodal_processing._maybe_emit_invoke_agent_event"
16071607
): # fmt: skip
1608-
handler._async_stop_invoke_agent(
1608+
handler._async_stop_invoke_agent( # pylint: disable=no-member
16091609
_MultimodalAsyncTask(
16101610
invocation=inv, method="stop_agent", handler=handler
16111611
)
@@ -1616,7 +1616,7 @@ def test_async_stop_and_fail_agent_process_correctly(self):
16161616

16171617
mock_span.reset_mock()
16181618
error = Error(message="err", type=ValueError)
1619-
handler._async_fail_invoke_agent(
1619+
handler._async_fail_invoke_agent( # pylint: disable=no-member
16201620
_MultimodalAsyncTask(
16211621
invocation=inv,
16221622
method="fail_agent",
@@ -1634,12 +1634,12 @@ def test_agent_async_methods_handle_span_none(self):
16341634
inv.span = None
16351635

16361636
# Should not raise
1637-
handler._async_stop_invoke_agent(
1637+
handler._async_stop_invoke_agent( # pylint: disable=no-member
16381638
_MultimodalAsyncTask(
16391639
invocation=inv, method="stop_agent", handler=handler
16401640
)
16411641
)
1642-
handler._async_fail_invoke_agent(
1642+
handler._async_fail_invoke_agent( # pylint: disable=no-member
16431643
_MultimodalAsyncTask(
16441644
invocation=inv,
16451645
method="fail_agent",
@@ -1662,7 +1662,7 @@ def test_fallback_stop_agent_applies_attributes(self):
16621662
) as m1, patch(
16631663
"opentelemetry.util.genai._multimodal_processing._maybe_emit_invoke_agent_event"
16641664
): # fmt: skip
1665-
handler._fallback_stop(inv, "stop_agent")
1665+
handler._fallback_stop(inv, "stop_agent") # pylint: disable=no-member
16661666
m1.assert_called_with(mock_span, inv)
16671667
mock_span.end.assert_called_once()
16681668

@@ -1683,7 +1683,7 @@ def test_fallback_fail_agent_applies_attributes(self):
16831683
) as m2, patch(
16841684
"opentelemetry.util.genai._multimodal_processing._maybe_emit_invoke_agent_event"
16851685
): # fmt: skip
1686-
handler._fallback_fail(inv, error, "fail_agent")
1686+
handler._fallback_fail(inv, error, "fail_agent") # pylint: disable=no-member
16871687
m1.assert_called_with(mock_span, inv)
16881688
m2.assert_called_with(mock_span, error)
16891689
mock_span.end.assert_called_once()
@@ -1951,7 +1951,7 @@ def test_shutdown_sequence(
19511951
("uploader", timeout)
19521952
)
19531953

1954-
ExtendedTelemetryHandler.shutdown(
1954+
ExtendedTelemetryHandler.shutdown( # pylint: disable=no-member
19551955
worker_timeout=1.0,
19561956
pre_uploader_timeout=2.0,
19571957
uploader_timeout=3.0,
@@ -1971,8 +1971,8 @@ def test_shutdown_idempotent( # pylint: disable=no-self-use
19711971
mock_shutdown_pre_uploader: MagicMock,
19721972
mock_shutdown_uploader: MagicMock,
19731973
):
1974-
ExtendedTelemetryHandler.shutdown()
1975-
ExtendedTelemetryHandler.shutdown()
1974+
ExtendedTelemetryHandler.shutdown() # pylint: disable=no-member
1975+
ExtendedTelemetryHandler.shutdown() # pylint: disable=no-member
19761976

19771977
mock_shutdown_worker.assert_called_once()
19781978
mock_shutdown_pre_uploader.assert_called_once()

0 commit comments

Comments
 (0)