Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reflect the deprecation of get_response being None. #1086

Merged
merged 2 commits into from
Sep 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion django-stubs/middleware/cache.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CacheMiddleware(UpdateCacheMiddleware, FetchFromCacheMiddleware):
cache: BaseCache = ...
def __init__(
self,
get_response: Optional[Callable] = ...,
get_response: Callable = ...,
cache_timeout: Optional[float] = ...,
page_timeout: Optional[float] = ...,
**kwargs: Any
Expand Down
9 changes: 5 additions & 4 deletions django-stubs/utils/deprecation.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Callable, Optional, Type
from typing import Any, Callable, Optional, Protocol, Type

from django.http.request import HttpRequest
from django.http.response import HttpResponse
Expand Down Expand Up @@ -27,9 +27,10 @@ class DeprecationInstanceCheck(type):
deprecation_warning: Type[Warning]
def __instancecheck__(self, instance: Any): ...

GetResponseCallable = Callable[[HttpRequest], HttpResponse]
class GetResponseCallable(Protocol):
def __call__(self, __request: HttpRequest) -> HttpResponse: ...

class MiddlewareMixin:
get_response: Optional[GetResponseCallable] = ...
def __init__(self, get_response: Optional[GetResponseCallable] = ...) -> None: ...
get_response: GetResponseCallable = ...
def __init__(self, get_response: GetResponseCallable = ...) -> None: ...
def __call__(self, request: HttpRequest) -> HttpResponse: ...