From d97afbec1801ebc4f5783b3e73d7de8308eedd96 Mon Sep 17 00:00:00 2001 From: 3252a8 <3252a8@proton.me> Date: Mon, 1 Jun 2026 11:16:28 +0300 Subject: [PATCH] fix: apply ruff formatting --- backend/bot/app/web/webapp/billing.py | 5 +---- backend/bot/handlers/admin/user_management.py | 4 +--- backend/bot/payment_providers/freekassa.py | 3 +-- backend/bot/payment_providers/severpay.py | 3 +-- backend/bot/payment_providers/wata.py | 3 +-- .../bot/services/subscription_service_impl/lifecycle.py | 7 +++---- backend/bot/services/subscription_service_impl/renewal.py | 4 +--- backend/config/tariffs_config.py | 4 +--- tests/test_payment_provider_registry.py | 1 - 9 files changed, 10 insertions(+), 24 deletions(-) diff --git a/backend/bot/app/web/webapp/billing.py b/backend/bot/app/web/webapp/billing.py index e625320..56189bc 100644 --- a/backend/bot/app/web/webapp/billing.py +++ b/backend/bot/app/web/webapp/billing.py @@ -671,10 +671,7 @@ async def device_topup_options_route(request: web.Request) -> web.Response: default_packages = packages.for_currency(default_currency) else: default_packages = getattr(packages, default_currency, []) if packages else [] - currency_counts = { - int(package.count) - for package in default_packages - } + currency_counts = {int(package.count) for package in default_packages} stars_counts = {int(package.count) for package in (packages.stars if packages else [])} plans = [] for count in sorted(currency_counts | stars_counts): diff --git a/backend/bot/handlers/admin/user_management.py b/backend/bot/handlers/admin/user_management.py index 694fce6..cc29674 100644 --- a/backend/bot/handlers/admin/user_management.py +++ b/backend/bot/handlers/admin/user_management.py @@ -454,9 +454,7 @@ async def format_user_card( # Total revenue from referrals referral_revenue = await payment_dal.get_referral_revenue(session, user.user_id) referral_revenue_text = hcode(f"{referral_revenue:.2f} {currency}") - card_parts.append( - f"{_('admin_user_referral_revenue_label')} {referral_revenue_text}" - ) + card_parts.append(f"{_('admin_user_referral_revenue_label')} {referral_revenue_text}") except Exception as e_fin: logging.error( f"Failed to build financial analytics for admin card {user.user_id}: {e_fin}" diff --git a/backend/bot/payment_providers/freekassa.py b/backend/bot/payment_providers/freekassa.py index 03341d6..1d830a5 100644 --- a/backend/bot/payment_providers/freekassa.py +++ b/backend/bot/payment_providers/freekassa.py @@ -777,8 +777,7 @@ SPEC = PaymentProviderSpec( manifest_fields=_CONFIG_MANIFEST + _PRESENTATION_MANIFEST, supported_currencies=FREEKASSA_SUPPORTED_CURRENCIES, currency_support_note=( - "FreeKassa SCI documents the payment currency parameter as " - "RUB, USD, EUR, UAH or KZT." + "FreeKassa SCI documents the payment currency parameter as RUB, USD, EUR, UAH or KZT." ), currency_support_url="https://docs.freekassa.net/", ) diff --git a/backend/bot/payment_providers/severpay.py b/backend/bot/payment_providers/severpay.py index dfb6071..2822e4a 100644 --- a/backend/bot/payment_providers/severpay.py +++ b/backend/bot/payment_providers/severpay.py @@ -682,8 +682,7 @@ SPEC = PaymentProviderSpec( manifest_fields=_CONFIG_MANIFEST + _PRESENTATION_MANIFEST, supported_currencies_resolver=lambda config: getattr(config, "SUPPORTED_CURRENCIES", "RUB,USD"), currency_support_note=( - "SeverPay PayIn requires a currency; keep this list aligned with your " - "merchant account." + "SeverPay PayIn requires a currency; keep this list aligned with your merchant account." ), currency_support_url="https://docs.severpay.io/ru/payin/create", ) diff --git a/backend/bot/payment_providers/wata.py b/backend/bot/payment_providers/wata.py index b3d1eff..422db61 100644 --- a/backend/bot/payment_providers/wata.py +++ b/backend/bot/payment_providers/wata.py @@ -1208,8 +1208,7 @@ SPEC = PaymentProviderSpec( manifest_fields=_CONFIG_MANIFEST + _PRESENTATION_MANIFEST, supported_currencies=WATA_SUPPORTED_CURRENCIES, currency_support_note=( - "WATA H2H payment links and widget document RUB, USD and EUR as " - "payment currencies." + "WATA H2H payment links and widget document RUB, USD and EUR as payment currencies." ), currency_support_url="https://wata.pro/api", ) diff --git a/backend/bot/services/subscription_service_impl/lifecycle.py b/backend/bot/services/subscription_service_impl/lifecycle.py index bff6851..4a4eea3 100644 --- a/backend/bot/services/subscription_service_impl/lifecycle.py +++ b/backend/bot/services/subscription_service_impl/lifecycle.py @@ -248,10 +248,9 @@ class SubscriptionLifecycleMixin: traffic_used_bytes=used_sub, ) update_data["period_start_at"] = None - update_data["effective_monthly_price_rub"] = ( - target.period_price(1, default_currency_key_for_settings(self.settings)) - or target.min_period_price(default_currency_key_for_settings(self.settings)) - ) + update_data["effective_monthly_price_rub"] = target.period_price( + 1, default_currency_key_for_settings(self.settings) + ) or target.min_period_price(default_currency_key_for_settings(self.settings)) if mode == "recalc_days" and options.get("recalc_days") is not None: update_data["end_date"] = now + timedelta(days=int(options["recalc_days"])) else: diff --git a/backend/bot/services/subscription_service_impl/renewal.py b/backend/bot/services/subscription_service_impl/renewal.py index 9467039..f58e8eb 100644 --- a/backend/bot/services/subscription_service_impl/renewal.py +++ b/backend/bot/services/subscription_service_impl/renewal.py @@ -44,9 +44,7 @@ class RenewalMixin: currency = default_payment_currency_code_for_settings(self.settings) amount = None tariffs_config = ( - self._tariffs_config() - if callable(getattr(self, "_tariffs_config", None)) - else None + self._tariffs_config() if callable(getattr(self, "_tariffs_config", None)) else None ) if tariffs_config and callable(getattr(self, "_resolve_tariff", None)): try: diff --git a/backend/config/tariffs_config.py b/backend/config/tariffs_config.py index 6ba6d41..2e0f8a6 100644 --- a/backend/config/tariffs_config.py +++ b/backend/config/tariffs_config.py @@ -132,9 +132,7 @@ class PackageSet(RootModel[Dict[str, List[TrafficPackage]]]): @property def non_stars_currencies(self) -> List[str]: return [ - currency - for currency, packages in self.root.items() - if currency != "stars" and packages + currency for currency, packages in self.root.items() if currency != "stars" and packages ] def has_any(self) -> bool: diff --git a/tests/test_payment_provider_registry.py b/tests/test_payment_provider_registry.py index 144021f..b5e002c 100644 --- a/tests/test_payment_provider_registry.py +++ b/tests/test_payment_provider_registry.py @@ -350,7 +350,6 @@ def test_webapp_payment_methods_filter_by_default_currency(monkeypatch): assert [method["id"] for method in methods] == ["wata"] - def test_admin_only_provider_toggle_pairs_are_declared(): pairs = set(provider_admin_only_pairs())