Update typing 03 (#48015)

This commit is contained in:
Marc Mueller
2021-03-17 21:46:07 +01:00
committed by GitHub
parent 6fb2e63e49
commit fabd73f08b
37 changed files with 417 additions and 379 deletions

View File

@@ -1,7 +1,9 @@
"""Example auth provider."""
from __future__ import annotations
from collections import OrderedDict
import hmac
from typing import Any, Dict, Optional, cast
from typing import Any, cast
import voluptuous as vol
@@ -33,7 +35,7 @@ class InvalidAuthError(HomeAssistantError):
class ExampleAuthProvider(AuthProvider):
"""Example auth provider based on hardcoded usernames and passwords."""
async def async_login_flow(self, context: Optional[Dict]) -> LoginFlow:
async def async_login_flow(self, context: dict | None) -> LoginFlow:
"""Return a flow to login."""
return ExampleLoginFlow(self)
@@ -60,7 +62,7 @@ class ExampleAuthProvider(AuthProvider):
raise InvalidAuthError
async def async_get_or_create_credentials(
self, flow_result: Dict[str, str]
self, flow_result: dict[str, str]
) -> Credentials:
"""Get credentials based on the flow result."""
username = flow_result["username"]
@@ -94,8 +96,8 @@ class ExampleLoginFlow(LoginFlow):
"""Handler for the login flow."""
async def async_step_init(
self, user_input: Optional[Dict[str, str]] = None
) -> Dict[str, Any]:
self, user_input: dict[str, str] | None = None
) -> dict[str, Any]:
"""Handle the step of the form."""
errors = {}
@@ -111,7 +113,7 @@ class ExampleLoginFlow(LoginFlow):
user_input.pop("password")
return await self.async_finish(user_input)
schema: Dict[str, type] = OrderedDict()
schema: dict[str, type] = OrderedDict()
schema["username"] = str
schema["password"] = str