From 1ccfbbbe0a5cde0014f2ac1e2f3a8c0807b0663b Mon Sep 17 00:00:00 2001 From: suyiiyii Date: Sat, 21 Dec 2024 21:10:06 +0800 Subject: [PATCH] :recycle: refactor code --- nonebot_bison/admin_page/api.py | 3 --- nonebot_bison/metrics.py | 2 +- nonebot_bison/scheduler/scheduler.py | 12 ++---------- nonebot_bison/utils/site.py | 3 +-- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/nonebot_bison/admin_page/api.py b/nonebot_bison/admin_page/api.py index bc0afe81..c816e757 100644 --- a/nonebot_bison/admin_page/api.py +++ b/nonebot_bison/admin_page/api.py @@ -4,13 +4,10 @@ from fastapi.exceptions import HTTPException from fastapi.param_functions import Depends from fastapi.routing import APIRouter -from fastapi.param_functions import Depends -from fastapi.exceptions import HTTPException from fastapi.security.oauth2 import OAuth2PasswordBearer import nonebot from nonebot_plugin_saa import TargetQQGroup from nonebot_plugin_saa.auto_select_bot import get_bot -from fastapi.security.oauth2 import OAuth2PasswordBearer from nonebot_bison.apis import check_sub_target from nonebot_bison.config import NoSuchSubscribeException, NoSuchTargetException, NoSuchUserException, config diff --git a/nonebot_bison/metrics.py b/nonebot_bison/metrics.py index 6041f0a4..93339cfd 100644 --- a/nonebot_bison/metrics.py +++ b/nonebot_bison/metrics.py @@ -3,7 +3,7 @@ from nonebot import require require("nonebot_plugin_prometheus") -from nonebot_plugin_prometheus import Gauge, Counter, Histogram +from nonebot_plugin_prometheus import Counter, Gauge, Histogram # Request counter request_counter = Counter( diff --git a/nonebot_bison/scheduler/scheduler.py b/nonebot_bison/scheduler/scheduler.py index 853547c6..448da108 100644 --- a/nonebot_bison/scheduler/scheduler.py +++ b/nonebot_bison/scheduler/scheduler.py @@ -2,21 +2,13 @@ from collections.abc import Callable from dataclasses import dataclass +from apscheduler.events import EVENT_JOB_MAX_INSTANCES from nonebot.log import logger from nonebot_plugin_apscheduler import scheduler -from apscheduler.events import EVENT_JOB_MAX_INSTANCES from nonebot_plugin_saa.utils.exceptions import NoBotFound -from nonebot_bison.utils import ClientManager -from nonebot_bison.metrics import sent_counter, request_counter, render_histogram, request_histogram - -from ..config import config -from ..send import send_msgs -from ..types import Target, SubUnit -from ..platform import platform_manager -from ..utils import Site, ProcessContext -from ..utils.site import SkipRequestException from nonebot_bison.config import config +from nonebot_bison.metrics import render_histogram, request_counter, request_histogram, sent_counter from nonebot_bison.platform import platform_manager from nonebot_bison.send import send_msgs from nonebot_bison.types import SubUnit, Target diff --git a/nonebot_bison/utils/site.py b/nonebot_bison/utils/site.py index 5aa65d6c..14e6e3f4 100644 --- a/nonebot_bison/utils/site.py +++ b/nonebot_bison/utils/site.py @@ -11,11 +11,10 @@ from nonebot_bison.config import config from nonebot_bison.config.db_model import Cookie +from nonebot_bison.metrics import cookie_choose_counter from nonebot_bison.types import Target from .http import http_client -from ..config.db_model import Cookie -from ..metrics import cookie_choose_counter class ClientManager(ABC):