mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-12 06:51:53 +08:00
Enhance stubs for csrf decorators. (#1130)
* Use inherited types from CsrfViewMiddleware. Signed-off-by: Zixuan James Li <p359101898@gmail.com> * 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 <p359101898@gmail.com> Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
@@ -2,17 +2,15 @@ from typing import Any, Callable, TypeVar
|
|||||||
|
|
||||||
from django.middleware.csrf import CsrfViewMiddleware
|
from django.middleware.csrf import CsrfViewMiddleware
|
||||||
|
|
||||||
csrf_protect: Any
|
csrf_protect: Callable[[_F], _F]
|
||||||
|
|
||||||
class _EnsureCsrfToken(CsrfViewMiddleware): ...
|
class _EnsureCsrfToken(CsrfViewMiddleware): ...
|
||||||
|
|
||||||
requires_csrf_token: Any
|
requires_csrf_token: Callable[[_F], _F]
|
||||||
|
|
||||||
class _EnsureCsrfCookie(CsrfViewMiddleware):
|
class _EnsureCsrfCookie(CsrfViewMiddleware): ...
|
||||||
get_response: None
|
|
||||||
def process_view(self, request: Any, callback: Any, callback_args: Any, callback_kwargs: Any): ...
|
|
||||||
|
|
||||||
ensure_csrf_cookie: Any
|
ensure_csrf_cookie: Callable[[_F], _F]
|
||||||
|
|
||||||
_F = TypeVar("_F", bound=Callable[..., Any])
|
_F = TypeVar("_F", bound=Callable[..., Any])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user