# Linting and formattingflake8>=6.0.0mypy>=1.5.0black>=23.7.0pydantic[mypy]# Testingpytest>=7.4.0pytest-asyncio>=0.21.1pytest-timeoutpytest-mock==3.11.1
The lint script (scripts/lint.py) runs all quality checks:
# Run all checkspython scripts/lint.py# Auto-fix formatting issuespython scripts/lint.py --fix# Check specific directoriespython scripts/lint.py --dirs src/servers/your-server
What It Checks:
Flake8 - Code linting
MyPy - Type checking
Black - Format verification
Output Example:
2024-01-15 10:30:00 - gumcp-lint - INFO - Parsed 25 patterns from .gitignore2024-01-15 10:30:00 - gumcp-lint - INFO - Found 145 Python files to check2024-01-15 10:30:01 - gumcp-lint - INFO - Flake8 linting...2024-01-15 10:30:03 - gumcp-lint - INFO - ✅ Flake8 linting passed!2024-01-15 10:30:03 - gumcp-lint - INFO - Mypy type checking...2024-01-15 10:30:05 - gumcp-lint - INFO - ✅ Mypy type checking passed!2024-01-15 10:30:05 - gumcp-lint - INFO - Black format checking...2024-01-15 10:30:06 - gumcp-lint - INFO - ✅ Black format checking passed!2024-01-15 10:30:06 - gumcp-lint - INFO - ✅ All linting checks passed!
def create_server(user_id=None, api_key=None): """Create a new server instance with optional user context Args: user_id: Optional user identifier for multi-tenant scenarios api_key: Optional API key for authentication Returns: Server instance configured with the specified parameters """ pass@server.list_tools()async def handle_list_tools() -> list[types.Tool]: """List available tools. Each tool specifies its arguments using JSON Schema validation. Returns: List of Tool objects describing available tools """ pass
# Good: Specific exception types with messagestry: result = await api_call()except httpx.HTTPError as e: logger.error(f"HTTP error during API call: {str(e)}") return [types.TextContent( type="text", text=f"Error: API request failed - {str(e)}" )]except ValueError as e: logger.error(f"Invalid value: {str(e)}") raise# Good: Validation with clear errorsif not arguments: raise ValueError("Missing arguments")if not arguments.get("key"): raise ValueError("Missing required parameter: key")
Problem: Importing modules that aren’t usedSolution: Remove or comment why they’re needed
# Goodimport logging # Used for loggerlogger = logging.getLogger(__name__)# Badimport loggingimport sys # Not used anywhere
Missing Docstrings
Problem: Public functions without documentationSolution: Add docstrings to all public APIs
# Gooddef authenticate_user(user_id: str) -> bool: """Authenticate a user by ID Args: user_id: The user identifier Returns: True if authentication succeeds """ pass# Baddef authenticate_user(user_id: str) -> bool: pass