mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
fix: ruff lint auto-fixes across hanzo-mcp and tests
This commit is contained in:
@@ -39,9 +39,9 @@ except Exception:
|
||||
# Re-export canonical types from hanzoai core.
|
||||
# hanzo-mcp works standalone but prefers hanzoai when available.
|
||||
try:
|
||||
from hanzoai.protocols import PermissionPolicy, PermissionMode, PermissionOutcome
|
||||
from hanzoai.config import ConfigLoader, RuntimeConfig
|
||||
from hanzoai.session import Session, compact_session, CompactionConfig
|
||||
from hanzoai.mcp import normalize_mcp_name, mcp_tool_name, MCPClient
|
||||
from hanzoai.mcp import MCPClient, mcp_tool_name, normalize_mcp_name
|
||||
from hanzoai.protocols import PermissionMode, PermissionOutcome, PermissionPolicy
|
||||
from hanzoai.session import CompactionConfig, Session, compact_session
|
||||
except ImportError:
|
||||
pass # hanzoai not installed, MCP server still works standalone
|
||||
|
||||
@@ -16,8 +16,6 @@ import json
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
# --- Re-export canonical config types from hanzoai ---
|
||||
from hanzoai.config import (
|
||||
ConfigEntry,
|
||||
@@ -35,6 +33,7 @@ from hanzoai.config import (
|
||||
OAuthConfig,
|
||||
RuntimeConfig,
|
||||
)
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
# --- Re-export tool config ---
|
||||
from .tool_config import (
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import os
|
||||
|
||||
from hanzoai.session import CompactionConfig, CompactionResult, Session, compact_session
|
||||
from mcp.server import FastMCP
|
||||
|
||||
from hanzo_mcp.prompts.compact_conversation import (
|
||||
COMPACT_CONVERSATION_PROMPT,
|
||||
compact_or_prompt,
|
||||
)
|
||||
from hanzoai.session import CompactionConfig, CompactionResult, Session, compact_session
|
||||
from hanzo_mcp.prompts.create_release import CREATE_RELEASE_PROMPT
|
||||
from hanzo_mcp.prompts.enhanced_prompts import (
|
||||
CONFIGURATION_GUIDE_PROMPT,
|
||||
|
||||
+13
-13
@@ -3,32 +3,32 @@
|
||||
Run: .venv/bin/python -m pytest tests/test_auth_pkce.py -v
|
||||
"""
|
||||
|
||||
import os
|
||||
import json
|
||||
import stat
|
||||
import base64
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import stat
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from urllib.parse import parse_qs, urlparse
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
from hanzoai.auth import (
|
||||
ANTHROPIC_AUTHORIZE_URL,
|
||||
OPENAI_ISSUER,
|
||||
HANZO_CLIENT_ID,
|
||||
OPENAI_CLIENT_ID,
|
||||
ANTHROPIC_CLIENT_ID,
|
||||
ANTHROPIC_TOKEN_URL,
|
||||
HANZO_CLIENT_ID,
|
||||
ANTHROPIC_AUTHORIZE_URL,
|
||||
HanzoAuth,
|
||||
OAuthAuthorizationRequest,
|
||||
OAuthCredentialStore,
|
||||
OAuthTokenExchangeRequest,
|
||||
OAuthTokenSet,
|
||||
OPENAI_CLIENT_ID,
|
||||
OPENAI_ISSUER,
|
||||
PkceCodePair,
|
||||
generate_pkce_pair,
|
||||
OAuthTokenSet,
|
||||
OAuthCredentialStore,
|
||||
OAuthAuthorizationRequest,
|
||||
OAuthTokenExchangeRequest,
|
||||
generate_state,
|
||||
generate_pkce_pair,
|
||||
)
|
||||
|
||||
|
||||
|
||||
+9
-10
@@ -2,8 +2,8 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
@@ -11,21 +11,20 @@ import pytest
|
||||
from hanzoai.config import (
|
||||
ConfigEntry,
|
||||
ConfigError,
|
||||
ConfigLoader,
|
||||
ConfigSource,
|
||||
McpClaudeAiProxyConfig,
|
||||
McpOAuthConfig,
|
||||
McpRemoteConfig,
|
||||
McpSdkConfig,
|
||||
McpStdioConfig,
|
||||
McpTransport,
|
||||
McpWsConfig,
|
||||
OAuthConfig,
|
||||
ConfigLoader,
|
||||
ConfigSource,
|
||||
McpSdkConfig,
|
||||
McpTransport,
|
||||
RuntimeConfig,
|
||||
McpOAuthConfig,
|
||||
McpStdioConfig,
|
||||
McpRemoteConfig,
|
||||
McpClaudeAiProxyConfig,
|
||||
_deep_merge,
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Deep merge
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
+6
-7
@@ -1,24 +1,23 @@
|
||||
"""Tests for MCP client implementation."""
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import sys
|
||||
import json
|
||||
import asyncio
|
||||
import textwrap
|
||||
|
||||
import pytest
|
||||
|
||||
from hanzoai.mcp import (
|
||||
JsonRpcError,
|
||||
JsonRpcRequest,
|
||||
JsonRpcResponse,
|
||||
MCPClient,
|
||||
MCPClientError,
|
||||
JsonRpcError,
|
||||
MCPHttpClient,
|
||||
JsonRpcRequest,
|
||||
MCPClientError,
|
||||
JsonRpcResponse,
|
||||
mcp_tool_name,
|
||||
normalize_mcp_name,
|
||||
)
|
||||
|
||||
|
||||
# --- Name normalization tests ---
|
||||
|
||||
|
||||
|
||||
+9
-11
@@ -6,14 +6,12 @@ source file and test name it mirrors.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import hashlib
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
# ── 1. SSE Parser ────────────────────────────────────────────────────────────
|
||||
|
||||
from hanzoai._streaming import SSEDecoder, ServerSentEvent
|
||||
|
||||
|
||||
@@ -117,7 +115,7 @@ def test_sse_comment_only():
|
||||
|
||||
# ── 2. MCP Name Normalization ────────────────────────────────────────────────
|
||||
|
||||
from hanzoai.mcp import normalize_mcp_name, mcp_tool_name
|
||||
from hanzoai.mcp import mcp_tool_name, normalize_mcp_name
|
||||
|
||||
|
||||
# Parity: claw-code/rust/crates/runtime/src/mcp.rs:normalizes_server_names_for_mcp_tooling
|
||||
@@ -147,8 +145,8 @@ def test_mcp_hyphens_kept():
|
||||
|
||||
from hanzoai.protocols import (
|
||||
PermissionMode,
|
||||
PermissionOutcome,
|
||||
PermissionPolicy,
|
||||
PermissionOutcome,
|
||||
PermissionRequest,
|
||||
)
|
||||
|
||||
@@ -189,12 +187,12 @@ def test_permission_tool_override():
|
||||
# ── 4. Session Compaction ────────────────────────────────────────────────────
|
||||
|
||||
from hanzoai.session import (
|
||||
CompactionConfig,
|
||||
ConversationMessage,
|
||||
MessageRole,
|
||||
Session,
|
||||
TextBlock,
|
||||
MessageRole,
|
||||
ToolResultBlock,
|
||||
CompactionConfig,
|
||||
ConversationMessage,
|
||||
compact_session,
|
||||
format_compact_summary,
|
||||
)
|
||||
@@ -302,14 +300,14 @@ def test_pkce_s256_rfc_vector():
|
||||
|
||||
from hanzoai.config import (
|
||||
ConfigEntry,
|
||||
McpWsConfig,
|
||||
ConfigLoader,
|
||||
ConfigSource,
|
||||
McpSdkConfig,
|
||||
McpTransport,
|
||||
McpStdioConfig,
|
||||
McpRemoteConfig,
|
||||
McpWsConfig,
|
||||
McpSdkConfig,
|
||||
McpClaudeAiProxyConfig,
|
||||
McpTransport,
|
||||
_parse_mcp_server,
|
||||
_sanitize_project_config,
|
||||
)
|
||||
|
||||
@@ -7,19 +7,19 @@ from pathlib import Path
|
||||
import pytest
|
||||
|
||||
from hanzoai.session import (
|
||||
CompactionConfig,
|
||||
CompactionResult,
|
||||
ConversationMessage,
|
||||
MessageRole,
|
||||
Session,
|
||||
TextBlock,
|
||||
TokenUsage,
|
||||
ToolResultBlock,
|
||||
MessageRole,
|
||||
ToolUseBlock,
|
||||
compact_session,
|
||||
estimate_session_tokens,
|
||||
format_compact_summary,
|
||||
ToolResultBlock,
|
||||
CompactionConfig,
|
||||
CompactionResult,
|
||||
ConversationMessage,
|
||||
should_compact,
|
||||
compact_session,
|
||||
format_compact_summary,
|
||||
estimate_session_tokens,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
"""Tests for SSE chunking and decoding in hanzoai._streaming."""
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import asyncio
|
||||
from typing import Iterator, AsyncIterator
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent / "pkg" / "hanzoai"))
|
||||
|
||||
from hanzoai._streaming import SSEDecoder, ServerSentEvent
|
||||
|
||||
Reference in New Issue
Block a user