Improved docstrings and linting

This commit is contained in:
Profitroll 2022-12-14 14:05:09 +01:00
parent 4541c84eb9
commit d4256f0c8c
1 changed files with 18 additions and 5 deletions

View File

@ -100,7 +100,7 @@ class HoloUser():
voice: Union[str, Voice, None] = None, voice: Union[str, Voice, None] = None,
adm_origin: bool = False, adm_origin: bool = False,
adm_context: bool = False adm_context: bool = False
): ) -> None:
"""Send a message to user """Send a message to user
### Args: ### Args:
@ -210,7 +210,7 @@ class HoloUser():
logWrite(f"Could not notify admin about failure when sending message! Admin has never interacted with bot!") logWrite(f"Could not notify admin about failure when sending message! Admin has never interacted with bot!")
await context.reply_text(locale("message_error", "message"), quote=should_quote(context)) await context.reply_text(locale("message_error", "message"), quote=should_quote(context))
async def set_label(self, chat: Chat, label: str): async def set_label(self, chat: Chat, label: str) -> None:
"""Set label in destination group """Set label in destination group
### Args: ### Args:
@ -223,7 +223,7 @@ class HoloUser():
if (not await isAnAdmin(self.id)) and (chat.id == configGet("admin_group")): if (not await isAnAdmin(self.id)) and (chat.id == configGet("admin_group")):
await app.set_administrator_title(configGet("destination_group"), self.id, label) await app.set_administrator_title(configGet("destination_group"), self.id, label)
async def reset_label(self, chat: Chat): async def reset_label(self, chat: Chat) -> None:
"""Reset label in destination group """Reset label in destination group
### Args: ### Args:
@ -238,13 +238,20 @@ class HoloUser():
)) ))
def application_state(self) -> tuple[Literal["none", "fill", "approved", "rejected"], bool]: def application_state(self) -> tuple[Literal["none", "fill", "approved", "rejected"], bool]:
"""Check the current state of application in tmp collection
### Returns:
* `tuple[Literal["none", "fill", "approved", "rejected"], bool]`: First element is an enum of a state and the second one is whether application is complete.
"""
tmp_application = col_tmp.find_one({"user": self.id, "type": "application"}) tmp_application = col_tmp.find_one({"user": self.id, "type": "application"})
if tmp_application is None: if tmp_application is None:
return "none", False return "none", False
else: else:
return tmp_application["state"], tmp_application["complete"] return tmp_application["state"], tmp_application["complete"]
def application_restart(self): def application_restart(self) -> None:
"""Reset application of a user in tmp collection and replace it with an empty one
"""
doc = { doc = {
"user": self.id, "user": self.id,
"type": "application", "type": "application",
@ -272,7 +279,13 @@ class HoloUser():
col_tmp.delete_one({"user": self.id, "type": "application"}) col_tmp.delete_one({"user": self.id, "type": "application"})
col_tmp.insert_one(document=doc) col_tmp.insert_one(document=doc)
async def application_next(self, query: str, msg: Union[Message, None] = None): async def application_next(self, query: str, msg: Message) -> None:
"""Move on filling application of user
### Args:
* query (`str`): Some kind of input
* msg (`Message`): Message that should receive replies
"""
if col_tmp.find_one({"user": self.id, "type": "application"}) is None: if col_tmp.find_one({"user": self.id, "type": "application"}) is None: