Skip to content

Commit 9301924

Browse files
authored
chore: bump ruff (#1085)
1 parent 6f43d1f commit 9301924

File tree

21 files changed

+56
-57
lines changed

21 files changed

+56
-57
lines changed

examples/clients/simple-auth-client/mcp_simple_auth_client/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def do_GET(self):
8181
<html>
8282
<body>
8383
<h1>Authorization Failed</h1>
84-
<p>Error: {query_params['error'][0]}</p>
84+
<p>Error: {query_params["error"][0]}</p>
8585
<p>You can close this window and return to the terminal.</p>
8686
</body>
8787
</html>

examples/fastmcp/memory.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from dataclasses import dataclass
1717
from datetime import datetime, timezone
1818
from pathlib import Path
19-
from typing import Annotated, Self
19+
from typing import Annotated, Self, TypeVar
2020

2121
import asyncpg
2222
import numpy as np
@@ -35,6 +35,8 @@
3535
DEFAULT_LLM_MODEL = "openai:gpt-4o"
3636
DEFAULT_EMBEDDING_MODEL = "text-embedding-3-small"
3737

38+
T = TypeVar("T")
39+
3840
mcp = FastMCP(
3941
"memory",
4042
dependencies=[
@@ -57,7 +59,7 @@ def cosine_similarity(a: list[float], b: list[float]) -> float:
5759
return np.dot(a_array, b_array) / (np.linalg.norm(a_array) * np.linalg.norm(b_array))
5860

5961

60-
async def do_ai[T](
62+
async def do_ai(
6163
user_prompt: str,
6264
system_prompt: str,
6365
result_type: type[T] | Annotated,

examples/fastmcp/unicode_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
mcp = FastMCP()
99

1010

11-
@mcp.tool(description="🌟 A tool that uses various Unicode characters in its description: " "á é í ó ú ñ 漢字 🎉")
11+
@mcp.tool(description="🌟 A tool that uses various Unicode characters in its description: á é í ó ú ñ 漢字 🎉")
1212
def hello_unicode(name: str = "世界", greeting: str = "¡Hola") -> str:
1313
"""
1414
A simple tool that demonstrates Unicode handling in:

examples/servers/simple-auth/mcp_simple_auth/simple_auth_provider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async def authorize(self, client: OAuthClientInformationFull, params: Authorizat
8989
}
9090

9191
# Build simple login URL that points to login page
92-
auth_url = f"{self.auth_callback_url}" f"?state={state}" f"&client_id={client.client_id}"
92+
auth_url = f"{self.auth_callback_url}?state={state}&client_id={client.client_id}"
9393

9494
return auth_url
9595

@@ -117,7 +117,7 @@ async def get_login_page(self, state: str) -> HTMLResponse:
117117
<p><strong>Username:</strong> demo_user<br>
118118
<strong>Password:</strong> demo_password</p>
119119
120-
<form action="{self.server_url.rstrip('/')}/login/callback" method="post">
120+
<form action="{self.server_url.rstrip("/")}/login/callback" method="post">
121121
<input type="hidden" name="state" value="{state}">
122122
<div class="form-group">
123123
<label>Username:</label>

examples/servers/simple-streamablehttp-stateless/mcp_simple_streamablehttp_stateless/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async def call_tool(name: str, arguments: dict) -> list[types.ContentBlock]:
5151
for i in range(count):
5252
await ctx.session.send_log_message(
5353
level="info",
54-
data=f"Notification {i+1}/{count} from caller: {caller}",
54+
data=f"Notification {i + 1}/{count} from caller: {caller}",
5555
logger="notification_stream",
5656
related_request_id=ctx.request_id,
5757
)

examples/servers/simple-streamablehttp/mcp_simple_streamablehttp/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async def call_tool(name: str, arguments: dict) -> list[types.ContentBlock]:
5555
for i in range(count):
5656
# Include more detailed message for resumability demonstration
5757
notification_msg = (
58-
f"[{i+1}/{count}] Event from '{caller}' - "
58+
f"[{i + 1}/{count}] Event from '{caller}' - "
5959
f"Use Last-Event-ID to resume if disconnected"
6060
)
6161
await ctx.session.send_log_message(
@@ -69,7 +69,7 @@ async def call_tool(name: str, arguments: dict) -> list[types.ContentBlock]:
6969
# - nowhere (if GET request isn't supported)
7070
related_request_id=ctx.request_id,
7171
)
72-
logger.debug(f"Sent notification {i+1}/{count} for caller: {caller}")
72+
logger.debug(f"Sent notification {i + 1}/{count} for caller: {caller}")
7373
if i < count - 1: # Don't wait after the last notification
7474
await anyio.sleep(interval)
7575

src/mcp/cli/claude.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def get_uv_path() -> str:
3535
uv_path = shutil.which("uv")
3636
if not uv_path:
3737
logger.error(
38-
"uv executable not found in PATH, falling back to 'uv'. " "Please ensure uv is installed and in your PATH"
38+
"uv executable not found in PATH, falling back to 'uv'. Please ensure uv is installed and in your PATH"
3939
)
4040
return "uv" # Fall back to just "uv" if not found
4141
return uv_path

src/mcp/cli/cli.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ def _check_server_object(server_object: Any, object_name: str):
150150
True if it's supported.
151151
"""
152152
if not isinstance(server_object, FastMCP):
153-
logger.error(f"The server object {object_name} is of type " f"{type(server_object)} (expecting {FastMCP}).")
153+
logger.error(f"The server object {object_name} is of type {type(server_object)} (expecting {FastMCP}).")
154154
if isinstance(server_object, LowLevelServer):
155155
logger.warning(
156-
"Note that only FastMCP server is supported. Low level " "Server class is not yet supported."
156+
"Note that only FastMCP server is supported. Low level Server class is not yet supported."
157157
)
158158
return False
159159
return True
@@ -164,7 +164,7 @@ def _check_server_object(server_object: Any, object_name: str):
164164
for name in ["mcp", "server", "app"]:
165165
if hasattr(module, name):
166166
if not _check_server_object(getattr(module, name), f"{file}:{name}"):
167-
logger.error(f"Ignoring object '{file}:{name}' as it's not a valid " "server object")
167+
logger.error(f"Ignoring object '{file}:{name}' as it's not a valid server object")
168168
continue
169169
return getattr(module, name)
170170

@@ -269,7 +269,7 @@ def dev(
269269
npx_cmd = _get_npx_command()
270270
if not npx_cmd:
271271
logger.error(
272-
"npx not found. Please ensure Node.js and npm are properly installed " "and added to your system PATH."
272+
"npx not found. Please ensure Node.js and npm are properly installed and added to your system PATH."
273273
)
274274
sys.exit(1)
275275

@@ -371,7 +371,7 @@ def install(
371371
typer.Option(
372372
"--name",
373373
"-n",
374-
help="Custom name for the server (defaults to server's name attribute or" " file name)",
374+
help="Custom name for the server (defaults to server's name attribute or file name)",
375375
),
376376
] = None,
377377
with_editable: Annotated[
@@ -445,7 +445,7 @@ def install(
445445
name = server.name
446446
except (ImportError, ModuleNotFoundError) as e:
447447
logger.debug(
448-
"Could not import server (likely missing dependencies), using file" " name",
448+
"Could not import server (likely missing dependencies), using file name",
449449
extra={"error": str(e)},
450450
)
451451
name = file.stem

src/mcp/client/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ async def initialize(self) -> types.InitializeResult:
168168
)
169169

170170
if result.protocolVersion not in SUPPORTED_PROTOCOL_VERSIONS:
171-
raise RuntimeError("Unsupported protocol version from the server: " f"{result.protocolVersion}")
171+
raise RuntimeError(f"Unsupported protocol version from the server: {result.protocolVersion}")
172172

173173
await self.send_notification(
174174
types.ClientNotification(types.InitializedNotification(method="notifications/initialized"))

src/mcp/client/sse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ async def sse_reader(
8383
or url_parsed.scheme != endpoint_parsed.scheme
8484
):
8585
error_msg = (
86-
"Endpoint origin does not match " f"connection origin: {endpoint_url}"
86+
f"Endpoint origin does not match connection origin: {endpoint_url}"
8787
)
8888
logger.error(error_msg)
8989
raise ValueError(error_msg)
@@ -125,7 +125,7 @@ async def post_writer(endpoint_url: str):
125125
),
126126
)
127127
response.raise_for_status()
128-
logger.debug("Client message sent successfully: " f"{response.status_code}")
128+
logger.debug(f"Client message sent successfully: {response.status_code}")
129129
except Exception as exc:
130130
logger.error(f"Error in post_writer: {exc}")
131131
finally:

0 commit comments

Comments
 (0)