diff --git a/homeassistant/components/nest/__init__.py b/homeassistant/components/nest/__init__.py index fb488763750..1548814804b 100644 --- a/homeassistant/components/nest/__init__.py +++ b/homeassistant/components/nest/__init__.py @@ -33,7 +33,6 @@ from .const import DATA_SDM, DATA_SUBSCRIBER, DOMAIN, OAUTH2_AUTHORIZE, OAUTH2_T from .events import EVENT_NAME_MAP, NEST_EVENT from .legacy import async_setup_legacy, async_setup_legacy_entry -_CONFIGURING = {} _LOGGER = logging.getLogger(__name__) CONF_PROJECT_ID = "project_id" diff --git a/homeassistant/components/nest/config_flow.py b/homeassistant/components/nest/config_flow.py index c6ebe543c99..2070f232d77 100644 --- a/homeassistant/components/nest/config_flow.py +++ b/homeassistant/components/nest/config_flow.py @@ -22,6 +22,7 @@ import async_timeout import voluptuous as vol from homeassistant.core import callback +from homeassistant.data_entry_flow import FlowResult from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import config_entry_oauth2_flow from homeassistant.util.json import load_json @@ -79,13 +80,13 @@ class NestFlowHandler( self._reauth = False @classmethod - def register_sdm_api(cls, hass): + def register_sdm_api(cls, hass) -> None: """Configure the flow handler to use the SDM API.""" if DOMAIN not in hass.data: hass.data[DOMAIN] = {} hass.data[DOMAIN][DATA_SDM] = {} - def is_sdm_api(self): + def is_sdm_api(self) -> bool: """Return true if this flow is setup to use SDM API.""" return DOMAIN in self.hass.data and DATA_SDM in self.hass.data[DOMAIN] @@ -104,7 +105,7 @@ class NestFlowHandler( "prompt": "consent", } - async def async_oauth_create_entry(self, data: dict) -> dict: + async def async_oauth_create_entry(self, data: dict) -> FlowResult: """Create an entry for the SDM flow.""" assert self.is_sdm_api(), "Step only supported for SDM API" data[DATA_SDM] = {} @@ -128,13 +129,13 @@ class NestFlowHandler( return await super().async_oauth_create_entry(data) - async def async_step_reauth(self, user_input=None): + async def async_step_reauth(self, user_input=None) -> FlowResult: """Perform reauth upon an API authentication error.""" assert self.is_sdm_api(), "Step only supported for SDM API" self._reauth = True # Forces update of existing config entry return await self.async_step_reauth_confirm() - async def async_step_reauth_confirm(self, user_input=None): + async def async_step_reauth_confirm(self, user_input=None) -> FlowResult: """Confirm reauth dialog.""" assert self.is_sdm_api(), "Step only supported for SDM API" if user_input is None: @@ -144,7 +145,7 @@ class NestFlowHandler( ) return await self.async_step_user() - async def async_step_user(self, user_input=None): + async def async_step_user(self, user_input=None) -> FlowResult: """Handle a flow initialized by the user.""" if self.is_sdm_api(): # Reauth will update an existing entry @@ -153,7 +154,7 @@ class NestFlowHandler( return await super().async_step_user(user_input) return await self.async_step_init(user_input) - async def async_step_init(self, user_input=None): + async def async_step_init(self, user_input=None) -> FlowResult: """Handle a flow start.""" assert not self.is_sdm_api(), "Step only supported for legacy API" @@ -178,7 +179,7 @@ class NestFlowHandler( data_schema=vol.Schema({vol.Required("flow_impl"): vol.In(list(flows))}), ) - async def async_step_link(self, user_input=None): + async def async_step_link(self, user_input=None) -> FlowResult: """Attempt to link with the Nest account. Route the user to a website to authenticate with Nest. Depending on @@ -225,7 +226,7 @@ class NestFlowHandler( errors=errors, ) - async def async_step_import(self, info): + async def async_step_import(self, info) -> FlowResult: """Import existing auth from Nest.""" assert not self.is_sdm_api(), "Step only supported for legacy API" @@ -235,7 +236,7 @@ class NestFlowHandler( config_path = info["nest_conf_path"] if not await self.hass.async_add_executor_job(os.path.isfile, config_path): - self.flow_impl = DOMAIN + self.flow_impl = DOMAIN # type: ignore return await self.async_step_link() flow = self.hass.data[DATA_FLOW_IMPL][DOMAIN] @@ -246,7 +247,7 @@ class NestFlowHandler( ) @callback - def _entry_from_tokens(self, title, flow, tokens): + def _entry_from_tokens(self, title, flow, tokens) -> FlowResult: """Create an entry from tokens.""" return self.async_create_entry( title=title, data={"tokens": tokens, "impl_domain": flow["domain"]} diff --git a/homeassistant/components/nest/device_trigger.py b/homeassistant/components/nest/device_trigger.py index 4ed492a15fa..889111d6f61 100644 --- a/homeassistant/components/nest/device_trigger.py +++ b/homeassistant/components/nest/device_trigger.py @@ -27,7 +27,7 @@ TRIGGER_SCHEMA = DEVICE_TRIGGER_BASE_SCHEMA.extend( ) -async def async_get_nest_device_id(hass: HomeAssistant, device_id: str) -> str: +async def async_get_nest_device_id(hass: HomeAssistant, device_id: str) -> str | None: """Get the nest API device_id from the HomeAssistant device_id.""" device_registry = await hass.helpers.device_registry.async_get_registry() device = device_registry.async_get(device_id) diff --git a/homeassistant/components/nest/sensor_sdm.py b/homeassistant/components/nest/sensor_sdm.py index 8182ef3ed95..d1ff26880de 100644 --- a/homeassistant/components/nest/sensor_sdm.py +++ b/homeassistant/components/nest/sensor_sdm.py @@ -44,7 +44,7 @@ async def async_setup_sdm_entry( _LOGGER.warning("Failed to get devices: %s", err) raise PlatformNotReady from err - entities = [] + entities: list[SensorEntity] = [] for device in device_manager.devices.values(): if TemperatureTrait.NAME in device.traits: entities.append(TemperatureSensor(device)) diff --git a/mypy.ini b/mypy.ini index 90880107761..8354b145a2f 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1364,7 +1364,7 @@ ignore_errors = true [mypy-homeassistant.components.ness_alarm.*] ignore_errors = true -[mypy-homeassistant.components.nest.*] +[mypy-homeassistant.components.nest.legacy.*] ignore_errors = true [mypy-homeassistant.components.netatmo.*] diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index f47966bdb5c..3be6471fa7f 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -113,7 +113,7 @@ IGNORED_MODULES: Final[list[str]] = [ "homeassistant.components.mullvad.*", "homeassistant.components.neato.*", "homeassistant.components.ness_alarm.*", - "homeassistant.components.nest.*", + "homeassistant.components.nest.legacy.*", "homeassistant.components.netatmo.*", "homeassistant.components.netio.*", "homeassistant.components.nightscout.*",