Add strict typing to ring integration (#115276)

This commit is contained in:
Steven B 2024-04-11 09:10:56 +01:00 committed by GitHub
parent 3546ca386f
commit 6954fcc8ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 384 additions and 359 deletions

View file

@ -28,7 +28,7 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
STEP_REAUTH_DATA_SCHEMA = vol.Schema({vol.Required(CONF_PASSWORD): str})
async def validate_input(hass: HomeAssistant, data):
async def validate_input(hass: HomeAssistant, data: dict[str, str]) -> dict[str, Any]:
"""Validate the user input allows us to connect."""
auth = Auth(f"{APPLICATION_NAME}/{ha_version}")
@ -56,9 +56,11 @@ class RingConfigFlow(ConfigFlow, domain=DOMAIN):
user_pass: dict[str, Any] = {}
reauth_entry: ConfigEntry | None = None
async def async_step_user(self, user_input=None):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Handle the initial step."""
errors = {}
errors: dict[str, str] = {}
if user_input is not None:
try:
token = await validate_input(self.hass, user_input)
@ -82,7 +84,9 @@ class RingConfigFlow(ConfigFlow, domain=DOMAIN):
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
)
async def async_step_2fa(self, user_input=None):
async def async_step_2fa(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Handle 2fa step."""
if user_input:
if self.reauth_entry:
@ -110,7 +114,7 @@ class RingConfigFlow(ConfigFlow, domain=DOMAIN):
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Dialog that informs the user that reauth is required."""
errors = {}
errors: dict[str, str] = {}
assert self.reauth_entry is not None
if user_input: