- content_type=CONTENT_TYPE.get(request.ctx.format, 'application/json'))
-
-
-@api.on_request
-async def extract_format(request):
+ content_type=CONTENT_TYPE.get(request.ctx.format,
+ 'application/json'))
+
+
+@api.on_request # type: ignore[misc]
+async def extract_format(request: sanic.Request) -> Optional[sanic.HTTPResponse]:
+ """ Get and check the 'format' parameter and prepare the formatter.
+ `ctx.result_type` describes the expected return type and
+ `ctx.default_format` the format value to assume when no parameter
+ is present.
+ """
+ assert request.route is not None