From e5f0e7adc49a91e2125d3d85654578f77706cd4b Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Tue, 17 Jun 2025 17:51:04 +0300 Subject: [PATCH] Fix too strict typing of view functions in decorators View functions can have additional parameters if the URL has parameters. Currently these are not allowed by the typing even though the code itself handles them just fine. Expand the view type to match what django-stubs is using e.g. here: https://github.com/typeddjango/django-stubs/blob/fb310b1b0b40c666c156f0943804f3791ff48f95/django-stubs/urls/conf.pyi#L18 --- csp/decorators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/csp/decorators.py b/csp/decorators.py index b330b6a..850d2b4 100644 --- a/csp/decorators.py +++ b/csp/decorators.py @@ -4,10 +4,10 @@ from typing import TYPE_CHECKING, Any, Callable if TYPE_CHECKING: - from django.http import HttpRequest, HttpResponseBase + from django.http import HttpResponseBase # A generic Django view function - _VIEW_T = Callable[[HttpRequest], HttpResponseBase] + _VIEW_T = Callable[..., HttpResponseBase] _VIEW_DECORATOR_T = Callable[[_VIEW_T], _VIEW_T]