♻️ remove unnecessary exclude_unset call

This commit is contained in:
StarHeartHunt
2026-04-20 11:34:25 +08:00
parent 7d55beb8e7
commit abdc28b0b5

View File

@@ -36,7 +36,7 @@ from nonebot.drivers import WebSocket as BaseWebSocket
from nonebot.drivers.none import Driver as NoneDriver from nonebot.drivers.none import Driver as NoneDriver
from nonebot.exception import WebSocketClosed from nonebot.exception import WebSocketClosed
from nonebot.log import LoguruHandler from nonebot.log import LoguruHandler
from nonebot.utils import UNSET, exclude_unset from nonebot.utils import UNSET, UnsetType, exclude_unset
try: try:
from websockets import ClientConnection, ConnectionClosed, connect from websockets import ClientConnection, ConnectionClosed, connect
@@ -77,18 +77,17 @@ class Mixin(WebSocketClientMixin):
@override @override
@asynccontextmanager @asynccontextmanager
async def websocket(self, setup: Request) -> AsyncGenerator["WebSocket", None]: async def websocket(self, setup: Request) -> AsyncGenerator["WebSocket", None]:
timeout_kwargs: dict[str, float | None] = {} timeout_kwargs: dict[str, float | None | UnsetType] = {}
if isinstance(setup.timeout, Timeout): if isinstance(setup.timeout, Timeout):
open_timeout = ( open_timeout = (
setup.timeout.connect or setup.timeout.read or setup.timeout.total setup.timeout.connect or setup.timeout.read or setup.timeout.total
) )
timeout_kwargs = exclude_unset( timeout_kwargs = {
{ "open_timeout": open_timeout,
"open_timeout": open_timeout, "close_timeout": setup.timeout.close,
"close_timeout": setup.timeout.close, "ping_timeout": setup.timeout.ping,
"ping_timeout": setup.timeout.ping, }
}
)
elif setup.timeout is not UNSET: elif setup.timeout is not UNSET:
timeout_kwargs = { timeout_kwargs = {
"open_timeout": setup.timeout, "open_timeout": setup.timeout,
@@ -99,13 +98,11 @@ class Mixin(WebSocketClientMixin):
open_timeout = ( open_timeout = (
DEFAULT_TIMEOUT.connect or DEFAULT_TIMEOUT.read or DEFAULT_TIMEOUT.total DEFAULT_TIMEOUT.connect or DEFAULT_TIMEOUT.read or DEFAULT_TIMEOUT.total
) )
timeout_kwargs = exclude_unset( timeout_kwargs = {
{ "open_timeout": open_timeout,
"open_timeout": open_timeout, "close_timeout": DEFAULT_TIMEOUT.close,
"close_timeout": DEFAULT_TIMEOUT.close, "ping_timeout": DEFAULT_TIMEOUT.ping,
"ping_timeout": DEFAULT_TIMEOUT.ping, }
}
)
kwargs = exclude_unset( kwargs = exclude_unset(
{ {