From cfe59fe2b327cbd7c436cc0a76342c182dab461f Mon Sep 17 00:00:00 2001 From: Chris Tapper Date: Wed, 31 Aug 2022 17:55:46 +1000 Subject: [PATCH] Use generic response type --- src/django_htmx/http.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/django_htmx/http.py b/src/django_htmx/http.py index 33c2c02a..07890eee 100644 --- a/src/django_htmx/http.py +++ b/src/django_htmx/http.py @@ -2,7 +2,7 @@ import json import sys -from typing import Any +from typing import Any, TypeVar from django.core.serializers.json import DjangoJSONEncoder from django.http import HttpResponse @@ -46,13 +46,16 @@ def __init__(self) -> None: self["HX-Refresh"] = "true" +_R = TypeVar("_R", bound=HttpResponseBase) + + def trigger_client_event( - response: HttpResponseBase, + response: _R, name: str, params: dict[str, Any], *, after: EventAfterType = "receive", -) -> HttpResponseBase: +) -> _R: if after == "receive": header = "HX-Trigger" elif after == "settle":