Skip to content
Snippets Groups Projects

Make MyPy happy

Merged karp requested to merge make-mypy-happy into master
All threads resolved!
+ 9
4
@@ -2,17 +2,22 @@
Provide RFC 7807-compliant problem details responses for the API.
"""
from typing import Optional
from typing import Any, Optional
ResponseBody = dict[str, Any]
HttpStatusCode = int
HttpHeaders = dict[str, str]
ProblemResponse = tuple[ResponseBody, HttpStatusCode, HttpHeaders]
def unauthorized():
def unauthorized() -> ProblemResponse:
"""
Return a 401 message and status code
"""
return _problem_response(title="Unauthorized", status=401)
def not_found():
def not_found() -> ProblemResponse:
"""
Return a 404 message and status code
"""
@@ -24,7 +29,7 @@ def _problem_response(
status: int,
type_uri: Optional[str] = None,
extensions: Optional[dict] = None,
) -> tuple[dict, int, dict]:
) -> ProblemResponse:
type_dict = {"type": type_uri} if type_uri is not None else {}
title_dict = {"title": title}
Loading