diff --git a/nonebot/drivers/aiohttp.py b/nonebot/drivers/aiohttp.py
index 5c701a94..20ca668f 100644
--- a/nonebot/drivers/aiohttp.py
+++ b/nonebot/drivers/aiohttp.py
@@ -9,18 +9,19 @@ import signal
import asyncio
import threading
from dataclasses import dataclass
-from typing import Set, List, cast, Union, Optional, Callable, Awaitable
+from typing import Set, List, Union, Callable, Optional, Awaitable, cast
import aiohttp
from yarl import URL
from nonebot.log import logger
from nonebot.adapters import Bot
-from nonebot.utils import escape_tag
from nonebot.typing import overrides
+from nonebot.utils import escape_tag
from nonebot.config import Env, Config
-from nonebot.drivers import (ForwardDriver, HTTPPollingSetup, WebSocketSetup,
- HTTPRequest, WebSocket as BaseWebSocket)
+from nonebot.drivers import WebSocket as BaseWebSocket
+from nonebot.drivers import (HTTPRequest, ForwardDriver, WebSocketSetup,
+ HTTPPollingSetup)
STARTUP_FUNC = Callable[[], Awaitable[None]]
SHUTDOWN_FUNC = Callable[[], Awaitable[None]]
@@ -242,8 +243,8 @@ class Driver(ForwardDriver):
setup_ = setup
except Exception as e:
logger.opt(colors=True, exception=e).error(
- f"Error while parsing setup {setup!r}."
- )
+ "Error while parsing setup "
+ f"{escape_tag(repr(setup))}.")
await asyncio.sleep(3)
continue
@@ -324,8 +325,8 @@ class Driver(ForwardDriver):
setup_ = setup
except Exception as e:
logger.opt(colors=True, exception=e).error(
- f"Error while parsing setup {setup!r}."
- )
+ "Error while parsing setup "
+ f"{escape_tag(repr(setup))}.")
await asyncio.sleep(3)
continue
diff --git a/nonebot/drivers/fastapi.py b/nonebot/drivers/fastapi.py
index aacc24aa..bd7b7ab9 100644
--- a/nonebot/drivers/fastapi.py
+++ b/nonebot/drivers/fastapi.py
@@ -13,26 +13,27 @@ FastAPI 驱动适配
import asyncio
import logging
from dataclasses import dataclass
-from typing import List, cast, Union, Optional, Callable, Awaitable
+from typing import List, Union, Callable, Optional, Awaitable, cast
import httpx
import uvicorn
from pydantic import BaseSettings
from fastapi.responses import Response
from websockets.exceptions import ConnectionClosed
-from fastapi import status, Request, FastAPI, HTTPException
+from fastapi import FastAPI, Request, HTTPException, status
+from starlette.websockets import WebSocket as FastAPIWebSocket
+from starlette.websockets import WebSocketState, WebSocketDisconnect
from websockets.legacy.client import Connect, WebSocketClientProtocol
-from starlette.websockets import (WebSocketState, WebSocketDisconnect, WebSocket
- as FastAPIWebSocket)
+from nonebot.config import Env
from nonebot.log import logger
from nonebot.adapters import Bot
-from nonebot.utils import escape_tag
from nonebot.typing import overrides
-from nonebot.config import Env, Config as NoneBotConfig
-from nonebot.drivers import (ReverseDriver, ForwardDriver, HTTPPollingSetup,
- WebSocketSetup, HTTPRequest, WebSocket as
- BaseWebSocket)
+from nonebot.utils import escape_tag
+from nonebot.config import Config as NoneBotConfig
+from nonebot.drivers import WebSocket as BaseWebSocket
+from nonebot.drivers import (HTTPRequest, ForwardDriver, ReverseDriver,
+ WebSocketSetup, HTTPPollingSetup)
HTTPPOLLING_SETUP = Union[HTTPPollingSetup,
Callable[[], Awaitable[HTTPPollingSetup]]]
@@ -357,8 +358,8 @@ class Driver(ReverseDriver, ForwardDriver):
setup_ = setup
except Exception as e:
logger.opt(colors=True, exception=e).error(
- f"Error while parsing setup {setup!r}."
- )
+ "Error while parsing setup "
+ f"{escape_tag(repr(setup))}.")
await asyncio.sleep(3)
continue
@@ -422,8 +423,8 @@ class Driver(ReverseDriver, ForwardDriver):
setup_ = setup
except Exception as e:
logger.opt(colors=True, exception=e).error(
- f"Error while parsing setup {setup!r}."
- )
+ "Error while parsing setup "
+ f"{escape_tag(repr(setup))}.")
await asyncio.sleep(3)
continue