From 4aabbcd3d8bd5f784cc53a8d5bbdd0373e66369b Mon Sep 17 00:00:00 2001 From: James Addison Date: Mon, 18 Dec 2023 15:31:10 +0000 Subject: [PATCH] payments: add type-hinting to EPC QR code --- apps/common/epc.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/common/epc.py b/apps/common/epc.py index 81f642196..7866776dd 100644 --- a/apps/common/epc.py +++ b/apps/common/epc.py @@ -1,14 +1,16 @@ from io import BytesIO from markupsafe import Markup -from segno import helpers +from segno import QRCode, helpers +from models.payment import BankPayment -def make_epc_qrfile(payment, **kwargs): + +def make_epc_qrfile(payment: BankPayment, **kwargs) -> BytesIO: qrfile = BytesIO() # TODO: this isn't currently used. Need to fetch IBAN from payment.recommended_destination # and name from somewhere - maybe config rather than hard-coding. - qr = helpers.make_epc_qr( + qr: QRCode = helpers.make_epc_qr( name="EMF Festivals Ltd", iban=payment.recommended_destination.iban, amount=payment.amount, @@ -20,11 +22,11 @@ def make_epc_qrfile(payment, **kwargs): return qrfile -def qrfile_to_svg(qrfile): +def qrfile_to_svg(qrfile: BytesIO) -> str: return Markup(qrfile.getvalue().decode("utf-8")) -def format_inline_epc_qr(payment): +def format_inline_epc_qr(payment: BankPayment) -> str: qrfile = make_epc_qrfile( payment, kind="svg",