Skip to content

Commit

Permalink
Type get_response with a callback protocol.
Browse files Browse the repository at this point in the history
Otherwise, calling `self.get_response(request)` in a subclass of
`MiddlewareMixin` runs into `Invalid self argument` error.

This is a workaround for python/mypy#5485.

Signed-off-by: Zixuan James Li <[email protected]>
  • Loading branch information
PIG208 committed Aug 8, 2022
1 parent e3ed7a4 commit 379340d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion django-stubs/utils/deprecation.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class DeprecationInstanceCheck(type):
def __instancecheck__(self, instance: Any): ...

class GetResponseCallable(Protocol):
def __call__(request: HttpRequest) -> HttpResponse: ...
def __call__(self, __request: HttpRequest) -> HttpResponse: ...

class MiddlewareMixin:
get_response: GetResponseCallable = ...
Expand Down

0 comments on commit 379340d

Please sign in to comment.