Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7c8979d

Browse files
Kludexdsp-ant
authored andcommittedMar 19, 2025
Apply UP rule
1 parent 5c99391 commit 7c8979d

File tree

12 files changed

+20
-17
lines changed

12 files changed

+20
-17
lines changed
 

Diff for: ‎src/mcp/client/websocket.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
22
import logging
3+
from collections.abc import AsyncGenerator
34
from contextlib import asynccontextmanager
4-
from typing import AsyncGenerator
55

66
import anyio
77
from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream

Diff for: ‎src/mcp/server/fastmcp/tools/base.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from __future__ import annotations as _annotations
22

33
import inspect
4-
from typing import TYPE_CHECKING, Any, Callable
4+
from collections.abc import Callable
5+
from typing import TYPE_CHECKING, Any
56

67
from pydantic import BaseModel, Field
78

@@ -38,7 +39,7 @@ def from_function(
3839
name: str | None = None,
3940
description: str | None = None,
4041
context_kwarg: str | None = None,
41-
) -> "Tool":
42+
) -> Tool:
4243
"""Create a Tool from a function."""
4344
func_name = name or fn.__name__
4445

Diff for: ‎src/mcp/shared/memory.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
In-memory transports
33
"""
44

5+
from collections.abc import AsyncGenerator
56
from contextlib import asynccontextmanager
67
from datetime import timedelta
7-
from typing import Any, AsyncGenerator
8+
from typing import Any
89

910
import anyio
1011
from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream

Diff for: ‎src/mcp/shared/progress.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from collections.abc import Generator
12
from contextlib import contextmanager
23
from dataclasses import dataclass, field
3-
from typing import Generator, Generic
4+
from typing import Generic
45

56
from pydantic import BaseModel
67

Diff for: ‎src/mcp/shared/session.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import logging
2+
from collections.abc import Callable
23
from contextlib import AsyncExitStack
34
from datetime import timedelta
45
from types import TracebackType
5-
from typing import Any, Callable, Generic, TypeVar
6+
from typing import Any, Generic, TypeVar
67

78
import anyio
89
import anyio.lowlevel

Diff for: ‎tests/issues/test_88_random_error.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""Test to reproduce issue #88: Random error thrown on response."""
22

3+
from collections.abc import Sequence
34
from datetime import timedelta
45
from pathlib import Path
5-
from typing import Sequence
66

77
import anyio
88
import pytest

Diff for: ‎tests/server/fastmcp/test_server.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import base64
22
from pathlib import Path
3-
from typing import TYPE_CHECKING, Union
3+
from typing import TYPE_CHECKING
44

55
import pytest
66
from pydantic import AnyUrl
@@ -114,7 +114,7 @@ def image_tool_fn(path: str) -> Image:
114114
return Image(path)
115115

116116

117-
def mixed_content_tool_fn() -> list[Union[TextContent, ImageContent]]:
117+
def mixed_content_tool_fn() -> list[TextContent | ImageContent]:
118118
return [
119119
TextContent(type="text", text="Hello"),
120120
ImageContent(type="image", data="abc", mimeType="image/png"),

Diff for: ‎tests/server/fastmcp/test_tool_manager.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import json
22
import logging
3-
from typing import Optional
43

54
import pytest
65
from pydantic import BaseModel
@@ -296,7 +295,7 @@ async def test_context_optional(self):
296295
"""Test that context is optional when calling tools."""
297296
from mcp.server.fastmcp import Context
298297

299-
def tool_with_context(x: int, ctx: Optional[Context] = None) -> str:
298+
def tool_with_context(x: int, ctx: Context | None = None) -> str:
300299
return str(x)
301300

302301
manager = ToolManager()

Diff for: ‎tests/server/test_lifespan.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Tests for lifespan functionality in both low-level and FastMCP servers."""
22

3+
from collections.abc import AsyncIterator
34
from contextlib import asynccontextmanager
4-
from typing import AsyncIterator
55

66
import anyio
77
import pytest

Diff for: ‎tests/shared/test_session.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import AsyncGenerator
1+
from collections.abc import AsyncGenerator
22

33
import anyio
44
import pytest

Diff for: ‎tests/shared/test_sse.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import multiprocessing
22
import socket
33
import time
4-
from typing import AsyncGenerator, Generator
4+
from collections.abc import AsyncGenerator, Generator
55

66
import anyio
77
import httpx
@@ -139,7 +139,7 @@ def server(server_port: int) -> Generator[None, None, None]:
139139
attempt += 1
140140
else:
141141
raise RuntimeError(
142-
"Server failed to start after {} attempts".format(max_attempts)
142+
f"Server failed to start after {max_attempts} attempts"
143143
)
144144

145145
yield

Diff for: ‎tests/shared/test_ws.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import multiprocessing
22
import socket
33
import time
4-
from typing import AsyncGenerator, Generator
4+
from collections.abc import AsyncGenerator, Generator
55

66
import anyio
77
import pytest
@@ -135,7 +135,7 @@ def server(server_port: int) -> Generator[None, None, None]:
135135
attempt += 1
136136
else:
137137
raise RuntimeError(
138-
"Server failed to start after {} attempts".format(max_attempts)
138+
f"Server failed to start after {max_attempts} attempts"
139139
)
140140

141141
yield

0 commit comments

Comments
 (0)
Please sign in to comment.