mirror of
https://github.com/nonebot/nonebot2.git
synced 2026-04-21 00:35:48 +00:00
♻️ remove unnecessary exclude_unset call
This commit is contained in:
@@ -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(
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user