Skip to content

Commit 820f9c4

Browse files
committed
refactor: enforce Literal type for mode field in append_or_prepend function
Enhanced the `mode` parameter to use `Literal` for stricter type checking, ensuring valid values ("prepend", "append") are explicitly enforced.
1 parent 7e5be5f commit 820f9c4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/mcp_bear/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from functools import partial
1919
from http import HTTPStatus
2020
from pathlib import Path
21-
from typing import cast, AsyncIterator, Final, Any, Mapping
21+
from typing import cast, AsyncIterator, Final, Any, Mapping, Literal
2222
from urllib.parse import urlencode, quote
2323

2424
import requests
@@ -253,7 +253,7 @@ async def add_file(
253253
description="if specified add the file to the corresponding header inside the note", default=None
254254
),
255255
filename: str = Field(description="file name with extension"),
256-
mode: str | None = Field(description="adding mode (prepend, append)", default=None),
256+
mode: Literal["prepend", "append"] | None = Field(description="adding mode", default=None),
257257
) -> None:
258258
"""Append or prepend a file to a note identified by its title or id."""
259259
if file.startswith("http://") or file.startswith("https://"):

0 commit comments

Comments
 (0)