refactor: improve code formatting and readability in configuration and run files
All checks were successful
CI / lint-and-test (push) Successful in 38s

- Simplified the assignment of `bot_username` in `config.py` for better clarity.
- Removed redundant import statement in `run.py` to streamline the code.
- Enhanced formatting in `group_duty_pin.py` and test files for improved readability and consistency.
- No functional changes were made; the focus was on code style and organization.
This commit is contained in:
2026-03-02 17:22:55 +03:00
parent 2fb553567f
commit bdead6eef7
4 changed files with 75 additions and 28 deletions

View File

@@ -94,9 +94,7 @@ class Settings:
)
raw_host = (os.getenv("HTTP_HOST") or "127.0.0.1").strip()
http_host = raw_host if raw_host else "127.0.0.1"
bot_username = (
(os.getenv("BOT_USERNAME", "") or "").strip().lstrip("@").lower()
)
bot_username = (os.getenv("BOT_USERNAME", "") or "").strip().lstrip("@").lower()
return cls(
bot_token=bot_token,
database_url=os.getenv("DATABASE_URL", "sqlite:///data/duty_teller.db"),

View File

@@ -439,7 +439,9 @@ async def trust_group_cmd(update: Update, context: ContextTypes.DEFAULT_TYPE) ->
loop = asyncio.get_running_loop()
already_trusted = await loop.run_in_executor(
None,
lambda: _sync_trust_group(chat_id, update.effective_user.id if update.effective_user else None),
lambda: _sync_trust_group(
chat_id, update.effective_user.id if update.effective_user else None
),
)
if already_trusted:
await update.message.reply_text(t(lang, "trust_group.already_trusted"))

View File

@@ -11,6 +11,7 @@ from telegram.ext import ApplicationBuilder
from duty_teller import config
from duty_teller.config import require_bot_token
from duty_teller.handlers import group_duty_pin, register_handlers
from duty_teller.utils.http_client import safe_urlopen
async def _resolve_bot_username(application) -> None:
@@ -19,7 +20,7 @@ async def _resolve_bot_username(application) -> None:
me = await application.bot.get_me()
config.BOT_USERNAME = (me.username or "").lower()
logger.info("Resolved BOT_USERNAME from API: %s", config.BOT_USERNAME)
from duty_teller.utils.http_client import safe_urlopen
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",