From ac502489382ab310fe17942b1f07b657d491d2a0 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Fri, 18 Feb 2022 08:10:25 +0100 Subject: [PATCH] Add type ignore error codes [other] (#66781) --- homeassistant/components/diagnostics/util.py | 2 +- homeassistant/components/energy/data.py | 2 +- homeassistant/components/energy/sensor.py | 6 +++--- homeassistant/components/group/media_player.py | 6 +++--- homeassistant/components/sensor/__init__.py | 2 +- homeassistant/components/sensor/recorder.py | 4 ++-- homeassistant/components/tts/media_source.py | 2 +- homeassistant/components/zeroconf/usage.py | 4 ++-- homeassistant/components/zone/__init__.py | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/homeassistant/components/diagnostics/util.py b/homeassistant/components/diagnostics/util.py index 84971ba89f1..ba4f3d20f9a 100644 --- a/homeassistant/components/diagnostics/util.py +++ b/homeassistant/components/diagnostics/util.py @@ -12,7 +12,7 @@ T = TypeVar("T") @overload -def async_redact_data(data: Mapping, to_redact: Iterable[Any]) -> dict: # type: ignore +def async_redact_data(data: Mapping, to_redact: Iterable[Any]) -> dict: # type: ignore[misc] ... diff --git a/homeassistant/components/energy/data.py b/homeassistant/components/energy/data.py index f8c14ed8b73..d07d3406073 100644 --- a/homeassistant/components/energy/data.py +++ b/homeassistant/components/energy/data.py @@ -291,7 +291,7 @@ class EnergyManager: "device_consumption", ): if key in update: - data[key] = update[key] # type: ignore + data[key] = update[key] # type: ignore[misc] self.data = data self._store.async_delay_save(lambda: cast(dict, self.data), 60) diff --git a/homeassistant/components/energy/sensor.py b/homeassistant/components/energy/sensor.py index c0d9ffcea4a..f8591e5c23f 100644 --- a/homeassistant/components/energy/sensor.py +++ b/homeassistant/components/energy/sensor.py @@ -148,17 +148,17 @@ class SensorManager: self._process_sensor_data( adapter, # Opting out of the type complexity because can't get it to work - energy_source, # type: ignore + energy_source, # type: ignore[arg-type] to_add, to_remove, ) continue - for flow in energy_source[adapter.flow_type]: # type: ignore + for flow in energy_source[adapter.flow_type]: # type: ignore[typeddict-item] self._process_sensor_data( adapter, # Opting out of the type complexity because can't get it to work - flow, # type: ignore + flow, # type: ignore[arg-type] to_add, to_remove, ) diff --git a/homeassistant/components/group/media_player.py b/homeassistant/components/group/media_player.py index 976b8cc69f8..509c0cb4083 100644 --- a/homeassistant/components/group/media_player.py +++ b/homeassistant/components/group/media_player.py @@ -123,7 +123,7 @@ class MediaGroup(MediaPlayerEntity): """Update supported features and state when a new state is received.""" self.async_set_context(event.context) self.async_update_supported_features( - event.data.get("entity_id"), event.data.get("new_state") # type: ignore + event.data.get("entity_id"), event.data.get("new_state") # type: ignore[arg-type] ) self.async_update_state() @@ -361,14 +361,14 @@ class MediaGroup(MediaPlayerEntity): async def async_volume_up(self) -> None: """Turn volume up for media player(s).""" for entity in self._features[KEY_VOLUME]: - volume_level = self.hass.states.get(entity).attributes["volume_level"] # type: ignore + volume_level = self.hass.states.get(entity).attributes["volume_level"] # type: ignore[union-attr] if volume_level < 1: await self.async_set_volume_level(min(1, volume_level + 0.1)) async def async_volume_down(self) -> None: """Turn volume down for media player(s).""" for entity in self._features[KEY_VOLUME]: - volume_level = self.hass.states.get(entity).attributes["volume_level"] # type: ignore + volume_level = self.hass.states.get(entity).attributes["volume_level"] # type: ignore[union-attr] if volume_level > 0: await self.async_set_volume_level(max(0, volume_level - 0.1)) diff --git a/homeassistant/components/sensor/__init__.py b/homeassistant/components/sensor/__init__.py index c6c4d18d21d..f374ebaeb38 100644 --- a/homeassistant/components/sensor/__init__.py +++ b/homeassistant/components/sensor/__init__.py @@ -355,7 +355,7 @@ class SensorEntity(Entity): hasattr(self, "_attr_unit_of_measurement") and self._attr_unit_of_measurement is not None ): - return self._attr_unit_of_measurement # type: ignore + return self._attr_unit_of_measurement # type: ignore[unreachable] native_unit_of_measurement = self.native_unit_of_measurement diff --git a/homeassistant/components/sensor/recorder.py b/homeassistant/components/sensor/recorder.py index 50d09b207a0..635c5af6242 100644 --- a/homeassistant/components/sensor/recorder.py +++ b/homeassistant/components/sensor/recorder.py @@ -418,7 +418,7 @@ def _compile_statistics( # noqa: C901 ] history_list = {} if entities_full_history: - history_list = history.get_significant_states_with_session( # type: ignore + history_list = history.get_significant_states_with_session( # type: ignore[no-untyped-call] hass, session, start - datetime.timedelta.resolution, @@ -432,7 +432,7 @@ def _compile_statistics( # noqa: C901 if "sum" not in wanted_statistics[i.entity_id] ] if entities_significant_history: - _history_list = history.get_significant_states_with_session( # type: ignore + _history_list = history.get_significant_states_with_session( # type: ignore[no-untyped-call] hass, session, start - datetime.timedelta.resolution, diff --git a/homeassistant/components/tts/media_source.py b/homeassistant/components/tts/media_source.py index 43c3998849c..5e595ca42b7 100644 --- a/homeassistant/components/tts/media_source.py +++ b/homeassistant/components/tts/media_source.py @@ -56,7 +56,7 @@ class TTSMediaSource(MediaSource): manager: SpeechManager = self.hass.data[DOMAIN] try: - url = await manager.async_get_url_path(**kwargs) # type: ignore + url = await manager.async_get_url_path(**kwargs) # type: ignore[arg-type] except HomeAssistantError as err: raise Unresolvable(str(err)) from err diff --git a/homeassistant/components/zeroconf/usage.py b/homeassistant/components/zeroconf/usage.py index ab0a0eaf9a7..47798be3def 100644 --- a/homeassistant/components/zeroconf/usage.py +++ b/homeassistant/components/zeroconf/usage.py @@ -23,5 +23,5 @@ def install_multiple_zeroconf_catcher(hass_zc: HaZeroconf) -> None: def new_zeroconf_init(self: zeroconf.Zeroconf, *k: Any, **kw: Any) -> None: return - zeroconf.Zeroconf.__new__ = new_zeroconf_new # type: ignore - zeroconf.Zeroconf.__init__ = new_zeroconf_init # type: ignore + zeroconf.Zeroconf.__new__ = new_zeroconf_new # type: ignore[assignment] + zeroconf.Zeroconf.__init__ = new_zeroconf_init # type: ignore[assignment] diff --git a/homeassistant/components/zone/__init__.py b/homeassistant/components/zone/__init__.py index dd327acbf75..ef2d21281d1 100644 --- a/homeassistant/components/zone/__init__.py +++ b/homeassistant/components/zone/__init__.py @@ -122,7 +122,7 @@ def async_active_zone( continue within_zone = zone_dist - radius < zone.attributes[ATTR_RADIUS] - closer_zone = closest is None or zone_dist < min_dist # type: ignore + closer_zone = closest is None or zone_dist < min_dist # type: ignore[unreachable] smaller_zone = ( zone_dist == min_dist and zone.attributes[ATTR_RADIUS]