chore: resolve all ruff linting and static analysis errors in EvoScientist/

- Fix RUF006: Implement background task tracking in Discord, iMessage, WeChat, and TUI to prevent premature GC of fire-and-forget tasks.
- Fix B904: Add explicit exception chaining (raise ... from) across all exception handlers.
- Fix RUF012: Annotate mutable class attributes with ClassVar for command arguments and media maps.
- Fix B008: Refactor Typer commands in cli/commands.py to use Annotated for argument and option defaults.
- Fix B023/B018: Resolve late-binding issues in lambdas and remove useless expressions.
- Fix syntax errors in retry.py docstrings and models.py lambda parameter ordering.
This commit is contained in:
Jan Piotrowski
2026-03-19 15:38:10 +01:00
parent 4a3d6c0318
commit 81316ffb2d
42 changed files with 331 additions and 264 deletions
+6 -4
View File
@@ -4,6 +4,7 @@ import logging
from dataclasses import dataclass
from datetime import datetime
from pathlib import Path
from typing import ClassVar
from ..base import (
AUDIO_EXTS,
@@ -55,9 +56,10 @@ class TelegramChannel(Channel):
raise ChannelError(
"python-telegram-bot not installed. "
"Install with: pip install evoscientist[telegram]"
)
) from None
builder = ApplicationBuilder().token(self.config.bot_token)
if self.config.proxy:
builder = builder.proxy(self.config.proxy).get_updates_proxy(
self.config.proxy
@@ -124,7 +126,7 @@ class TelegramChannel(Channel):
await self._send_with_format_fallback(_send, formatted_text, raw_text)
_MEDIA_SENDERS = {
_MEDIA_SENDERS: ClassVar[dict] = {
IMAGE_EXTS: ("send_photo", "photo"),
VIDEO_EXTS: ("send_video", "video"),
AUDIO_EXTS: ("send_audio", "audio"),
@@ -285,7 +287,7 @@ class TelegramChannel(Channel):
)
)
_MIME_TO_EXT = {
_MIME_TO_EXT: ClassVar[dict[str, str]] = {
"image/jpeg": ".jpg",
"image/png": ".png",
"image/gif": ".gif",
@@ -296,7 +298,7 @@ class TelegramChannel(Channel):
"video/mp4": ".mp4",
"video/quicktime": ".mov",
}
_TYPE_TO_EXT = {
_TYPE_TO_EXT: ClassVar[dict[str, str]] = {
"image": ".jpg",
"voice": ".ogg",
"audio": ".mp3",