Add strict mode to pyright (#315)

* Add strict mode to pyright

* Apply UP rule

* fix readme

* More correct

* Leave wrong Context for now

* Add strict mode to pyright

* Apply UP rule

* fix readme

* fix

* ignore
This commit is contained in:
Marcelo Trylesinski
2025-03-20 09:13:08 +00:00
committed by GitHub
parent 5a54d82459
commit ae77772ea8
27 changed files with 194 additions and 133 deletions

View File

@@ -1,5 +1,6 @@
import json
import subprocess
from pathlib import Path
from unittest.mock import patch
import pytest
@@ -8,7 +9,7 @@ from mcp.cli.claude import update_claude_config
@pytest.fixture
def temp_config_dir(tmp_path):
def temp_config_dir(tmp_path: Path):
"""Create a temporary Claude config directory."""
config_dir = tmp_path / "Claude"
config_dir.mkdir()
@@ -16,23 +17,20 @@ def temp_config_dir(tmp_path):
@pytest.fixture
def mock_config_path(temp_config_dir):
def mock_config_path(temp_config_dir: Path):
"""Mock get_claude_config_path to return our temporary directory."""
with patch("mcp.cli.claude.get_claude_config_path", return_value=temp_config_dir):
yield temp_config_dir
def test_command_execution(mock_config_path):
def test_command_execution(mock_config_path: Path):
"""Test that the generated command can actually be executed."""
# Setup
server_name = "test_server"
file_spec = "test_server.py:app"
# Update config
success = update_claude_config(
file_spec=file_spec,
server_name=server_name,
)
success = update_claude_config(file_spec=file_spec, server_name=server_name)
assert success
# Read the generated config

View File

@@ -7,11 +7,7 @@ from mcp.shared.context import RequestContext
from mcp.shared.memory import (
create_connected_server_and_client_session as create_session,
)
from mcp.types import (
ListRootsResult,
Root,
TextContent,
)
from mcp.types import ListRootsResult, Root, TextContent
@pytest.mark.anyio
@@ -39,7 +35,7 @@ async def test_list_roots_callback():
return callback_return
@server.tool("test_list_roots")
async def test_list_roots(context: Context, message: str):
async def test_list_roots(context: Context, message: str): # type: ignore[reportUnknownMemberType]
roots = await context.session.list_roots()
assert roots == callback_return
return True

View File

@@ -1,4 +1,4 @@
from typing import List, Literal
from typing import Literal
import anyio
import pytest
@@ -14,7 +14,7 @@ from mcp.types import (
class LoggingCollector:
def __init__(self):
self.log_messages: List[LoggingMessageNotificationParams] = []
self.log_messages: list[LoggingMessageNotificationParams] = []
async def __call__(self, params: LoggingMessageNotificationParams) -> None:
self.log_messages.append(params)