summaryrefslogtreecommitdiff
path: root/Biz/PodcastItLater/Billing.py
diff options
context:
space:
mode:
Diffstat (limited to 'Biz/PodcastItLater/Billing.py')
-rw-r--r--Biz/PodcastItLater/Billing.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/Biz/PodcastItLater/Billing.py b/Biz/PodcastItLater/Billing.py
index 4996607..0e2537a 100644
--- a/Biz/PodcastItLater/Billing.py
+++ b/Biz/PodcastItLater/Billing.py
@@ -37,7 +37,7 @@ PRICE_TO_TIER = {
}
# Tier limits (None = unlimited)
-TIER_LIMITS = {
+TIER_LIMITS: dict[str, dict[str, int | None]] = {
"free": {
"articles_per_period": 10,
"minutes_per_period": None,
@@ -112,7 +112,7 @@ def can_submit(user_id: int) -> tuple[bool, str, dict[str, int]]:
usage = get_usage(user_id, period_start, period_end)
# Check article limit
- article_limit = limits["articles_per_period"] # type: ignore[index]
+ article_limit = limits.get("articles_per_period")
if article_limit is not None and usage["articles"] >= article_limit:
msg = (
f"You've reached your limit of {article_limit} articles "
@@ -121,7 +121,7 @@ def can_submit(user_id: int) -> tuple[bool, str, dict[str, int]]:
return (False, msg, usage)
# Check minutes limit (if implemented)
- minute_limit = limits.get("minutes_per_period") # type: ignore[attr-defined]
+ minute_limit = limits.get("minutes_per_period")
if minute_limit is not None and usage.get("minutes", 0) >= minute_limit:
return (
False,
@@ -391,11 +391,13 @@ def _update_subscription_state(subscription: dict[str, typing.Any]) -> None:
period_start = datetime.fromtimestamp(period_start_ts, tz=timezone.utc)
# Calculate period end if not provided (assume monthly)
+ december = 12
+ january = 1
if not period_end_ts:
- if period_start.month == 12: # noqa: PLR2004
+ if period_start.month == december:
period_end = period_start.replace(
year=period_start.year + 1,
- month=1,
+ month=january,
)
else:
period_end = period_start.replace(month=period_start.month + 1)
@@ -447,7 +449,7 @@ def get_tier_info(tier: str) -> dict[str, typing.Any]:
Returns:
dict with keys: name, articles_limit, price, description
"""
- tier_info = {
+ tier_info: dict[str, dict[str, typing.Any]] = {
"free": {
"name": "Free",
"articles_limit": 10,
@@ -461,7 +463,7 @@ def get_tier_info(tier: str) -> dict[str, typing.Any]:
"description": "Unlimited articles",
},
}
- return tier_info.get(tier, tier_info["free"]) # type: ignore[return-value]
+ return tier_info.get(tier, tier_info["free"])
# Tests