diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4705422..f8cb7b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,5 +69,8 @@ jobs: - name: Format check run: ruff format --check . + - name: Type check + run: mypy src/ + - name: Test run: pytest -v diff --git a/pyproject.toml b/pyproject.toml index b55a333..45d1aab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,7 @@ dev = [ "pytest", "pytest-asyncio", "ruff", + "mypy", ] [tool.ruff] @@ -42,6 +43,19 @@ line-length = 100 [tool.ruff.lint] select = ["E", "F", "I", "N", "W", "UP"] +[tool.mypy] +python_version = "3.11" +strict = true +warn_unused_ignores = true +warn_redundant_casts = true +warn_unreachable = true +show_error_codes = true +exclude = ["build/", "dist/"] + +[[tool.mypy.overrides]] +module = "tests.*" +disallow_untyped_defs = false + [tool.pytest.ini_options] asyncio_mode = "auto" testpaths = ["tests"] diff --git a/src/my_mcp_server/server.py b/src/my_mcp_server/server.py index c593abf..7828376 100644 --- a/src/my_mcp_server/server.py +++ b/src/my_mcp_server/server.py @@ -33,13 +33,13 @@ # --------------------------------------------------------------------------- -def ok(data: str | dict) -> dict: +def ok(data: str | dict[str, object]) -> dict[str, object]: """Return a successful tool response.""" text = data if isinstance(data, str) else str(data) return {"content": [{"type": "text", "text": text}]} -def err(message: str) -> dict: +def err(message: str) -> dict[str, object]: """Return an error tool response.""" return {"content": [{"type": "text", "text": message}], "isError": True}