Spaces:
Running
Running
William Easton commited on
Make the type checker less sad
Browse files
src/fastmcp/prompts/prompt.py
CHANGED
|
@@ -59,7 +59,7 @@ class PromptArgument(FastMCPBaseModel):
|
|
| 59 |
|
| 60 |
name: str = Field(description="Name of the argument")
|
| 61 |
description: str | None = Field(
|
| 62 |
-
None, description="Description of what the argument does"
|
| 63 |
)
|
| 64 |
required: bool = Field(
|
| 65 |
default=False, description="Whether the argument is required"
|
|
@@ -71,13 +71,13 @@ class Prompt(FastMCPBaseModel, ABC):
|
|
| 71 |
|
| 72 |
name: str = Field(description="Name of the prompt")
|
| 73 |
description: str | None = Field(
|
| 74 |
-
None, description="Description of what the prompt does"
|
| 75 |
)
|
| 76 |
tags: Annotated[set[str], BeforeValidator(_convert_set_defaults)] = Field(
|
| 77 |
default_factory=set, description="Tags for the prompt"
|
| 78 |
)
|
| 79 |
arguments: list[PromptArgument] | None = Field(
|
| 80 |
-
None, description="Arguments that can be passed to the prompt"
|
| 81 |
)
|
| 82 |
|
| 83 |
def __eq__(self, other: object) -> bool:
|
|
|
|
| 59 |
|
| 60 |
name: str = Field(description="Name of the argument")
|
| 61 |
description: str | None = Field(
|
| 62 |
+
default=None, description="Description of what the argument does"
|
| 63 |
)
|
| 64 |
required: bool = Field(
|
| 65 |
default=False, description="Whether the argument is required"
|
|
|
|
| 71 |
|
| 72 |
name: str = Field(description="Name of the prompt")
|
| 73 |
description: str | None = Field(
|
| 74 |
+
default=None, description="Description of what the prompt does"
|
| 75 |
)
|
| 76 |
tags: Annotated[set[str], BeforeValidator(_convert_set_defaults)] = Field(
|
| 77 |
default_factory=set, description="Tags for the prompt"
|
| 78 |
)
|
| 79 |
arguments: list[PromptArgument] | None = Field(
|
| 80 |
+
default=None, description="Arguments that can be passed to the prompt"
|
| 81 |
)
|
| 82 |
|
| 83 |
def __eq__(self, other: object) -> bool:
|
src/fastmcp/resources/resource.py
CHANGED
|
@@ -38,9 +38,9 @@ class Resource(FastMCPBaseModel, abc.ABC):
|
|
| 38 |
uri: Annotated[AnyUrl, UrlConstraints(host_required=False)] = Field(
|
| 39 |
default=..., description="URI of the resource"
|
| 40 |
)
|
| 41 |
-
name: str | None = Field(description="Name of the resource"
|
| 42 |
description: str | None = Field(
|
| 43 |
-
description="Description of the resource"
|
| 44 |
)
|
| 45 |
tags: Annotated[set[str], BeforeValidator(_convert_set_defaults)] = Field(
|
| 46 |
default_factory=set, description="Tags for the resource"
|
|
|
|
| 38 |
uri: Annotated[AnyUrl, UrlConstraints(host_required=False)] = Field(
|
| 39 |
default=..., description="URI of the resource"
|
| 40 |
)
|
| 41 |
+
name: str | None = Field(default=None, description="Name of the resource")
|
| 42 |
description: str | None = Field(
|
| 43 |
+
default=None, description="Description of the resource"
|
| 44 |
)
|
| 45 |
tags: Annotated[set[str], BeforeValidator(_convert_set_defaults)] = Field(
|
| 46 |
default_factory=set, description="Tags for the resource"
|
src/fastmcp/tools/tool.py
CHANGED
|
@@ -45,14 +45,14 @@ class Tool(FastMCPBaseModel, ABC):
|
|
| 45 |
default_factory=set, description="Tags for the tool"
|
| 46 |
)
|
| 47 |
annotations: ToolAnnotations | None = Field(
|
| 48 |
-
None, description="Additional annotations about the tool"
|
| 49 |
)
|
| 50 |
exclude_args: list[str] | None = Field(
|
| 51 |
-
None,
|
| 52 |
description="Arguments to exclude from the tool schema, such as State, Memory, or Credential",
|
| 53 |
)
|
| 54 |
serializer: Callable[[Any], str] | None = Field(
|
| 55 |
-
None, description="Optional custom serializer for tool results"
|
| 56 |
)
|
| 57 |
|
| 58 |
def to_mcp_tool(self, **overrides: Any) -> MCPTool:
|
|
|
|
| 45 |
default_factory=set, description="Tags for the tool"
|
| 46 |
)
|
| 47 |
annotations: ToolAnnotations | None = Field(
|
| 48 |
+
default=None, description="Additional annotations about the tool"
|
| 49 |
)
|
| 50 |
exclude_args: list[str] | None = Field(
|
| 51 |
+
default=None,
|
| 52 |
description="Arguments to exclude from the tool schema, such as State, Memory, or Credential",
|
| 53 |
)
|
| 54 |
serializer: Callable[[Any], str] | None = Field(
|
| 55 |
+
default=None, description="Optional custom serializer for tool results"
|
| 56 |
)
|
| 57 |
|
| 58 |
def to_mcp_tool(self, **overrides: Any) -> MCPTool:
|
tests/utilities/test_typeadapter.py
CHANGED
|
@@ -60,7 +60,7 @@ def complex_arguments_fn(
|
|
| 60 |
456,
|
| 61 |
],
|
| 62 |
field_with_default_via_field_annotation_before_nondefault_arg: Annotated[
|
| 63 |
-
int, Field(1)
|
| 64 |
],
|
| 65 |
unannotated,
|
| 66 |
my_model_a: SomeInputModelA,
|
|
@@ -68,7 +68,7 @@ def complex_arguments_fn(
|
|
| 68 |
my_model_b: SomeInputModelB,
|
| 69 |
an_int_annotated_with_field_default: Annotated[
|
| 70 |
int,
|
| 71 |
-
Field(1, description="An int with a field"),
|
| 72 |
],
|
| 73 |
unannotated_with_default=5,
|
| 74 |
my_model_a_with_default: SomeInputModelA = SomeInputModelA(), # noqa: B008
|
|
|
|
| 60 |
456,
|
| 61 |
],
|
| 62 |
field_with_default_via_field_annotation_before_nondefault_arg: Annotated[
|
| 63 |
+
int, Field(default=1)
|
| 64 |
],
|
| 65 |
unannotated,
|
| 66 |
my_model_a: SomeInputModelA,
|
|
|
|
| 68 |
my_model_b: SomeInputModelB,
|
| 69 |
an_int_annotated_with_field_default: Annotated[
|
| 70 |
int,
|
| 71 |
+
Field(default=1, description="An int with a field"),
|
| 72 |
],
|
| 73 |
unannotated_with_default=5,
|
| 74 |
my_model_a_with_default: SomeInputModelA = SomeInputModelA(), # noqa: B008
|