Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Define decorators generated from middleware with TypeVars.
csrf_protect and etc. are created via the decorator_from_middleware
helper, which doesn't modify the original signature of the wrapped view
function. Using TypeVar helps preserve the original type of the
decorated callable.

Signed-off-by: Zixuan James Li <[email protected]>
  • Loading branch information
PIG208 committed Aug 27, 2022
commit 5fb320dbd79b7e50fe9e7d17d0c888329480a167
6 changes: 3 additions & 3 deletions django-stubs/views/decorators/csrf.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ from typing import Any, Callable, TypeVar

from django.middleware.csrf import CsrfViewMiddleware

csrf_protect: Any
csrf_protect: Callable[[_F], _F]

class _EnsureCsrfToken(CsrfViewMiddleware): ...

requires_csrf_token: Any
requires_csrf_token: Callable[[_F], _F]

class _EnsureCsrfCookie(CsrfViewMiddleware): ...

ensure_csrf_cookie: Any
ensure_csrf_cookie: Callable[[_F], _F]

_F = TypeVar("_F", bound=Callable[..., Any])

Expand Down