mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-11-09 10:59:43 +00:00
Bump to python 3.10 and alpine 3.16 (#3791)
* Bump to python 3.10 * 3.10 is not a number * Musllinux wheels link * Revert attrs 22.1.0 -> 21.2.0 for wheel * Revert cryptography for wheel & pylint fix * Precommit and devcontainer to 3.10 * pyupgrade rewriting things * revert * Update builder.yml * fix rust * Update builder.yml Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""Init file for Supervisor util for RESTful API."""
|
||||
import json
|
||||
from typing import Any, Optional
|
||||
from typing import Any
|
||||
|
||||
from aiohttp import web
|
||||
from aiohttp.hdrs import AUTHORIZATION
|
||||
@@ -25,7 +25,7 @@ from ..utils.log_format import format_message
|
||||
from .const import CONTENT_TYPE_BINARY, HEADER_TOKEN, HEADER_TOKEN_OLD
|
||||
|
||||
|
||||
def excract_supervisor_token(request: web.Request) -> Optional[str]:
|
||||
def excract_supervisor_token(request: web.Request) -> str | None:
|
||||
"""Extract Supervisor token from request."""
|
||||
if supervisor_token := request.headers.get(HEADER_TOKEN):
|
||||
return supervisor_token
|
||||
@@ -112,7 +112,7 @@ def api_process_raw(content):
|
||||
|
||||
|
||||
def api_return_error(
|
||||
error: Optional[Exception] = None, message: Optional[str] = None
|
||||
error: Exception | None = None, message: str | None = None
|
||||
) -> web.Response:
|
||||
"""Return an API error message."""
|
||||
if error and not message:
|
||||
@@ -130,7 +130,7 @@ def api_return_error(
|
||||
)
|
||||
|
||||
|
||||
def api_return_ok(data: Optional[dict[str, Any]] = None) -> web.Response:
|
||||
def api_return_ok(data: dict[str, Any] | None = None) -> web.Response:
|
||||
"""Return an API ok answer."""
|
||||
return web.json_response(
|
||||
{JSON_RESULT: RESULT_OK, JSON_DATA: data or {}},
|
||||
@@ -139,7 +139,7 @@ def api_return_ok(data: Optional[dict[str, Any]] = None) -> web.Response:
|
||||
|
||||
|
||||
async def api_validate(
|
||||
schema: vol.Schema, request: web.Request, origin: Optional[list[str]] = None
|
||||
schema: vol.Schema, request: web.Request, origin: list[str] | None = None
|
||||
) -> dict[str, Any]:
|
||||
"""Validate request data with schema."""
|
||||
data: dict[str, Any] = await request.json(loads=json_loads)
|
||||
|
||||
Reference in New Issue
Block a user