diff --git a/homeassistant/components/bluetooth/passive_update_processor.py b/homeassistant/components/bluetooth/passive_update_processor.py index 29ebda3488ba..3e7e4e96659b 100644 --- a/homeassistant/components/bluetooth/passive_update_processor.py +++ b/homeassistant/components/bluetooth/passive_update_processor.py @@ -146,20 +146,19 @@ class PassiveBluetoothDataUpdate[_T]: """ device_change = False changed_entity_keys: set[PassiveBluetoothEntityKey] = set() - for key, device_info in new_data.devices.items(): - if device_change or self.devices.get(key, UNDEFINED) != device_info: + for device_key, device_info in new_data.devices.items(): + if device_change or self.devices.get(device_key, UNDEFINED) != device_info: device_change = True - self.devices[key] = device_info + self.devices[device_key] = device_info for incoming, current in ( (new_data.entity_descriptions, self.entity_descriptions), (new_data.entity_names, self.entity_names), (new_data.entity_data, self.entity_data), ): - # mypy can't seem to work this out - for key, data in incoming.items(): # type: ignore[attr-defined] - if current.get(key, UNDEFINED) != data: # type: ignore[attr-defined] - changed_entity_keys.add(key) # type: ignore[arg-type] - current[key] = data # type: ignore[index] + for key, data in incoming.items(): + if current.get(key, UNDEFINED) != data: + changed_entity_keys.add(key) + current[key] = data # type: ignore[assignment] # If the device changed we don't need to return the changed # entity keys as all entities will be updated return None if device_change else changed_entity_keys diff --git a/homeassistant/components/recorder/core.py b/homeassistant/components/recorder/core.py index a5eecf42f222..4e5ac04c3bfa 100644 --- a/homeassistant/components/recorder/core.py +++ b/homeassistant/components/recorder/core.py @@ -85,6 +85,7 @@ from .db_schema import ( ) from .executor import DBInterruptibleThreadPoolExecutor from .migration import ( + BaseRunTimeMigration, EntityIDMigration, EventsContextIDMigration, EventTypeIDMigration, @@ -805,6 +806,7 @@ class Recorder(threading.Thread): for row in execute_stmt_lambda_element(session, get_migration_changes()) } + migrator: BaseRunTimeMigration for migrator_cls in (StatesContextIDMigration, EventsContextIDMigration): migrator = migrator_cls(session, schema_version, migration_changes) if migrator.needs_migrate(): diff --git a/homeassistant/components/sonos/__init__.py b/homeassistant/components/sonos/__init__.py index 2049cb4c8c79..912a8d04f4e3 100644 --- a/homeassistant/components/sonos/__init__.py +++ b/homeassistant/components/sonos/__init__.py @@ -9,7 +9,7 @@ import datetime from functools import partial import logging import socket -from typing import TYPE_CHECKING, Any, cast +from typing import Any, cast from urllib.parse import urlparse from aiohttp import ClientError @@ -372,12 +372,11 @@ class SonosDiscoveryManager: (SonosAlarms, self.data.alarms), (SonosFavorites, self.data.favorites), ): - if TYPE_CHECKING: - coord_dict = cast(dict[str, Any], coord_dict) - if soco.household_id not in coord_dict: + c_dict: dict[str, Any] = coord_dict + if soco.household_id not in c_dict: new_coordinator = coordinator(self.hass, soco.household_id) new_coordinator.setup(soco) - coord_dict[soco.household_id] = new_coordinator + c_dict[soco.household_id] = new_coordinator speaker.setup(self.entry) except (OSError, SoCoException, Timeout) as ex: _LOGGER.warning("Failed to add SonosSpeaker using %s: %s", soco, ex) diff --git a/homeassistant/components/tessie/lock.py b/homeassistant/components/tessie/lock.py index 9457d476e326..0ea65ce4781c 100644 --- a/homeassistant/components/tessie/lock.py +++ b/homeassistant/components/tessie/lock.py @@ -35,7 +35,7 @@ async def async_setup_entry( """Set up the Tessie sensor platform from a config entry.""" data = entry.runtime_data - entities = [ + entities: list[TessieEntity] = [ klass(vehicle) for klass in (TessieLockEntity, TessieCableLockEntity) for vehicle in data.vehicles diff --git a/requirements_test.txt b/requirements_test.txt index fce669c49298..460da410db60 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -11,7 +11,7 @@ astroid==3.2.2 coverage==7.5.3 freezegun==1.5.0 mock-open==1.4.0 -mypy-dev==1.11.0a8 +mypy-dev==1.11.0a9 pre-commit==3.7.1 pydantic==1.10.17 pylint==3.2.2