Skip to content

Commit 6a5f9d6

Browse files
committed
Testing lint checker
1 parent 0e6e339 commit 6a5f9d6

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/mcpinstrumentor/mcpinstrumentor.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def setup_logger_two():
2424
return logger
2525

2626

27-
class MCPInstrumentor(BaseInstrumentor):
27+
class MCPInstrumentor(BaseInstrumentor): # pylint: disable=attribute-defined-outside-init
2828
"""
2929
An instrumenter for MCP.
3030
"""
@@ -95,7 +95,7 @@ async def _wrap_handle_request(self, wrapped, instance, args, kwargs):
9595
else:
9696
return await wrapped(*args, **kwargs)
9797

98-
def _inject_trace_context(self, request_data, span_ctx):
98+
def _inject_trace_context(self, request_data, span_ctx): # pylint: disable=no-self-use
9999
if "params" not in request_data:
100100
request_data["params"] = {}
101101
if "_meta" not in request_data["params"]:
@@ -106,7 +106,7 @@ def _inject_trace_context(self, request_data, span_ctx):
106106
traceparent = f"00-{trace_id_hex}-{span_id_hex}-{trace_flags}"
107107
request_data["params"]["_meta"]["traceparent"] = traceparent
108108

109-
def _extract_span_context_from_traceparent(self, traceparent):
109+
def _extract_span_context_from_traceparent(self, traceparent): # pylint: disable=no-self-use
110110
parts = traceparent.split("-")
111111
if len(parts) == 4:
112112
try:
@@ -123,9 +123,9 @@ def _extract_span_context_from_traceparent(self, traceparent):
123123
return None
124124
return None
125125

126-
def _get_span_name(self, req):
126+
def _get_span_name(self, req): # pylint: disable=no-self-use
127127
span_name = "unknown"
128-
import mcp.types as types
128+
import mcp.types as types # pylint: disable=import-outside-toplevel
129129

130130
if isinstance(req, types.ListToolsRequest):
131131
span_name = "tools/list"
@@ -137,7 +137,7 @@ def _get_span_name(self, req):
137137
return span_name
138138

139139
def handle_attributes(self, span, request, is_client=True):
140-
import mcp.types as types
140+
import mcp.types as types # pylint: disable=import-outside-toplevel
141141

142142
operation = self._get_span_name(request)
143143
if isinstance(request, types.ListToolsRequest):
@@ -152,13 +152,13 @@ def handle_attributes(self, span, request, is_client=True):
152152
else:
153153
self._add_server_attributes(span, operation, request)
154154

155-
def _add_client_attributes(self, span, operation, request):
155+
def _add_client_attributes(self, span, operation, request): # pylint: disable=no-self-use
156156
span.set_attribute("aws.remote.service", "Appsignals MCP Server")
157157
span.set_attribute("aws.remote.operation", operation)
158158
if hasattr(request, "params") and hasattr(request.params, "name"):
159159
span.set_attribute("tool.name", request.params.name)
160160

161-
def _add_server_attributes(self, span, operation, request):
161+
def _add_server_attributes(self, span, operation, request): # pylint: disable=no-self-use
162162
span.set_attribute("server_side", True)
163163
if hasattr(request, "params") and hasattr(request.params, "name"):
164164
span.set_attribute("tool.name", request.params.name)

aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_mcpinstrumentor.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
14
"""
25
Unit tests for MCPInstrumentor - testing actual mcpinstrumentor methods
36
"""
@@ -8,9 +11,12 @@
811
import unittest
912
from unittest.mock import MagicMock
1013

14+
# Add src path for imports
1115
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../.."))
1216
src_path = os.path.join(project_root, "src")
1317
sys.path.insert(0, src_path)
18+
19+
# pylint: disable=wrong-import-position
1420
from amazon.opentelemetry.distro.mcpinstrumentor.mcpinstrumentor import MCPInstrumentor # noqa: E402
1521

1622

@@ -214,7 +220,7 @@ def setUp(self):
214220
mock_tracer = MagicMock()
215221
self.instrumentor.tracer = mock_tracer
216222

217-
def test_no_trace_context_fallback(self):
223+
def test_no_trace_context_fallback(self): # pylint: disable=no-self-use
218224
"""Test graceful handling when no trace context is present on server side"""
219225

220226
class MockServerNoTrace:
@@ -258,7 +264,7 @@ def __init__(self, name):
258264
# Should not create traced spans when no trace context is present
259265
mock_tracer.start_as_current_span.assert_not_called()
260266

261-
def test_end_to_end_client_server_communication(self):
267+
def test_end_to_end_client_server_communication(self): # pylint: disable=too-many-locals,too-many-statements
262268
"""Test where server actually receives what client sends (including injected trace context)"""
263269

264270
# Create realistic request/response classes

0 commit comments

Comments
 (0)