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

Fix incompatible type annotation of get method in the HTTPMethodView class #3016

Merged
merged 3 commits into from
Dec 22, 2024
Merged
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions sanic/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ def get(self, request: Request):
to `"/v"`.
"""

get: Optional[Callable[..., Any]]

decorators: List[Callable[[Callable[..., Any]], Callable[..., Any]]] = []

def __init_subclass__(
Expand Down Expand Up @@ -146,9 +144,11 @@ def __init_subclass__(

def dispatch_request(self, request: Request, *args, **kwargs):
"""Dispatch request to appropriate handler method."""
handler = getattr(self, request.method.lower(), None)
if not handler and request.method == "HEAD":
handler = self.get
method = request.method.lower()
handler = getattr(self, method)
ahopkins marked this conversation as resolved.
Show resolved Hide resolved

if not handler and method == "head":
handler = getattr(self, "get")
if not handler:
# The router will never allow us to get here, but this is
# included as a fallback and for completeness.
Expand Down
Loading