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:
Jiajun Xie 2026-04-06 19:35:06 +08:00 committed by Xubin Ren
parent f4904c4bdf
commit 5ee96721f7
7 changed files with 7 additions and 7 deletions

View File

@ -30,5 +30,8 @@ jobs:
- name: Install all dependencies
run: uv sync --all-extras
- name: Lint with ruff
run: uv run ruff check nanobot --select F401,F841
- name: Run tests
run: uv run pytest tests/

View File

@ -3,7 +3,7 @@
from nanobot.agent.context import ContextBuilder
from nanobot.agent.hook import AgentHook, AgentHookContext, CompositeHook
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.subagent import SubagentManager

View File

@ -4,7 +4,6 @@ from __future__ import annotations
import asyncio
import json
import re
import os
import time
from contextlib import AsyncExitStack, nullcontext

View File

@ -9,7 +9,6 @@ import time
import uuid
from collections import OrderedDict
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Literal
from loguru import logger

View File

@ -18,7 +18,6 @@ try:
from nio import (
AsyncClient,
AsyncClientConfig,
ContentRepositoryConfigError,
DownloadError,
InviteEvent,
JoinError,

View File

@ -6,14 +6,14 @@ import asyncio
import re
import time
import unicodedata
from dataclasses import dataclass, field
from dataclasses import dataclass
from typing import Any, Literal
from loguru import logger
from pydantic import Field
from telegram import BotCommand, ReactionTypeEmoji, ReplyParameters, Update
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 nanobot.bus.events import OutboundMessage

View File

@ -484,7 +484,7 @@ class WeixinChannel(BaseChannel):
except httpx.TimeoutException:
# Normal for long-poll, just retry
continue
except Exception as e:
except Exception:
if not self._running:
break
consecutive_failures += 1