Improve type hints in azure devops config flow (#75909)

* Improve type hints in azure devops config flow

* Improve
This commit is contained in:
epenet 2022-08-03 10:15:41 +02:00 committed by GitHub
parent 1ba18f8df6
commit 1ee4445a7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,6 @@
"""Config flow to configure the Azure DevOps integration."""
from __future__ import annotations
from collections.abc import Mapping
from typing import Any
@ -19,11 +21,13 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN):
def __init__(self):
"""Initialize config flow."""
self._organization = None
self._project = None
self._pat = None
self._organization: str | None = None
self._project: str | None = None
self._pat: str | None = None
async def _show_setup_form(self, errors=None):
async def _show_setup_form(
self, errors: dict[str, str] | None = None
) -> FlowResult:
"""Show the setup form to the user."""
return self.async_show_form(
step_id="user",
@ -37,7 +41,7 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN):
errors=errors or {},
)
async def _show_reauth_form(self, errors=None):
async def _show_reauth_form(self, errors: dict[str, str]) -> FlowResult:
"""Show the reauth form to the user."""
return self.async_show_form(
step_id="reauth",
@ -48,9 +52,9 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN):
errors=errors or {},
)
async def _check_setup(self):
async def _check_setup(self) -> dict[str, str] | None:
"""Check the setup of the flow."""
errors = {}
errors: dict[str, str] = {}
client = DevOpsClient()
@ -69,10 +73,12 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN):
return errors
return None
async def async_step_user(self, user_input=None):
async def async_step_user(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
"""Handle a flow initiated by the user."""
if user_input is None:
return await self._show_setup_form(user_input)
return await self._show_setup_form()
self._organization = user_input[CONF_ORG]
self._project = user_input[CONF_PROJECT]
@ -115,7 +121,7 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN):
)
return self.async_abort(reason="reauth_successful")
def _async_create_entry(self):
def _async_create_entry(self) -> FlowResult:
"""Handle create entry."""
return self.async_create_entry(
title=f"{self._organization}/{self._project}",