Fix type hints and small bugs

This commit is contained in:
Richard Chien
2018-10-16 01:03:50 +08:00
parent 73e891d521
commit 0046ebacac
12 changed files with 98 additions and 86 deletions

View File

@ -1,25 +1,21 @@
from typing import Union, Callable, Dict, Any, List, Sequence
from . import NoneBot
from .helpers import send, send_expr
from .typing import Context_T, Message_T, Expression_T
class BaseSession:
__slots__ = ('bot', 'ctx')
def __init__(self, bot: NoneBot, ctx: Dict[str, Any]):
def __init__(self, bot: NoneBot, ctx: Context_T):
self.bot = bot
self.ctx = ctx
async def send(self,
message: Union[str, Dict[str, Any], List[Dict[str, Any]]],
*, ignore_failure: bool = True) -> None:
async def send(self, message: Message_T, *,
ignore_failure: bool = True) -> None:
"""Send a message ignoring failure by default."""
return await send(self.bot, self.ctx, message,
ignore_failure=ignore_failure)
async def send_expr(self,
expr: Union[str, Sequence[str], Callable],
**kwargs):
async def send_expr(self, expr: Expression_T, **kwargs):
"""Sending a expression message ignoring failure by default."""
return await send_expr(self.bot, self.ctx, expr, **kwargs)