mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-06 12:14:28 +08:00
Preserve callable type in view decorators (#67)
This commit is contained in:
committed by
Maxim Kurnikov
parent
5dd6eccdb5
commit
952e1c3ee9
@@ -1,5 +1,7 @@
|
||||
from typing import Any, Callable, Optional
|
||||
from typing import Any, Callable, Optional, TypeVar
|
||||
|
||||
_F = TypeVar("_F", bound=Callable[..., Any])
|
||||
|
||||
def cache_page(timeout: float, *, cache: Optional[Any] = ..., key_prefix: Optional[Any] = ...) -> Callable: ...
|
||||
def cache_control(**kwargs: Any) -> Callable: ...
|
||||
def never_cache(view_func: Callable) -> Callable: ...
|
||||
def never_cache(view_func: _F) -> _F: ...
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from typing import Callable
|
||||
from typing import Callable, TypeVar, Any
|
||||
|
||||
def xframe_options_deny(view_func: Callable) -> Callable: ...
|
||||
def xframe_options_sameorigin(view_func: Callable) -> Callable: ...
|
||||
def xframe_options_exempt(view_func: Callable) -> Callable: ...
|
||||
_F = TypeVar("_F", bound=Callable[..., Any])
|
||||
|
||||
def xframe_options_deny(view_func: _F) -> _F: ...
|
||||
def xframe_options_sameorigin(view_func: _F) -> _F: ...
|
||||
def xframe_options_exempt(view_func: _F) -> _F: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Callable
|
||||
from typing import Any, Callable, TypeVar
|
||||
|
||||
from django.middleware.csrf import CsrfViewMiddleware
|
||||
|
||||
@@ -14,4 +14,6 @@ class _EnsureCsrfCookie(CsrfViewMiddleware):
|
||||
|
||||
ensure_csrf_cookie: Any
|
||||
|
||||
def csrf_exempt(view_func: Callable) -> Callable: ...
|
||||
_F = TypeVar("_F", bound=Callable[..., Any])
|
||||
|
||||
def csrf_exempt(view_func: _F) -> _F: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from typing import Callable, TypeVar
|
||||
from typing import Callable, TypeVar, Any
|
||||
|
||||
_C = TypeVar("_C", bound=Callable)
|
||||
_C = TypeVar("_C", bound=Callable[..., Any])
|
||||
|
||||
def gzip_page(view_func: _C) -> _C: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Callable, List, Optional
|
||||
from typing import Any, Callable, List, Optional, TypeVar
|
||||
|
||||
conditional_page: Any
|
||||
|
||||
@@ -8,6 +8,8 @@ require_GET: Any
|
||||
require_POST: Any
|
||||
require_safe: Any
|
||||
|
||||
_F = TypeVar("_F", bound=Callable[..., Any])
|
||||
|
||||
def condition(etag_func: Optional[Callable] = ..., last_modified_func: Optional[Callable] = ...) -> Callable: ...
|
||||
def etag(etag_func: Callable) -> Callable: ...
|
||||
def last_modified(last_modified_func: Callable) -> Callable: ...
|
||||
def etag(etag_func: Callable[..., Any]) -> Callable[[_F], _F]: ...
|
||||
def last_modified(last_modified_func: Callable[..., Any]) -> Callable[[_F], _F]: ...
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
from typing import Any, Callable
|
||||
from typing import Any, Callable, TypeVar
|
||||
|
||||
_F = TypeVar("_F", bound=Callable[..., Any])
|
||||
|
||||
def vary_on_headers(*headers: Any) -> Callable: ...
|
||||
def vary_on_cookie(func: Callable) -> Callable: ...
|
||||
def vary_on_cookie(func: _F) -> _F: ...
|
||||
|
||||
Reference in New Issue
Block a user