From 46eacb1059848e26848dac5c24b7dc74f523798f Mon Sep 17 00:00:00 2001 From: Konippi Date: Sat, 1 Nov 2025 17:38:58 +0900 Subject: [PATCH] fix: f-strings formatting in logging --- mcp_proxy_for_aws/middleware/tool_filter.py | 4 ++-- pyproject.toml | 2 +- tests/integ/conftest.py | 8 ++++++-- tests/integ/mcp/simple_mcp_client.py | 2 +- tests/integ/test_proxy_dynamic_tools.py | 6 +++--- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/mcp_proxy_for_aws/middleware/tool_filter.py b/mcp_proxy_for_aws/middleware/tool_filter.py index 94ddfb3..3cb2215 100644 --- a/mcp_proxy_for_aws/middleware/tool_filter.py +++ b/mcp_proxy_for_aws/middleware/tool_filter.py @@ -34,7 +34,7 @@ async def on_list_tools( """Filter tools based on read only flag.""" # Get list of FastMCP Components tools = await call_next(context) - self.logger.info(f'Filtering tools for read only: {self.read_only}') + self.logger.info('Filtering tools for read only: %s', self.read_only) # If not read only, return the list of tools as is if not self.read_only: @@ -49,7 +49,7 @@ async def on_list_tools( read_only_hint = getattr(annotations, 'readOnlyHint', False) if not read_only_hint: # Skip tools that don't have readOnlyHint=True - self.logger.info(f'Skipping tool {tool.name} needing write permissions') + self.logger.info('Skipping tool %s needing write permissions', tool.name) continue filtered_tools.append(tool) diff --git a/pyproject.toml b/pyproject.toml index f4c2535..c5e7344 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -95,7 +95,7 @@ force-exclude = true [tool.ruff.lint] exclude = ["__init__.py"] -select = ["C", "D", "E", "F", "I", "W"] +select = ["C", "D", "E", "F", "G", "I", "W"] ignore = ["C901", "E501", "E741", "F402", "F823", "D100", "D106"] [tool.ruff.lint.isort] diff --git a/tests/integ/conftest.py b/tests/integ/conftest.py index 23cdd01..441d1ce 100644 --- a/tests/integ/conftest.py +++ b/tests/integ/conftest.py @@ -77,10 +77,14 @@ def _build_endpoint_environment_remote_configuration(): region_name = os.environ.get('AWS_REGION') if not region_name: - logger.warn('AWS_REGION param not set. Defaulting to us-east-1') + logger.warning('AWS_REGION param not set. Defaulting to us-east-1') region_name = 'us-east-1' - logger.info(f'Starting server with config - {remote_endpoint_url=} and {region_name=}') + logger.info( + 'Starting server with config - remote_endpoint_url=%s and region_name=%s', + remote_endpoint_url, + region_name, + ) return RemoteMCPServerConfiguration( endpoint=remote_endpoint_url, diff --git a/tests/integ/mcp/simple_mcp_client.py b/tests/integ/mcp/simple_mcp_client.py index 779a615..1f8b615 100644 --- a/tests/integ/mcp/simple_mcp_client.py +++ b/tests/integ/mcp/simple_mcp_client.py @@ -23,7 +23,7 @@ def build_mcp_client(endpoint: str, region_name: str) -> fastmcp.Client: async def _basic_elicitation_handler(message: str, response_type: type, params, context): - logger.info(f'Server asks: {message} with response_type {response_type}') + logger.info('Server asks: %s with response_type %s', message, response_type) # Usually the Handler would expect an user Input to control flow via Accept, Decline, Cancel # But in this Integ test we only care that an Elicitation request went through the handler diff --git a/tests/integ/test_proxy_dynamic_tools.py b/tests/integ/test_proxy_dynamic_tools.py index a6d5338..6d0db2d 100644 --- a/tests/integ/test_proxy_dynamic_tools.py +++ b/tests/integ/test_proxy_dynamic_tools.py @@ -18,7 +18,7 @@ async def test_proxy_reflects_tool_addition(mcp_client: fastmcp.Client, is_using initial_tools = await mcp_client.list_tools() initial_tool_names = [tool.name for tool in initial_tools] - logger.info(f'Initial tools: {initial_tool_names}') + logger.info('Initial tools: %s', initial_tool_names) # Verify 'multiply' tool doesn't exist yet assert 'multiply' not in initial_tool_names, 'multiply tool should not exist initially' @@ -26,13 +26,13 @@ async def test_proxy_reflects_tool_addition(mcp_client: fastmcp.Client, is_using # Act - Trigger backend to dynamically add a new tool logger.info('Calling add_tool_multiply to add a new tool to the backend') add_result = await mcp_client.call_tool('add_tool_multiply', {}) - logger.info(f'Backend response: {add_result}') + logger.info('Backend response: %s', add_result) # Get updated tool list updated_tools = await mcp_client.list_tools() updated_tool_names = [tool.name for tool in updated_tools] - logger.info(f'Updated tools: {updated_tool_names}') + logger.info('Updated tools: %s', updated_tool_names) # Assert # The proxy should reflect the newly added tool