~homeworkprod/byceps

a5c7b396946b849778eb0beb09dcccc723ba1876 — Jochen Kupperschmidt 5 months ago 87b31ba
Add missing type hints to variables
M byceps/blueprints/site/board/service.py => byceps/blueprints/site/board/service.py +1 -1
@@ 134,7 134,7 @@ def enrich_creators(
    for posting in postings:
        user_id = posting.creator_id

        badges = badges_by_user_id.get(user_id, set())
        badges: set[Badge] = badges_by_user_id.get(user_id, set())

        if user_id in ticket_users:
            ticket = Ticket(party.title)

M byceps/services/newsletter/service.py => byceps/services/newsletter/service.py +3 -1
@@ 126,7 126,9 @@ def count_subscriptions_by_state(
    rows = _build_query_for_current_state(list_id) \
        .all()

    totals = {state: 0 for state in SubscriptionState}
    totals: dict[Union[SubscriptionState, str], int] = {
        state: 0 for state in SubscriptionState
    }

    for state_name, count in rows:
        state = SubscriptionState[state_name]

M byceps/services/shop/order/email/example_service.py => byceps/services/shop/order/email/example_service.py +3 -2
@@ 6,6 6,7 @@ byceps.services.shop.order.email.example_service
:License: Revised BSD (see `LICENSE` file for details)
"""

from __future__ import annotations
from datetime import datetime
from decimal import Decimal
from typing import Optional


@@ 22,7 23,7 @@ from ...shop import service as shop_service
from ...shop.transfer.models import ShopID

from ..email.service import OrderEmailData
from ..transfer.models import Order, PaymentMethod, PaymentState
from ..transfer.models import Order, OrderItem, PaymentMethod, PaymentState

from . import service as shop_order_email_service



@@ 112,7 113,7 @@ def _build_order(
    address = None

    total_amount = Decimal('42.95')
    items = []
    items: list[OrderItem] = []
    payment_method = PaymentMethod.bank_transfer

    return Order(

M byceps/services/shop/order/service.py => byceps/services/shop/order/service.py +2 -2
@@ 28,7 28,7 @@ from ..storefront import service as storefront_service
from ..storefront.transfer.models import StorefrontID

from .dbmodels.order import Order as DbOrder
from .dbmodels.order_event import OrderEvent as DbOrderEvent
from .dbmodels.order_event import OrderEvent as DbOrderEvent, OrderEventData
from .dbmodels.order_item import OrderItem as DbOrderItem
from .models.orderer import Orderer
from . import action_service, sequence_service


@@ 334,7 334,7 @@ def mark_order_as_paid(
    event_type = 'order-paid'
    # Add required, internally set properties after given additional
    # ones to ensure the former are not overridden by the latter.
    event_data = {}
    event_data: OrderEventData = {}
    if additional_event_data is not None:
        event_data.update(additional_event_data)
    event_data.update(

M byceps/services/shop/shipping/service.py => byceps/services/shop/shipping/service.py +1 -1
@@ 92,7 92,7 @@ def _aggregate_ordered_article_quantites(
    article_descriptions: dict[ArticleNumber, str],
) -> Iterator[ArticleToShip]:
    """Aggregate article quantities per payment state."""
    d = defaultdict(Counter)
    d: defaultdict[ArticleNumber, Counter] = defaultdict(Counter)

    for item in order_item_quantities:
        d[item.article_number][item.payment_state] += item.quantity

M byceps/services/ticketing/attendance_service.py => byceps/services/ticketing/attendance_service.py +1 -1
@@ 226,7 226,7 @@ def _get_top_archived_attendees_for_parties(
def _merge_top_attendance_counts(
    xs: list[list[tuple[UserID, int]]]
) -> Counter[UserID]:
    counter = Counter()
    counter: Counter = Counter()

    for x in xs:
        counter.update(dict(x))

M byceps/util/templating.py => byceps/util/templating.py +1 -1
@@ 64,7 64,7 @@ class SiteTemplateOverridesLoader(BaseLoader):
    """Look for site-specific template overrides."""

    def __init__(self) -> None:
        self._loaders_by_site_id = {}
        self._loaders_by_site_id: dict[str, BaseLoader] = {}

    def get_source(self, environment: Environment, template: Template) -> str:
        site_id = getattr(g, 'site_id', None)