mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 15:19:10 +02:00
Remove redundant None checks from Context methods (#2251)
The fastmcp property already raises RuntimeError if None, making these checks unreachable.
This commit is contained in:
parent
380835593c
commit
b57a39c69c
2 changed files with 3 additions and 11 deletions
|
|
@ -224,8 +224,6 @@ class Context:
|
|||
Returns:
|
||||
List of Resource objects available on the server
|
||||
"""
|
||||
if self.fastmcp is None:
|
||||
raise ValueError("Context is not available outside of a request")
|
||||
return await self.fastmcp._list_resources_mcp()
|
||||
|
||||
async def list_prompts(self) -> list[MCPPrompt]:
|
||||
|
|
@ -234,8 +232,6 @@ class Context:
|
|||
Returns:
|
||||
List of Prompt objects available on the server
|
||||
"""
|
||||
if self.fastmcp is None:
|
||||
raise ValueError("Context is not available outside of a request")
|
||||
return await self.fastmcp._list_prompts_mcp()
|
||||
|
||||
async def get_prompt(
|
||||
|
|
@ -250,8 +246,6 @@ class Context:
|
|||
Returns:
|
||||
The prompt result
|
||||
"""
|
||||
if self.fastmcp is None:
|
||||
raise ValueError("Context is not available outside of a request")
|
||||
return await self.fastmcp._get_prompt_mcp(name, arguments)
|
||||
|
||||
async def read_resource(self, uri: str | AnyUrl) -> list[ReadResourceContents]:
|
||||
|
|
@ -263,8 +257,6 @@ class Context:
|
|||
Returns:
|
||||
The resource content as either text or bytes
|
||||
"""
|
||||
if self.fastmcp is None:
|
||||
raise ValueError("Context is not available outside of a request")
|
||||
return await self.fastmcp._read_resource_mcp(uri)
|
||||
|
||||
async def log(
|
||||
|
|
|
|||
6
uv.lock
generated
6
uv.lock
generated
|
|
@ -1,5 +1,5 @@
|
|||
version = 1
|
||||
revision = 2
|
||||
revision = 3
|
||||
requires-python = ">=3.10"
|
||||
resolution-markers = [
|
||||
"python_full_version >= '3.11'",
|
||||
|
|
@ -566,7 +566,6 @@ dependencies = [
|
|||
{ name = "py-key-value-aio", extra = ["disk", "keyring", "memory"] },
|
||||
{ name = "pydantic", extra = ["email"] },
|
||||
{ name = "pyperclip" },
|
||||
{ name = "pytest-asyncio" },
|
||||
{ name = "python-dotenv" },
|
||||
{ name = "rich" },
|
||||
{ name = "websockets" },
|
||||
|
|
@ -591,6 +590,7 @@ dev = [
|
|||
{ name = "pyinstrument" },
|
||||
{ name = "pyperclip" },
|
||||
{ name = "pytest" },
|
||||
{ name = "pytest-asyncio" },
|
||||
{ name = "pytest-cov" },
|
||||
{ name = "pytest-env" },
|
||||
{ name = "pytest-flakefinder" },
|
||||
|
|
@ -617,7 +617,6 @@ requires-dist = [
|
|||
{ name = "py-key-value-aio", extras = ["disk", "keyring", "memory"], specifier = ">=0.2.6,<0.3.0" },
|
||||
{ name = "pydantic", extras = ["email"], specifier = ">=2.11.7" },
|
||||
{ name = "pyperclip", specifier = ">=1.9.0" },
|
||||
{ name = "pytest-asyncio", specifier = ">=1.2.0" },
|
||||
{ name = "python-dotenv", specifier = ">=1.1.0" },
|
||||
{ name = "rich", specifier = ">=13.9.4" },
|
||||
{ name = "websockets", specifier = ">=15.0.1" },
|
||||
|
|
@ -637,6 +636,7 @@ dev = [
|
|||
{ name = "pyinstrument", specifier = ">=5.0.2" },
|
||||
{ name = "pyperclip", specifier = ">=1.9.0" },
|
||||
{ name = "pytest", specifier = ">=8.3.3" },
|
||||
{ name = "pytest-asyncio", specifier = ">=1.2.0" },
|
||||
{ name = "pytest-cov", specifier = ">=6.1.1" },
|
||||
{ name = "pytest-env", specifier = ">=1.1.5" },
|
||||
{ name = "pytest-flakefinder" },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue