mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-21 09:02:32 +00:00
ci: add ruff lint check for unused imports and variables
Add CI step to detect unused imports (F401) and unused variables (F841) with ruff. Clean up existing violations: - Remove unused Consolidator import in agent/__init__.py - Remove unused re import in agent/loop.py - Remove unused Path import in channels/feishu.py - Remove unused ContentRepositoryConfigError import in channels/matrix.py - Remove unused field and CommandHandler imports in channels/telegram.py - Remove unused exception variable in channels/weixin.py
This commit is contained in:
parent
f4904c4bdf
commit
5ee96721f7
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@ -30,5 +30,8 @@ jobs:
|
|||||||
- name: Install all dependencies
|
- name: Install all dependencies
|
||||||
run: uv sync --all-extras
|
run: uv sync --all-extras
|
||||||
|
|
||||||
|
- name: Lint with ruff
|
||||||
|
run: uv run ruff check nanobot --select F401,F841
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: uv run pytest tests/
|
run: uv run pytest tests/
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
from nanobot.agent.context import ContextBuilder
|
from nanobot.agent.context import ContextBuilder
|
||||||
from nanobot.agent.hook import AgentHook, AgentHookContext, CompositeHook
|
from nanobot.agent.hook import AgentHook, AgentHookContext, CompositeHook
|
||||||
from nanobot.agent.loop import AgentLoop
|
from nanobot.agent.loop import AgentLoop
|
||||||
from nanobot.agent.memory import Consolidator, Dream, MemoryStore
|
from nanobot.agent.memory import Dream, MemoryStore
|
||||||
from nanobot.agent.skills import SkillsLoader
|
from nanobot.agent.skills import SkillsLoader
|
||||||
from nanobot.agent.subagent import SubagentManager
|
from nanobot.agent.subagent import SubagentManager
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,6 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import re
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
from contextlib import AsyncExitStack, nullcontext
|
from contextlib import AsyncExitStack, nullcontext
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import time
|
|||||||
import uuid
|
import uuid
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
|
||||||
from typing import Any, Literal
|
from typing import Any, Literal
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|||||||
@ -18,7 +18,6 @@ try:
|
|||||||
from nio import (
|
from nio import (
|
||||||
AsyncClient,
|
AsyncClient,
|
||||||
AsyncClientConfig,
|
AsyncClientConfig,
|
||||||
ContentRepositoryConfigError,
|
|
||||||
DownloadError,
|
DownloadError,
|
||||||
InviteEvent,
|
InviteEvent,
|
||||||
JoinError,
|
JoinError,
|
||||||
|
|||||||
@ -6,14 +6,14 @@ import asyncio
|
|||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import unicodedata
|
import unicodedata
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass
|
||||||
from typing import Any, Literal
|
from typing import Any, Literal
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pydantic import Field
|
from pydantic import Field
|
||||||
from telegram import BotCommand, ReactionTypeEmoji, ReplyParameters, Update
|
from telegram import BotCommand, ReactionTypeEmoji, ReplyParameters, Update
|
||||||
from telegram.error import BadRequest, NetworkError, TimedOut
|
from telegram.error import BadRequest, NetworkError, TimedOut
|
||||||
from telegram.ext import Application, CommandHandler, ContextTypes, MessageHandler, filters
|
from telegram.ext import Application, ContextTypes, MessageHandler, filters
|
||||||
from telegram.request import HTTPXRequest
|
from telegram.request import HTTPXRequest
|
||||||
|
|
||||||
from nanobot.bus.events import OutboundMessage
|
from nanobot.bus.events import OutboundMessage
|
||||||
|
|||||||
@ -484,7 +484,7 @@ class WeixinChannel(BaseChannel):
|
|||||||
except httpx.TimeoutException:
|
except httpx.TimeoutException:
|
||||||
# Normal for long-poll, just retry
|
# Normal for long-poll, just retry
|
||||||
continue
|
continue
|
||||||
except Exception as e:
|
except Exception:
|
||||||
if not self._running:
|
if not self._running:
|
||||||
break
|
break
|
||||||
consecutive_failures += 1
|
consecutive_failures += 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user