diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 38b5d08..d34c5ae 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.9.9' + rev: 'v0.4.3' hooks: - id: ruff args: [ --fix, --exit-non-zero-on-fix ] diff --git a/app/commands/commands.py b/app/commands/commands.py index cfcc5e7..ff295c4 100644 --- a/app/commands/commands.py +++ b/app/commands/commands.py @@ -65,7 +65,7 @@ def get(key: str) -> str | None: contacts = "" if constants.CONTACTS: contacts_list = "\n".join( - f'- {g("type")}: {a(g("text"), g("url"))}' # type: ignore[arg-type] + f"- {g('type')}: {a(g('text'), g('url'))}" # type: ignore[arg-type] for c in constants.CONTACTS if all(map(c.get, ("type", "text", "url"))) if (g := get_by_lang(c)) # type: ignore[arg-type] diff --git a/app/constants/__init__.py b/app/constants/__init__.py index 33e93f7..cca272f 100644 --- a/app/constants/__init__.py +++ b/app/constants/__init__.py @@ -66,7 +66,7 @@ ENABLE_MONGO = MONGO_URL and MONGO_DB if not ENABLE_MONGO: print( - "Bot requires MongoDB to work.\n" "Please, set MONGO_URL and MONGO_DB envs.", + "Bot requires MongoDB to work.\nPlease, set MONGO_URL and MONGO_DB envs.", file=sys.stderr, ) exit(1) diff --git a/app/parsers/instagram.py b/app/parsers/instagram.py index b556b83..ec2dfbb 100644 --- a/app/parsers/instagram.py +++ b/app/parsers/instagram.py @@ -16,9 +16,7 @@ INSTAGRAM_RE = re.compile(r"(?:https?://)?(?:www\.)?instagram\.com/(?P\w+)/(?P[\w-]+)") -USER_AGENT = ( - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) " "Chrome/91.0.4472.114 Safari/537.36" -) +USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" proxy_file = CONFIG_PATH / "http_proxies.txt" diff --git a/app/settings/user_settings.py b/app/settings/user_settings.py index e6dcf64..894143b 100644 --- a/app/settings/user_settings.py +++ b/app/settings/user_settings.py @@ -45,7 +45,7 @@ def check(language: str) -> str: display_name=_("👤 Add author in media"), template_str_answer=_("Add author in media are {}!"), template_str_menu=_( - "Add author in media (video/audio/images):" "\n\n{}\n\n" "Example: So funny video by @username" + "Add author in media (video/audio/images):\n\n{}\n\nExample: So funny video by @username" ), settings_data_default=False, ) @@ -55,7 +55,7 @@ def check(language: str) -> str: display_name=_("🔗 Add original link in media"), template_str_answer=_("Add original link in media are {}!"), template_str_menu=_( - "Add original link in media:" "\n\n{}\n\n" "️📝 NOTE! Twitter always add original link in media." + "Add original link in media:\n\n{}\n\n️📝 NOTE! Twitter always add original link in media." ), settings_data_default=False, ) @@ -65,7 +65,7 @@ def check(language: str) -> str: display_name=_("🏳️ Add flag to TikTok videos/images"), template_str_answer=_("Add flag to TikTok videos/images are {}!"), template_str_menu=_( - "Adds the flag of the country from which the videos/images was " "uploaded (author's country):\n\n{}" + "Adds the flag of the country from which the videos/images was uploaded (author's country):\n\n{}" ), settings_data_default=False, ) @@ -130,9 +130,7 @@ def check(d: str) -> str: display_name=_("📬 Add media source to videos/images"), template_str_answer=_("Add media source to videos/images are {}!"), template_str_menu=_( - "Add the social network where the videos/images were taken from:" - "\n\n{}\n\n" - "Example: So funny video from TikTok" + "Add the social network where the videos/images were taken from:\n\n{}\n\nExample: So funny video from TikTok" ), settings_data_default=False, ) @@ -184,7 +182,7 @@ def check(history: str) -> str: await ctx.update_message( text=_( - "Choose source to save in history. " "To see the history, use Inline Query.\n\n" "Current: {}" + "Choose source to save in history. To see the history, use Inline Query.\n\nCurrent: {}" ).format(HISTORY_DISPLAY[HistoryTypes[ctx.data]]), buttons=[ ctx.btn(text=f"{history_name}{check(history_type)}", result=history_type) diff --git a/cli/comands.py b/cli/comands.py index bc6a63d..2f785c1 100644 --- a/cli/comands.py +++ b/cli/comands.py @@ -54,7 +54,7 @@ def markdown_update_region(markdown: str, region: str, data: str) -> str: end_rm = markdown.split(end, 1)[1] logger.info("Update %r region in markdown", region) - return f"{start_rm.strip()}\n\n" f"{start}\n\n" f"{data.strip()}\n\n" f"{end}\n\n" f"{end_rm.strip()}" + return f"{start_rm.strip()}\n\n{start}\n\n{data.strip()}\n\n{end}\n\n{end_rm.strip()}" add_command( @@ -99,7 +99,7 @@ def generate_makefile() -> list[dict]: # noinspection PyTypeChecker,PydanticTypeChecker cmds = "\n".join( - f"{name}:{description}\n" f"\tpoetry run -- python -m cli {name}{extra}\n" + f"{name}:{description}\n\tpoetry run -- python -m cli {name}{extra}\n" for name, description, extra in map(dict.values, data) ) diff --git a/main.py b/main.py index 134e079..6bc3acc 100644 --- a/main.py +++ b/main.py @@ -68,7 +68,7 @@ async def _process_video(update: Update, ctx: CallbackContext, media: Video) -> if update.effective_chat.type == ChatType.PRIVATE: logger.info("Sending video as link: %s", media) await update.effective_message.reply_text( - _("Error sending video: {title}\n" "\n\n" 'Direct link to video').format( + _('Error sending video: {title}\n\n\nDirect link to video').format( title=a(media_caption, media.original_url), url=media.url, ),