Compare commits

...

2 commits

Author SHA1 Message Date
3bbfb7b692
refactor: use more None type annotations
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2025-03-10 00:25:35 +03:00
8b97a60a34
refactor: explicitly define parameter types
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2025-03-10 00:21:20 +03:00
3 changed files with 7 additions and 5 deletions

View file

@ -1,7 +1,7 @@
import re
def humanize_tags_from_json(value, default):
def humanize_tags_from_json(value: str, default: str):
if value != "":
output = str()
tags = value.split()
@ -14,7 +14,7 @@ def humanize_tags_from_json(value, default):
return default
def format_rating(value):
def format_rating(value: str):
match value:
case "g":
# Negative Squared Latin Capital Letter G

View file

@ -1,3 +1,4 @@
from configparser import ConfigParser
from uuid import uuid4
import requests
@ -31,7 +32,8 @@ async def inline_query(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
await answer_query(update, query, config, data)
async def answer_query(update, query, config, data):
async def answer_query(update: Update, query: str,
config: ConfigParser, data) -> None:
characters = humanize_tags_from_json(data['tag_string_character'], "no characters")
copyrights = humanize_tags_from_json(data['tag_string_copyright'], "unknown copyright")
artists = humanize_tags_from_json(data['tag_string_artist'], "unknown artist")
@ -63,7 +65,7 @@ async def answer_query(update, query, config, data):
await update.inline_query.answer(results)
async def invalid_query(update, query):
async def invalid_query(update: Update, query: str) -> None:
results = [
InlineQueryResultArticle(
id=str(uuid4()),

View file

@ -33,7 +33,7 @@ def main() -> None:
application.run_polling(allowed_updates=Update.ALL_TYPES)
def validate_config():
def validate_config() -> None:
# noinspection PyBroadException
try:
response = requests.get(f"https://{config.get('Service', 'Domain')}/profile.json")