diff --git a/django-stubs/middleware/cache.pyi b/django-stubs/middleware/cache.pyi index 520ac39..7923a93 100644 --- a/django-stubs/middleware/cache.pyi +++ b/django-stubs/middleware/cache.pyi @@ -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 diff --git a/django-stubs/utils/deprecation.pyi b/django-stubs/utils/deprecation.pyi index e1f1467..77e61a8 100644 --- a/django-stubs/utils/deprecation.pyi +++ b/django-stubs/utils/deprecation.pyi @@ -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 @@ -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: ...