Skip to content

Commit 2332bda

Browse files
committed
[melobot] Tiny modifies for some functions and vars
1 parent 12c0b48 commit 2332bda

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/melobot/bot/dispatch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __init__(self) -> None:
5858
def internal_add(self, *handlers: EventHandler) -> None:
5959
for h in handlers:
6060
self.handlers.setdefault(h.flow.priority, set()).add(h)
61-
h.flow.on_priority_reset(lambda new_prior, h=h: self.reset(h, new_prior))
61+
h.flow.on_priority_reset(lambda new_prior, h=h: self._reset(h, new_prior))
6262

6363
async def add(self, *handlers: EventHandler) -> None:
6464
async with self.broadcast_ctrl.write():
@@ -76,7 +76,7 @@ async def expire(self, *handlers: EventHandler) -> None:
7676
async with self.broadcast_ctrl.write():
7777
await self._remove(*handlers)
7878

79-
async def reset(self, handler: EventHandler, new_prior: HandleLevel) -> None:
79+
async def _reset(self, handler: EventHandler, new_prior: HandleLevel) -> None:
8080
if handler.flow.priority == new_prior:
8181
return
8282

src/melobot/session/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ async def suspend(timeout: float | None = None) -> bool:
264264
:param timeout: 挂起后再唤醒的超时时间, 为空则永不超时
265265
:return: 如果为 `False` 则表明唤醒超时
266266
"""
267-
return await SessionCtx().get().__suspend__(timeout)
267+
return await _SESSION_CTX.get().__suspend__(timeout)
268268

269269

270270
def enter_session(

src/melobot/utils.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
ContextManager,
1515
Coroutine,
1616
Literal,
17-
TypeVar,
1817
cast,
1918
)
2019

21-
from typing_extensions import Self
20+
from typing_extensions import Self, TypeVar
2221

2322
from .exceptions import ValidateError
2423
from .typ import AsyncCallable, P, T
@@ -349,10 +348,10 @@ def to_coro(
349348
return to_async(obj)(*args, **kwargs) # type: ignore[arg-type]
350349

351350

352-
CbRetT = TypeVar("CbRetT")
353-
FirstCbRetT = TypeVar("FirstCbRetT")
354-
SecondCbRetT = TypeVar("SecondCbRetT")
355-
OriginRetT = TypeVar("OriginRetT")
351+
CbRetT = TypeVar("CbRetT", default=Any)
352+
FirstCbRetT = TypeVar("FirstCbRetT", default=Any)
353+
SecondCbRetT = TypeVar("SecondCbRetT", default=Any)
354+
OriginRetT = TypeVar("OriginRetT", default=Any)
356355

357356

358357
def if_not(

0 commit comments

Comments
 (0)