From 0ffa727fb7151892fe4f24f0272eef8147dfa338 Mon Sep 17 00:00:00 2001 From: themanyfaceddemon Date: Sun, 11 Aug 2024 20:40:52 +0300 Subject: [PATCH] fix typing in server --- DMBotNetwork/server.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/DMBotNetwork/server.py b/DMBotNetwork/server.py index 85561fd..2257159 100644 --- a/DMBotNetwork/server.py +++ b/DMBotNetwork/server.py @@ -23,9 +23,8 @@ def __init__(self, host: str, port: int, db_path: Path, owner_password: str = 'o self._port: int = port self._is_online: bool = False - self._connection = None - - self._server = None + self._connection: Optional[aiosqlite.Connection] = None + self._server: Optional[asyncio.AbstractServer] = None self._db_path: Path = db_path self._owner_password: str = owner_password @@ -54,7 +53,7 @@ async def _init_db(self, db_path: Path, owner_password: str) -> None: ) await self._connection.commit() - async def _check_password(self, password: str, db_password: bytes): + async def _check_password(self, password: str, db_password: bytes) -> bool: loop = asyncio.get_running_loop() return await loop.run_in_executor(None, bcrypt.checkpw, password.encode(), db_password) @@ -156,7 +155,7 @@ async def db_change_access(self, username: str, new_access: Optional[Dict[str, b logging.error(f"Error changing access for user {username}: {e}") # Client work - async def _req_auth(self, reader: StreamReader, writer: StreamWriter) -> str: + async def _req_auth(self, reader: StreamReader, writer: StreamWriter) -> Optional[str]: try: await self.send_data(writer, {"action": "auth"}) user_data = await asyncio.wait_for(self.receive_data(reader), timeout=self.TIME_OUT)