mirror of
https://github.com/Alishahryar1/free-claude-code.git
synced 2026-04-28 03:20:01 +00:00
fixed linter errors
This commit is contained in:
parent
43a0786fc1
commit
303767e346
28 changed files with 20 additions and 49 deletions
|
|
@ -1,6 +1,5 @@
|
|||
"""FastAPI route handlers."""
|
||||
|
||||
import json
|
||||
import logging
|
||||
import uuid
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"""CLI event parser for Claude Code CLI output."""
|
||||
|
||||
import logging
|
||||
from typing import Dict, List, Optional
|
||||
from typing import Dict, List
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class CLISession:
|
|||
"--dangerously-skip-permissions",
|
||||
"--verbose",
|
||||
]
|
||||
logger.info(f"Starting new Claude session")
|
||||
logger.info("Starting new Claude session")
|
||||
|
||||
if self.allowed_dirs:
|
||||
for d in self.allowed_dirs:
|
||||
|
|
@ -149,7 +149,7 @@ class CLISession:
|
|||
logger.error(f"Claude CLI Stderr: {stderr_text}")
|
||||
# Yield stderr as error event so it shows in UI
|
||||
if stderr_text:
|
||||
logger.info(f"CLI_SESSION: Yielding error event from stderr")
|
||||
logger.info("CLI_SESSION: Yielding error event from stderr")
|
||||
yield {"type": "error", "error": {"message": stderr_text}}
|
||||
|
||||
return_code = await self.process.wait()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"""Abstract base class for messaging platforms."""
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Callable, Awaitable, Optional, Any, Protocol, Tuple, runtime_checkable
|
||||
from typing import Callable, Awaitable, Optional, Protocol, Tuple, runtime_checkable
|
||||
from .models import IncomingMessage
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import asyncio
|
|||
import logging
|
||||
from typing import Optional, TYPE_CHECKING
|
||||
|
||||
from .base import MessagingPlatform, SessionManagerInterface, CLISession
|
||||
from .base import MessagingPlatform, SessionManagerInterface
|
||||
from .models import IncomingMessage
|
||||
from .session import SessionStore
|
||||
from .tree_queue import TreeQueueManager, MessageNode, MessageState
|
||||
|
|
@ -279,7 +279,7 @@ class ClaudeMessageHandler:
|
|||
elif parsed["type"] == "complete":
|
||||
if not any(components.values()):
|
||||
components["content"].append("Done.")
|
||||
logger.info(f"HANDLER: Task complete, updating UI")
|
||||
logger.info("HANDLER: Task complete, updating UI")
|
||||
# Always force final complete status to bypass flood wait
|
||||
await update_ui("✅ **Complete**", force=True)
|
||||
|
||||
|
|
@ -298,7 +298,7 @@ class ClaudeMessageHandler:
|
|||
f"HANDLER: Error event received: {error_msg[:200]}"
|
||||
)
|
||||
components["errors"].append(error_msg)
|
||||
logger.info(f"HANDLER: Updating UI with error status")
|
||||
logger.info("HANDLER: Updating UI with error status")
|
||||
# Always force error status to bypass flood wait
|
||||
await update_ui("❌ **Error**", force=True)
|
||||
if tree:
|
||||
|
|
@ -313,7 +313,7 @@ class ClaudeMessageHandler:
|
|||
self.platform.queue_edit_message(
|
||||
child.incoming.chat_id,
|
||||
child.status_message_id,
|
||||
f"❌ **Cancelled:** Parent task failed",
|
||||
"❌ **Cancelled:** Parent task failed",
|
||||
parse_mode="markdown",
|
||||
)
|
||||
)
|
||||
|
|
@ -335,7 +335,7 @@ class ClaudeMessageHandler:
|
|||
self.platform.queue_edit_message(
|
||||
child.incoming.chat_id,
|
||||
child.status_message_id,
|
||||
f"❌ **Cancelled:** Parent task was stopped",
|
||||
"❌ **Cancelled:** Parent task was stopped",
|
||||
parse_mode="markdown",
|
||||
)
|
||||
)
|
||||
|
|
@ -359,7 +359,7 @@ class ClaudeMessageHandler:
|
|||
self.platform.queue_edit_message(
|
||||
child.incoming.chat_id,
|
||||
child.status_message_id,
|
||||
f"❌ **Cancelled:** Parent task failed",
|
||||
"❌ **Cancelled:** Parent task failed",
|
||||
parse_mode="markdown",
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import os
|
|||
# This must be set BEFORE importing telegram.error
|
||||
os.environ["PTB_TIMEDELTA"] = "1"
|
||||
|
||||
from typing import Callable, Awaitable, Optional, Any, Dict
|
||||
from typing import Callable, Awaitable, Optional, Any
|
||||
|
||||
from .base import MessagingPlatform
|
||||
from .models import IncomingMessage
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"""Unified exception hierarchy for providers."""
|
||||
|
||||
from typing import Optional, Any
|
||||
from typing import Any
|
||||
|
||||
|
||||
class ProviderError(Exception):
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import json
|
|||
import logging
|
||||
import os
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ NVIDIA NIM provider functionality:
|
|||
|
||||
import json
|
||||
import logging
|
||||
from typing import Any, Dict, AsyncIterator
|
||||
from typing import Any, Dict
|
||||
|
||||
from .utils import AnthropicToOpenAIConverter, map_stop_reason, extract_think_content
|
||||
from .exceptions import (
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import logging
|
|||
import os
|
||||
import json
|
||||
import uuid
|
||||
from typing import Dict, Any, AsyncIterator
|
||||
from typing import Any, AsyncIterator
|
||||
|
||||
import httpx
|
||||
from httpx import TimeoutException, ConnectTimeout
|
||||
|
|
@ -16,15 +16,9 @@ from .utils import (
|
|||
ThinkTagParser,
|
||||
HeuristicToolParser,
|
||||
ContentType,
|
||||
extract_think_content,
|
||||
extract_reasoning_from_delta,
|
||||
AnthropicToOpenAIConverter,
|
||||
)
|
||||
from .exceptions import (
|
||||
AuthenticationError,
|
||||
InvalidRequestError,
|
||||
RateLimitError,
|
||||
OverloadedError,
|
||||
APIError,
|
||||
)
|
||||
from .nvidia_mixins import (
|
||||
|
|
@ -73,7 +67,7 @@ class NvidiaNimProvider(
|
|||
message_id = f"msg_{uuid.uuid4()}"
|
||||
sse = SSEBuilder(message_id, request.model, input_tokens)
|
||||
error_msg = "⏱️ Global rate limit active. Resuming now..."
|
||||
logger.info(f"NIM_STREAM: Reactive block detected, notified user")
|
||||
logger.info("NIM_STREAM: Reactive block detected, notified user")
|
||||
yield sse.message_start()
|
||||
for event in sse.emit_error(error_msg):
|
||||
yield event
|
||||
|
|
@ -179,7 +173,7 @@ class NvidiaNimProvider(
|
|||
error_message = (
|
||||
f"⏱️ API Timeout ({timeout_type}): Request exceeded time limit"
|
||||
)
|
||||
logger.info(f"NIM_STREAM: Emitting SSE error event for timeout")
|
||||
logger.info("NIM_STREAM: Emitting SSE error event for timeout")
|
||||
except Exception as e:
|
||||
logger.error(f"NIM_ERROR: {type(e).__name__}: {e}")
|
||||
error_occurred = True
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import json
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Optional, Dict, Any, Iterator, List
|
||||
from typing import Optional, Dict, Any, Iterator
|
||||
|
||||
try:
|
||||
import tiktoken
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from api.app import app
|
||||
from api.dependencies import get_provider
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import pytest
|
||||
import asyncio
|
||||
import json
|
||||
import os
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
"""Tests for config/settings.py"""
|
||||
|
||||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
class TestSettings:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import json
|
||||
import pytest
|
||||
from providers.utils.message_converter import AnthropicToOpenAIConverter
|
||||
|
||||
# --- Mock Classes ---
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import pytest
|
||||
import asyncio
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from api.dependencies import get_provider, get_settings, cleanup_provider
|
||||
from providers.nvidia_nim import NvidiaNimProvider
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import pytest
|
||||
from messaging.event_parser import parse_cli_event
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import pytest
|
||||
import asyncio
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from messaging.handler import ClaudeMessageHandler
|
||||
from messaging.models import IncomingMessage
|
||||
from messaging.tree_queue import MessageState
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import asyncio
|
|||
import time
|
||||
import os
|
||||
import logging
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
# Set environment variables relative to test execution
|
||||
os.environ["MESSAGING_RATE_LIMIT"] = "1"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import pytest
|
|||
import json
|
||||
import os
|
||||
from datetime import datetime, timedelta
|
||||
from unittest.mock import AsyncMock, MagicMock, patch, mock_open
|
||||
from unittest.mock import patch
|
||||
|
||||
# --- Existing Tests ---
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import pytest
|
||||
from providers.model_utils import (
|
||||
strip_provider_prefixes,
|
||||
is_claude_model,
|
||||
|
|
|
|||
|
|
@ -4,12 +4,8 @@ import httpx
|
|||
from unittest.mock import MagicMock, AsyncMock, patch
|
||||
from providers.nvidia_nim import (
|
||||
NvidiaNimProvider,
|
||||
RateLimitError,
|
||||
APIError,
|
||||
OverloadedError,
|
||||
)
|
||||
from providers.base import ProviderConfig
|
||||
from providers.utils import ContentType
|
||||
|
||||
|
||||
# Mock data classes
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import pytest
|
||||
from providers.utils.think_parser import ThinkTagParser, ContentType
|
||||
from providers.utils.heuristic_tool_parser import HeuristicToolParser
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import asyncio
|
|||
import time
|
||||
import os
|
||||
import logging
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from providers.rate_limit import GlobalRateLimiter
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import pytest
|
||||
import asyncio
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from messaging.telegram import TelegramPlatform
|
||||
from telegram.error import NetworkError, RetryAfter, TelegramError
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
"""Tests for api/request_utils.py module."""
|
||||
|
||||
import pytest
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from api.request_utils import (
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import pytest
|
||||
import asyncio
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from messaging.telegram import TelegramPlatform, TELEGRAM_AVAILABLE
|
||||
from messaging.models import IncomingMessage
|
||||
from messaging.telegram import TelegramPlatform
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import pytest
|
||||
import asyncio
|
||||
from datetime import datetime
|
||||
|
||||
from messaging.tree_queue import (
|
||||
MessageState,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue