fix: apply ruff formatting

This commit is contained in:
3252a8
2026-06-01 11:16:28 +03:00
parent 21079f78dc
commit d97afbec18
9 changed files with 10 additions and 24 deletions
+1 -4
View File
@@ -671,10 +671,7 @@ async def device_topup_options_route(request: web.Request) -> web.Response:
default_packages = packages.for_currency(default_currency) default_packages = packages.for_currency(default_currency)
else: else:
default_packages = getattr(packages, default_currency, []) if packages else [] default_packages = getattr(packages, default_currency, []) if packages else []
currency_counts = { currency_counts = {int(package.count) for package in default_packages}
int(package.count)
for package in default_packages
}
stars_counts = {int(package.count) for package in (packages.stars if packages else [])} stars_counts = {int(package.count) for package in (packages.stars if packages else [])}
plans = [] plans = []
for count in sorted(currency_counts | stars_counts): for count in sorted(currency_counts | stars_counts):
@@ -454,9 +454,7 @@ async def format_user_card(
# Total revenue from referrals # Total revenue from referrals
referral_revenue = await payment_dal.get_referral_revenue(session, user.user_id) referral_revenue = await payment_dal.get_referral_revenue(session, user.user_id)
referral_revenue_text = hcode(f"{referral_revenue:.2f} {currency}") referral_revenue_text = hcode(f"{referral_revenue:.2f} {currency}")
card_parts.append( card_parts.append(f"{_('admin_user_referral_revenue_label')} {referral_revenue_text}")
f"{_('admin_user_referral_revenue_label')} {referral_revenue_text}"
)
except Exception as e_fin: except Exception as e_fin:
logging.error( logging.error(
f"Failed to build financial analytics for admin card {user.user_id}: {e_fin}" f"Failed to build financial analytics for admin card {user.user_id}: {e_fin}"
+1 -2
View File
@@ -777,8 +777,7 @@ SPEC = PaymentProviderSpec(
manifest_fields=_CONFIG_MANIFEST + _PRESENTATION_MANIFEST, manifest_fields=_CONFIG_MANIFEST + _PRESENTATION_MANIFEST,
supported_currencies=FREEKASSA_SUPPORTED_CURRENCIES, supported_currencies=FREEKASSA_SUPPORTED_CURRENCIES,
currency_support_note=( currency_support_note=(
"FreeKassa SCI documents the payment currency parameter as " "FreeKassa SCI documents the payment currency parameter as RUB, USD, EUR, UAH or KZT."
"RUB, USD, EUR, UAH or KZT."
), ),
currency_support_url="https://docs.freekassa.net/", currency_support_url="https://docs.freekassa.net/",
) )
+1 -2
View File
@@ -682,8 +682,7 @@ SPEC = PaymentProviderSpec(
manifest_fields=_CONFIG_MANIFEST + _PRESENTATION_MANIFEST, manifest_fields=_CONFIG_MANIFEST + _PRESENTATION_MANIFEST,
supported_currencies_resolver=lambda config: getattr(config, "SUPPORTED_CURRENCIES", "RUB,USD"), supported_currencies_resolver=lambda config: getattr(config, "SUPPORTED_CURRENCIES", "RUB,USD"),
currency_support_note=( currency_support_note=(
"SeverPay PayIn requires a currency; keep this list aligned with your " "SeverPay PayIn requires a currency; keep this list aligned with your merchant account."
"merchant account."
), ),
currency_support_url="https://docs.severpay.io/ru/payin/create", currency_support_url="https://docs.severpay.io/ru/payin/create",
) )
+1 -2
View File
@@ -1208,8 +1208,7 @@ SPEC = PaymentProviderSpec(
manifest_fields=_CONFIG_MANIFEST + _PRESENTATION_MANIFEST, manifest_fields=_CONFIG_MANIFEST + _PRESENTATION_MANIFEST,
supported_currencies=WATA_SUPPORTED_CURRENCIES, supported_currencies=WATA_SUPPORTED_CURRENCIES,
currency_support_note=( currency_support_note=(
"WATA H2H payment links and widget document RUB, USD and EUR as " "WATA H2H payment links and widget document RUB, USD and EUR as payment currencies."
"payment currencies."
), ),
currency_support_url="https://wata.pro/api", currency_support_url="https://wata.pro/api",
) )
@@ -248,10 +248,9 @@ class SubscriptionLifecycleMixin:
traffic_used_bytes=used_sub, traffic_used_bytes=used_sub,
) )
update_data["period_start_at"] = None update_data["period_start_at"] = None
update_data["effective_monthly_price_rub"] = ( update_data["effective_monthly_price_rub"] = target.period_price(
target.period_price(1, default_currency_key_for_settings(self.settings)) 1, default_currency_key_for_settings(self.settings)
or target.min_period_price(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: if mode == "recalc_days" and options.get("recalc_days") is not None:
update_data["end_date"] = now + timedelta(days=int(options["recalc_days"])) update_data["end_date"] = now + timedelta(days=int(options["recalc_days"]))
else: else:
@@ -44,9 +44,7 @@ class RenewalMixin:
currency = default_payment_currency_code_for_settings(self.settings) currency = default_payment_currency_code_for_settings(self.settings)
amount = None amount = None
tariffs_config = ( tariffs_config = (
self._tariffs_config() self._tariffs_config() if callable(getattr(self, "_tariffs_config", None)) else None
if callable(getattr(self, "_tariffs_config", None))
else None
) )
if tariffs_config and callable(getattr(self, "_resolve_tariff", None)): if tariffs_config and callable(getattr(self, "_resolve_tariff", None)):
try: try:
+1 -3
View File
@@ -132,9 +132,7 @@ class PackageSet(RootModel[Dict[str, List[TrafficPackage]]]):
@property @property
def non_stars_currencies(self) -> List[str]: def non_stars_currencies(self) -> List[str]:
return [ return [
currency currency for currency, packages in self.root.items() if currency != "stars" and packages
for currency, packages in self.root.items()
if currency != "stars" and packages
] ]
def has_any(self) -> bool: def has_any(self) -> bool:
-1
View File
@@ -350,7 +350,6 @@ def test_webapp_payment_methods_filter_by_default_currency(monkeypatch):
assert [method["id"] for method in methods] == ["wata"] assert [method["id"] for method in methods] == ["wata"]
def test_admin_only_provider_toggle_pairs_are_declared(): def test_admin_only_provider_toggle_pairs_are_declared():
pairs = set(provider_admin_only_pairs()) pairs = set(provider_admin_only_pairs())