From 1df132490ba949e05eb9eed58bd75e6e848b4832 Mon Sep 17 00:00:00 2001 From: Trey <73353716+TreyWW@users.noreply.github.com> Date: Fri, 8 Nov 2024 20:42:38 +0000 Subject: [PATCH] fix: mypy issue with previous invoice_statuses Signed-off-by: Trey <73353716+TreyWW@users.noreply.github.com> --- backend/core/api/public/endpoints/Invoices/edit.py | 4 +++- backend/finance/api/invoices/edit.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/core/api/public/endpoints/Invoices/edit.py b/backend/core/api/public/endpoints/Invoices/edit.py index c888550c..ada5aef1 100644 --- a/backend/core/api/public/endpoints/Invoices/edit.py +++ b/backend/core/api/public/endpoints/Invoices/edit.py @@ -1,4 +1,6 @@ from datetime import datetime +from typing import Literal + from rest_framework import status from rest_framework.decorators import api_view from rest_framework.response import Response @@ -72,7 +74,7 @@ def edit_invoice_endpoint(request: APIRequest): @api_view(["POST"]) def change_status_endpoint(request, invoice_id: int, invoice_status: str): - invoice_status = invoice_status.lower() if invoice_status else "" + invoice_status: Literal["paid", "draft", "pending"] = invoice_status.lower() if invoice_status else "" try: invoice = Invoice.objects.get(id=invoice_id) diff --git a/backend/finance/api/invoices/edit.py b/backend/finance/api/invoices/edit.py index d28d32b3..1c9be2ec 100644 --- a/backend/finance/api/invoices/edit.py +++ b/backend/finance/api/invoices/edit.py @@ -1,4 +1,5 @@ from datetime import datetime +from typing import Literal from django.contrib import messages from django.http import HttpRequest, JsonResponse, HttpResponse @@ -76,7 +77,7 @@ def edit_invoice(request: HtmxHttpRequest): @require_POST @web_require_scopes("invoices:write", True, True) def change_status(request: HtmxHttpRequest, invoice_id: int, status: str) -> HttpResponse: - status = status.lower() if status else "" + status: Literal["paid", "draft", "pending"] = status.lower() if status else "" if not request.htmx: return redirect("finance:invoices:single:dashboard")