From 5e81d28116bfee89cbc95575a0a6265c339faff6 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 2 Feb 2023 18:35:24 +0100 Subject: [PATCH] Update black to 23.1.0 (#87188) --- .pre-commit-config.yaml | 2 +- homeassistant/bootstrap.py | 1 - homeassistant/components/adax/__init__.py | 1 - .../components/aladdin_connect/config_flow.py | 1 - homeassistant/components/alert/__init__.py | 1 - homeassistant/components/alexa/auth.py | 1 - homeassistant/components/alexa/intent.py | 1 - homeassistant/components/asuswrt/router.py | 1 - .../components/axis/binary_sensor.py | 2 -- .../components/bayesian/binary_sensor.py | 1 - .../components/bluesound/media_player.py | 1 - homeassistant/components/bluetooth/models.py | 1 - homeassistant/components/bosch_shc/switch.py | 5 ---- homeassistant/components/bthome/sensor.py | 10 ++++++-- homeassistant/components/buienradar/sensor.py | 1 - .../components/control4/config_flow.py | 1 - homeassistant/components/darksky/weather.py | 1 + .../components/deconz/binary_sensor.py | 1 - .../components/deconz/config_flow.py | 1 - homeassistant/components/deconz/sensor.py | 1 - homeassistant/components/deconz/services.py | 2 -- homeassistant/components/delijn/sensor.py | 2 +- homeassistant/components/derivative/sensor.py | 2 +- .../device_sun_light_trigger/__init__.py | 1 - homeassistant/components/dnsip/config_flow.py | 1 - .../components/doods/image_processing.py | 1 - homeassistant/components/ebusd/__init__.py | 1 - homeassistant/components/ecovacs/vacuum.py | 1 - homeassistant/components/elv/switch.py | 2 +- homeassistant/components/emoncms/sensor.py | 1 - .../components/emulated_hue/hue_api.py | 6 ++--- homeassistant/components/escea/config_flow.py | 1 - homeassistant/components/ezviz/camera.py | 3 --- homeassistant/components/ezviz/config_flow.py | 1 - .../components/faa_delays/config_flow.py | 1 - homeassistant/components/filter/sensor.py | 3 --- homeassistant/components/fints/sensor.py | 1 - homeassistant/components/firmata/__init__.py | 2 +- .../components/fleetgo/device_tracker.py | 1 - homeassistant/components/flipr/__init__.py | 2 +- homeassistant/components/flo/device.py | 2 +- homeassistant/components/flume/sensor.py | 1 - homeassistant/components/fritz/switch.py | 2 -- homeassistant/components/glances/sensor.py | 1 - .../components/google_assistant/helpers.py | 1 - .../components/harmony/config_flow.py | 1 - .../components/homematicip_cloud/climate.py | 7 +++++- homeassistant/components/honeywell/climate.py | 1 - .../components/honeywell/config_flow.py | 1 - homeassistant/components/hue/migration.py | 2 -- .../hvv_departures/binary_sensor.py | 1 - .../components/hvv_departures/config_flow.py | 3 --- homeassistant/components/hyperion/__init__.py | 2 +- homeassistant/components/ifttt/__init__.py | 1 - .../components/intellifire/config_flow.py | 1 - .../components/intellifire/coordinator.py | 1 - .../components/isy994/binary_sensor.py | 2 +- homeassistant/components/isy994/helpers.py | 1 - homeassistant/components/izone/climate.py | 5 ++-- homeassistant/components/izone/config_flow.py | 1 - .../components/juicenet/config_flow.py | 1 - .../components/kitchen_sink/repairs.py | 2 +- .../landisgyr_heat_meter/__init__.py | 1 - homeassistant/components/lifx/manager.py | 4 ---- homeassistant/components/london_air/sensor.py | 1 - homeassistant/components/lovelace/__init__.py | 1 - homeassistant/components/lupusec/switch.py | 1 - .../components/lutron/binary_sensor.py | 2 +- homeassistant/components/lutron/cover.py | 2 +- homeassistant/components/lutron/light.py | 2 +- homeassistant/components/lutron/switch.py | 2 +- .../components/lutron_caseta/__init__.py | 1 - .../components/lutron_caseta/button.py | 1 - .../components/mediaroom/media_player.py | 1 - .../components/melnor/config_flow.py | 2 -- homeassistant/components/met/weather.py | 2 +- .../components/meteo_france/__init__.py | 1 - .../components/mikrotik/device_tracker.py | 2 -- .../components/minecraft_server/helpers.py | 2 +- homeassistant/components/modbus/__init__.py | 5 +++- .../components/mold_indicator/sensor.py | 1 - .../components/mqtt/binary_sensor.py | 1 - homeassistant/components/mqtt/client.py | 1 - homeassistant/components/mqtt/discovery.py | 2 +- homeassistant/components/mqtt/subscription.py | 6 ++++- homeassistant/components/nam/config_flow.py | 1 - homeassistant/components/nest/config_flow.py | 1 - .../components/nfandroidtv/config_flow.py | 1 - .../components/nibe_heatpump/__init__.py | 1 - homeassistant/components/nina/__init__.py | 1 - homeassistant/components/nina/config_flow.py | 2 -- .../components/numato/binary_sensor.py | 1 - homeassistant/components/onvif/config_flow.py | 1 - .../components/open_meteo/weather.py | 1 - .../components/opencv/image_processing.py | 2 +- .../components/openhome/media_player.py | 12 ++++++---- .../weather_update_coordinator.py | 1 - .../components/philips_js/config_flow.py | 1 - .../components/philips_js/media_player.py | 1 - homeassistant/components/plex/__init__.py | 1 - .../components/poolsense/__init__.py | 2 +- .../components/progettihwsw/config_flow.py | 1 - homeassistant/components/ps4/media_player.py | 1 - .../components/pushbullet/config_flow.py | 1 - .../components/pushover/config_flow.py | 1 - homeassistant/components/pushover/notify.py | 1 - homeassistant/components/qvr_pro/camera.py | 1 - homeassistant/components/rachio/switch.py | 2 +- .../components/rainbird/config_flow.py | 2 +- homeassistant/components/recorder/pool.py | 1 - homeassistant/components/recorder/purge.py | 1 - .../components/repairs/issue_handler.py | 2 +- .../components/rest_command/__init__.py | 1 - .../components/rfxtrx/binary_sensor.py | 1 - .../components/rss_feed_template/__init__.py | 2 +- homeassistant/components/sabnzbd/__init__.py | 1 - .../components/sabnzbd/config_flow.py | 1 - homeassistant/components/script/__init__.py | 1 - .../components/sensibo/config_flow.py | 1 - homeassistant/components/shelly/climate.py | 1 - .../components/simplepush/config_flow.py | 1 - .../components/smartthings/__init__.py | 1 + homeassistant/components/snmp/sensor.py | 1 - homeassistant/components/snmp/switch.py | 1 - homeassistant/components/sonos/speaker.py | 2 +- homeassistant/components/spc/__init__.py | 1 - homeassistant/components/sql/config_flow.py | 1 - .../components/srp_energy/__init__.py | 2 +- .../components/srp_energy/config_flow.py | 1 - homeassistant/components/srp_energy/sensor.py | 2 +- homeassistant/components/supla/__init__.py | 1 - .../components/surepetcare/binary_sensor.py | 1 - .../components/surepetcare/sensor.py | 1 - .../swiss_hydrological_data/sensor.py | 1 - homeassistant/components/switchbee/climate.py | 1 - homeassistant/components/switchbee/light.py | 1 - homeassistant/components/switchbee/switch.py | 1 - .../components/system_log/__init__.py | 2 -- homeassistant/components/tasmota/discovery.py | 4 ++-- .../components/tellduslive/config_flow.py | 1 - homeassistant/components/template/cover.py | 1 - homeassistant/components/template/fan.py | 1 - homeassistant/components/template/switch.py | 1 - .../components/tomato/device_tracker.py | 2 -- homeassistant/components/toon/coordinator.py | 1 - .../components/traccar/device_tracker.py | 6 ++++- .../components/trafikverket_train/sensor.py | 1 - .../components/transmission/config_flow.py | 1 - homeassistant/components/tuya/number.py | 1 - homeassistant/components/twinkly/light.py | 2 -- .../components/uk_transport/sensor.py | 2 +- homeassistant/components/unifi/config_flow.py | 2 -- homeassistant/components/unifi/controller.py | 3 --- .../components/unifi/device_tracker.py | 1 - homeassistant/components/unifi/services.py | 2 -- .../components/unifi_direct/device_tracker.py | 1 - .../components/unifiprotect/button.py | 1 - .../components/unifiprotect/sensor.py | 1 - .../components/w800rf32/binary_sensor.py | 2 -- homeassistant/components/whirlpool/sensor.py | 1 - homeassistant/components/ws66i/__init__.py | 1 - homeassistant/components/zamg/coordinator.py | 2 +- homeassistant/components/zamg/sensor.py | 2 +- homeassistant/components/zha/core/device.py | 6 ++--- homeassistant/components/zha/core/helpers.py | 1 - homeassistant/helpers/entity_platform.py | 6 ++--- homeassistant/helpers/network.py | 1 - homeassistant/helpers/service.py | 1 - requirements_test_pre_commit.txt | 2 +- script/translations/migrate.py | 2 -- tests/components/abode/test_config_flow.py | 1 - .../accuweather/test_config_flow.py | 4 ---- tests/components/accuweather/test_init.py | 2 -- tests/components/adax/test_config_flow.py | 5 +++- .../components/airthings/test_config_flow.py | 5 +++- .../components/aladdin_connect/test_cover.py | 2 -- tests/components/aladdin_connect/test_init.py | 5 ---- tests/components/alexa/test_smart_home.py | 10 ++++++-- tests/components/analytics/test_analytics.py | 2 -- .../components/androidtv/test_config_flow.py | 1 - .../aurora_abb_powerone/test_config_flow.py | 11 ++++++--- .../aussie_broadband/test_config_flow.py | 2 -- tests/components/aws/test_init.py | 1 - tests/components/axis/conftest.py | 1 - tests/components/backup/test_http.py | 1 - tests/components/backup/test_websocket.py | 1 - tests/components/blink/test_config_flow.py | 4 +++- .../components/bluetooth/test_base_scanner.py | 5 +++- .../components/bluetooth/test_diagnostics.py | 1 - tests/components/bluetooth/test_wrappers.py | 4 ++-- .../test_device_tracker.py | 4 ---- tests/components/brother/test_config_flow.py | 3 --- tests/components/canary/test_sensor.py | 4 ++-- tests/components/cloudflare/test_init.py | 1 - .../components/co2signal/test_config_flow.py | 15 +++++++++--- tests/components/coinbase/test_config_flow.py | 1 - tests/components/coinbase/test_diagnostics.py | 1 - .../deconz/test_alarm_control_panel.py | 2 -- tests/components/dhcp/test_init.py | 4 +++- .../components/dlna_dmr/test_media_player.py | 2 +- tests/components/ecobee/test_config_flow.py | 1 - tests/components/elkm1/__init__.py | 5 +++- tests/components/file/test_notify.py | 1 - tests/components/filesize/test_config_flow.py | 8 +++++-- .../fireservicerota/test_config_flow.py | 1 - tests/components/firmata/test_config_flow.py | 1 - .../freedompro/test_binary_sensor.py | 2 -- .../components/freedompro/test_config_flow.py | 3 --- tests/components/freedompro/test_sensor.py | 1 - tests/components/fritz/conftest.py | 1 - tests/components/fritz/test_config_flow.py | 13 ---------- tests/components/fronius/test_config_flow.py | 5 +++- tests/components/generic/test_camera.py | 2 -- tests/components/greeneye_monitor/conftest.py | 2 +- tests/components/hddtemp/test_sensor.py | 1 - tests/components/history_stats/test_sensor.py | 1 - .../components/honeywell/test_config_flow.py | 1 - tests/components/hue/test_config_flow.py | 2 +- tests/components/hue/test_init.py | 1 - .../components/huisbaasje/test_config_flow.py | 5 +++- tests/components/huisbaasje/test_sensor.py | 2 -- .../hvv_departures/test_config_flow.py | 5 ---- tests/components/insteon/test_config_flow.py | 17 +++++++++---- .../intellifire/test_config_flow.py | 2 -- tests/components/ipma/test_config_flow.py | 2 -- tests/components/ipma/test_init.py | 1 - tests/components/iss/test_config_flow.py | 1 - .../lacrosse_view/test_config_flow.py | 10 ++++++-- .../launch_library/test_config_flow.py | 1 - tests/components/led_ble/test_config_flow.py | 16 +++++++++---- .../litterrobot/test_config_flow.py | 2 -- tests/components/local_file/test_camera.py | 1 - tests/components/melnor/conftest.py | 1 - tests/components/melnor/test_config_flow.py | 5 ---- tests/components/melnor/test_number.py | 1 - tests/components/melnor/test_switch.py | 1 - .../minecraft_server/test_config_flow.py | 15 +++++++++--- tests/components/modbus/test_init.py | 2 +- .../moehlenhoff_alpha2/test_config_flow.py | 1 - tests/components/mqtt/test_common.py | 12 +++++----- tests/components/mqtt/test_discovery.py | 2 -- .../mqtt_json/test_device_tracker.py | 1 - tests/components/mutesync/test_config_flow.py | 5 +++- tests/components/nam/test_config_flow.py | 1 - tests/components/netatmo/test_init.py | 1 - tests/components/nexia/test_config_flow.py | 4 +++- tests/components/nina/test_binary_sensor.py | 2 -- tests/components/nina/test_config_flow.py | 5 ---- tests/components/nina/test_init.py | 1 - tests/components/nzbget/test_sensor.py | 2 +- tests/components/oncue/__init__.py | 9 ++++--- tests/components/plaato/test_config_flow.py | 2 -- tests/components/plant/test_init.py | 1 - .../prosegur/test_alarm_control_panel.py | 2 -- tests/components/prosegur/test_init.py | 1 - .../components/radiotherm/test_config_flow.py | 1 - tests/components/recorder/test_migrate.py | 5 +++- .../components/repairs/test_websocket_api.py | 2 +- tests/components/roon/test_config_flow.py | 5 ---- .../components/samsungtv/test_config_flow.py | 4 ---- .../components/samsungtv/test_media_player.py | 3 --- tests/components/scrape/test_config_flow.py | 5 +++- tests/components/script/test_blueprint.py | 1 - tests/components/senseme/__init__.py | 1 - tests/components/shelly/test_config_flow.py | 1 - tests/components/shelly/test_init.py | 2 -- tests/components/sleepiq/test_config_flow.py | 1 - tests/components/sma/test_config_flow.py | 1 - tests/components/smappee/test_config_flow.py | 5 +++- .../smartthings/test_config_flow.py | 1 - tests/components/sonarr/test_sensor.py | 2 +- tests/components/sql/test_sensor.py | 4 +++- .../components/squeezebox/test_config_flow.py | 10 ++++++-- tests/components/srp_energy/__init__.py | 1 - .../components/srp_energy/test_config_flow.py | 1 - tests/components/subaru/conftest.py | 5 +++- tests/components/subaru/test_config_flow.py | 9 +++++-- tests/components/subaru/test_init.py | 5 +++- .../components/switchbee/test_config_flow.py | 1 - .../synology_dsm/test_config_flow.py | 4 ---- .../tankerkoenig/test_config_flow.py | 1 - tests/components/tibber/test_statistics.py | 2 +- .../totalconnect/test_config_flow.py | 12 ++++++---- tests/components/upnp/conftest.py | 2 ++ tests/components/uptimerobot/common.py | 1 - .../uptimerobot/test_config_flow.py | 4 ---- .../uptimerobot/test_diagnostics.py | 2 -- tests/components/uptimerobot/test_init.py | 2 -- tests/components/uptimerobot/test_switch.py | 2 -- tests/components/vera/test_sensor.py | 2 +- tests/components/version/common.py | 2 -- tests/components/vulcan/test_config_flow.py | 6 ----- tests/components/vultr/test_binary_sensor.py | 1 - tests/components/vultr/test_sensor.py | 2 -- tests/components/wake_on_lan/test_switch.py | 7 ------ tests/components/wallbox/test_number.py | 1 - .../components/whirlpool/test_config_flow.py | 1 - tests/components/wolflink/test_config_flow.py | 1 - tests/components/ws66i/test_config_flow.py | 1 - tests/components/yeelight/test_config_flow.py | 1 - tests/components/zeroconf/test_init.py | 24 +++++++++++++++---- tests/components/zha/test_channels.py | 2 +- tests/components/zwave_me/test_config_flow.py | 1 - .../zwave_me/test_remove_stale_devices.py | 5 +++- tests/conftest.py | 1 - tests/helpers/test_config_entry_flow.py | 2 -- tests/helpers/test_device_registry.py | 2 +- tests/helpers/test_entity.py | 1 - tests/helpers/test_translation.py | 6 ++++- tests/scripts/test_check_config.py | 1 - tests/test_config_entries.py | 1 - tests/test_requirements.py | 5 ---- 312 files changed, 299 insertions(+), 475 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e9321ac7df4..1e7b03a1994 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,7 +20,7 @@ repos: - --remove-all-unused-imports stages: [manual] - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.1.0 hooks: - id: black args: diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index e821d0de10e..1cc850f31e4 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -406,7 +406,6 @@ def async_enable_logging( if (err_path_exists and os.access(err_log_path, os.W_OK)) or ( not err_path_exists and os.access(err_dir, os.W_OK) ): - err_handler: ( logging.handlers.RotatingFileHandler | logging.handlers.TimedRotatingFileHandler diff --git a/homeassistant/components/adax/__init__.py b/homeassistant/components/adax/__init__.py index 438f1fc74ad..511fb746216 100644 --- a/homeassistant/components/adax/__init__.py +++ b/homeassistant/components/adax/__init__.py @@ -24,7 +24,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> # convert title and unique_id to string if config_entry.version == 1: if isinstance(config_entry.unique_id, int): - hass.config_entries.async_update_entry( config_entry, unique_id=str(config_entry.unique_id), diff --git a/homeassistant/components/aladdin_connect/config_flow.py b/homeassistant/components/aladdin_connect/config_flow.py index eb201182b68..89d3b0faf14 100644 --- a/homeassistant/components/aladdin_connect/config_flow.py +++ b/homeassistant/components/aladdin_connect/config_flow.py @@ -88,7 +88,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): errors["base"] = "cannot_connect" else: - self.hass.config_entries.async_update_entry( self.entry, data={ diff --git a/homeassistant/components/alert/__init__.py b/homeassistant/components/alert/__init__.py index 4f8f1dade93..120b24dcc44 100644 --- a/homeassistant/components/alert/__init__.py +++ b/homeassistant/components/alert/__init__.py @@ -270,7 +270,6 @@ class Alert(Entity): await self._send_notification_message(message) async def _send_notification_message(self, message: Any) -> None: - if not self._notifiers: return diff --git a/homeassistant/components/alexa/auth.py b/homeassistant/components/alexa/auth.py index 1ce20d154bd..2dbda64568f 100644 --- a/homeassistant/components/alexa/auth.py +++ b/homeassistant/components/alexa/auth.py @@ -103,7 +103,6 @@ class Auth: return dt.utcnow() < preemptive_expire_time async def _async_request_new_token(self, lwa_params): - try: session = aiohttp_client.async_get_clientsession(self.hass) async with async_timeout.timeout(10): diff --git a/homeassistant/components/alexa/intent.py b/homeassistant/components/alexa/intent.py index ef145a9ceb8..c18ffd316b1 100644 --- a/homeassistant/components/alexa/intent.py +++ b/homeassistant/components/alexa/intent.py @@ -193,7 +193,6 @@ def resolve_slot_synonyms(key, request): and "resolutionsPerAuthority" in request["resolutions"] and len(request["resolutions"]["resolutionsPerAuthority"]) >= 1 ): - # Extract all of the possible values from each authority with a # successful match possible_values = [] diff --git a/homeassistant/components/asuswrt/router.py b/homeassistant/components/asuswrt/router.py index ffdec02bd3e..4291c21d0ed 100644 --- a/homeassistant/components/asuswrt/router.py +++ b/homeassistant/components/asuswrt/router.py @@ -274,7 +274,6 @@ class AsusWrtRouter: entity_reg, self._entry.entry_id ) for entry in track_entries: - if entry.domain != TRACKER_DOMAIN: continue device_mac = format_mac(entry.unique_id) diff --git a/homeassistant/components/axis/binary_sensor.py b/homeassistant/components/axis/binary_sensor.py index 729d69ed45b..067014cc81f 100644 --- a/homeassistant/components/axis/binary_sensor.py +++ b/homeassistant/components/axis/binary_sensor.py @@ -112,7 +112,6 @@ class AxisBinarySensor(AxisEventEntity, BinarySensorEntity): self._attr_name = self.device.api.vapix.ports[event.id].name elif event.group == EventGroup.MOTION: - for event_topic, event_data in ( (EventTopic.FENCE_GUARD, self.device.api.vapix.fence_guard), (EventTopic.LOITERING_GUARD, self.device.api.vapix.loitering_guard), @@ -120,7 +119,6 @@ class AxisBinarySensor(AxisEventEntity, BinarySensorEntity): (EventTopic.OBJECT_ANALYTICS, self.device.api.vapix.object_analytics), (EventTopic.MOTION_DETECTION_4, self.device.api.vapix.vmd4), ): - if ( event.topic_base == event_topic and event_data diff --git a/homeassistant/components/bayesian/binary_sensor.py b/homeassistant/components/bayesian/binary_sensor.py index 4cd68c7a9b4..5266e310428 100644 --- a/homeassistant/components/bayesian/binary_sensor.py +++ b/homeassistant/components/bayesian/binary_sensor.py @@ -399,7 +399,6 @@ class BayesianBinarySensor(BinarySensorEntity): observations_by_entity: dict[str, list[Observation]] = {} for observation in self._observations: - if (key := observation.entity_id) is None: continue observations_by_entity.setdefault(key, []).append(observation) diff --git a/homeassistant/components/bluesound/media_player.py b/homeassistant/components/bluesound/media_player.py index 7c23e76385a..69e115470ad 100644 --- a/homeassistant/components/bluesound/media_player.py +++ b/homeassistant/components/bluesound/media_player.py @@ -396,7 +396,6 @@ class BluesoundPlayer(MediaPlayerEntity): _LOGGER.debug("Calling URL: %s", url) try: - async with async_timeout.timeout(125): response = await self._polling_session.get( url, headers={CONNECTION: KEEP_ALIVE} diff --git a/homeassistant/components/bluetooth/models.py b/homeassistant/components/bluetooth/models.py index 58067a467ce..40ac86de607 100644 --- a/homeassistant/components/bluetooth/models.py +++ b/homeassistant/components/bluetooth/models.py @@ -12,7 +12,6 @@ from home_assistant_bluetooth import BluetoothServiceInfoBleak from homeassistant.util.dt import monotonic_time_coarse if TYPE_CHECKING: - from .manager import BluetoothManager diff --git a/homeassistant/components/bosch_shc/switch.py b/homeassistant/components/bosch_shc/switch.py index 1bc430c8d4a..dc9159622d9 100644 --- a/homeassistant/components/bosch_shc/switch.py +++ b/homeassistant/components/bosch_shc/switch.py @@ -95,7 +95,6 @@ async def async_setup_entry( session: SHCSession = hass.data[DOMAIN][config_entry.entry_id][DATA_SESSION] for switch in session.device_helper.smart_plugs: - entities.append( SHCSwitch( device=switch, @@ -113,7 +112,6 @@ async def async_setup_entry( ) for switch in session.device_helper.light_switches: - entities.append( SHCSwitch( device=switch, @@ -124,7 +122,6 @@ async def async_setup_entry( ) for switch in session.device_helper.smart_plugs_compact: - entities.append( SHCSwitch( device=switch, @@ -135,7 +132,6 @@ async def async_setup_entry( ) for switch in session.device_helper.camera_eyes: - entities.append( SHCSwitch( device=switch, @@ -146,7 +142,6 @@ async def async_setup_entry( ) for switch in session.device_helper.camera_360: - entities.append( SHCSwitch( device=switch, diff --git a/homeassistant/components/bthome/sensor.py b/homeassistant/components/bthome/sensor.py index 8cc8b10a67c..2d4fb07d579 100644 --- a/homeassistant/components/bthome/sensor.py +++ b/homeassistant/components/bthome/sensor.py @@ -231,7 +231,10 @@ SENSOR_DESCRIPTIONS = { state_class=SensorStateClass.MEASUREMENT, ), # UV index (-) - (BTHomeSensorDeviceClass.UV_INDEX, None,): SensorEntityDescription( + ( + BTHomeSensorDeviceClass.UV_INDEX, + None, + ): SensorEntityDescription( key=f"{BTHomeSensorDeviceClass.UV_INDEX}", state_class=SensorStateClass.MEASUREMENT, ), @@ -256,7 +259,10 @@ SENSOR_DESCRIPTIONS = { state_class=SensorStateClass.MEASUREMENT, ), # Volume (L) - (BTHomeSensorDeviceClass.VOLUME, Units.VOLUME_LITERS,): SensorEntityDescription( + ( + BTHomeSensorDeviceClass.VOLUME, + Units.VOLUME_LITERS, + ): SensorEntityDescription( key=f"{BTHomeSensorDeviceClass.VOLUME}_{Units.VOLUME_LITERS}", device_class=SensorDeviceClass.VOLUME, native_unit_of_measurement=UnitOfVolume.LITERS, diff --git a/homeassistant/components/buienradar/sensor.py b/homeassistant/components/buienradar/sensor.py index 1ba51e476d8..ae762efefe7 100644 --- a/homeassistant/components/buienradar/sensor.py +++ b/homeassistant/components/buienradar/sensor.py @@ -735,7 +735,6 @@ class BrSensor(SensorEntity): or sensor_type.endswith("_4d") or sensor_type.endswith("_5d") ): - # update forecasting sensors: fcday = 0 if sensor_type.endswith("_2d"): diff --git a/homeassistant/components/control4/config_flow.py b/homeassistant/components/control4/config_flow.py index 05fd8a2b7c8..06dc62d114b 100644 --- a/homeassistant/components/control4/config_flow.py +++ b/homeassistant/components/control4/config_flow.py @@ -96,7 +96,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): """Handle the initial step.""" errors = {} if user_input is not None: - hub = Control4Validator( user_input[CONF_HOST], user_input[CONF_USERNAME], diff --git a/homeassistant/components/darksky/weather.py b/homeassistant/components/darksky/weather.py index 530f1788dd8..25672908670 100644 --- a/homeassistant/components/darksky/weather.py +++ b/homeassistant/components/darksky/weather.py @@ -188,6 +188,7 @@ class DarkSkyWeather(WeatherEntity): @property def forecast(self): """Return the forecast array.""" + # Per conversation with Joshua Reyes of Dark Sky, to get the total # forecasted precipitation, you have to multiple the intensity by # the hours for the forecast interval diff --git a/homeassistant/components/deconz/binary_sensor.py b/homeassistant/components/deconz/binary_sensor.py index ef78e8f1419..0b646bedbd8 100644 --- a/homeassistant/components/deconz/binary_sensor.py +++ b/homeassistant/components/deconz/binary_sensor.py @@ -271,7 +271,6 @@ class DeconzBinarySensor(DeconzDevice[SensorResources], BinarySensorEntity): attr[ATTR_TEMPERATURE] = self._device.internal_temperature if isinstance(self._device, Presence): - if self._device.dark is not None: attr[ATTR_DARK] = self._device.dark diff --git a/homeassistant/components/deconz/config_flow.py b/homeassistant/components/deconz/config_flow.py index 569f13666df..acbf5089f96 100644 --- a/homeassistant/components/deconz/config_flow.py +++ b/homeassistant/components/deconz/config_flow.py @@ -87,7 +87,6 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN): If no bridge is found allow user to manually input configuration. """ if user_input is not None: - if user_input[CONF_HOST] == CONF_MANUAL_INPUT: return await self.async_step_manual_input() diff --git a/homeassistant/components/deconz/sensor.py b/homeassistant/components/deconz/sensor.py index ee27beaa8e2..03c9f9c70f5 100644 --- a/homeassistant/components/deconz/sensor.py +++ b/homeassistant/components/deconz/sensor.py @@ -372,7 +372,6 @@ class DeconzSensor(DeconzDevice[SensorResources], SensorEntity): attr[ATTR_DAYLIGHT] = self._device.daylight elif isinstance(self._device, LightLevel): - if self._device.dark is not None: attr[ATTR_DARK] = self._device.dark diff --git a/homeassistant/components/deconz/services.py b/homeassistant/components/deconz/services.py index e4399e53524..5cea4ca3b15 100644 --- a/homeassistant/components/deconz/services.py +++ b/homeassistant/components/deconz/services.py @@ -186,10 +186,8 @@ async def async_remove_orphaned_entries_service(gateway: DeconzGateway) -> None: devices_to_be_removed.remove(event.device_id) for entry in entity_entries: - # Don't remove available entities if entry.unique_id in gateway.entities[entry.domain]: - # Don't remove devices with available entities if entry.device_id in devices_to_be_removed: devices_to_be_removed.remove(entry.device_id) diff --git a/homeassistant/components/delijn/sensor.py b/homeassistant/components/delijn/sensor.py index f0a263d0d0f..2cf85b91abd 100644 --- a/homeassistant/components/delijn/sensor.py +++ b/homeassistant/components/delijn/sensor.py @@ -121,6 +121,6 @@ class DeLijnPublicTransportSensor(SensorEntity): self._attr_extra_state_attributes["next_passages"] = self.line.passages self._attr_available = True - except (KeyError) as error: + except KeyError as error: _LOGGER.error("Invalid data received from De Lijn: %s", error) self._attr_available = False diff --git a/homeassistant/components/derivative/sensor.py b/homeassistant/components/derivative/sensor.py index 85d964a84cb..adf91eb706b 100644 --- a/homeassistant/components/derivative/sensor.py +++ b/homeassistant/components/derivative/sensor.py @@ -245,7 +245,7 @@ class DerivativeSensor(RestoreEntity, SensorEntity): derivative = new_derivative else: derivative = Decimal(0) - for (start, end, value) in self._state_list: + for start, end, value in self._state_list: weight = calculate_weight(start, end, new_state.last_updated) derivative = derivative + (value * Decimal(weight)) diff --git a/homeassistant/components/device_sun_light_trigger/__init__.py b/homeassistant/components/device_sun_light_trigger/__init__.py index a78b3432016..ea9205ebdec 100644 --- a/homeassistant/components/device_sun_light_trigger/__init__.py +++ b/homeassistant/components/device_sun_light_trigger/__init__.py @@ -214,7 +214,6 @@ async def activate_automation( # noqa: C901 elif start_point and start_point < now < get_astral_event_next( hass, SUN_EVENT_SUNSET ): - # Check for every light if it would be on if someone was home # when the fading in started and turn it on if so for index, light_id in enumerate(light_ids): diff --git a/homeassistant/components/dnsip/config_flow.py b/homeassistant/components/dnsip/config_flow.py index eb48095539a..6a1437d5159 100644 --- a/homeassistant/components/dnsip/config_flow.py +++ b/homeassistant/components/dnsip/config_flow.py @@ -93,7 +93,6 @@ class DnsIPConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): errors = {} if user_input: - hostname = user_input[CONF_HOSTNAME] name = DEFAULT_NAME if hostname == DEFAULT_HOSTNAME else hostname resolver = user_input.get(CONF_RESOLVER, DEFAULT_RESOLVER) diff --git a/homeassistant/components/doods/image_processing.py b/homeassistant/components/doods/image_processing.py index 677aafc0b52..8240bb117ea 100644 --- a/homeassistant/components/doods/image_processing.py +++ b/homeassistant/components/doods/image_processing.py @@ -255,7 +255,6 @@ class Doods(ImageProcessingEntity): ) for label, values in matches.items(): - # Draw custom label regions/areas if label in self._label_areas and self._label_areas[label] != [0, 0, 1, 1]: box_label = f"{label.capitalize()} Detection Area" diff --git a/homeassistant/components/ebusd/__init__.py b/homeassistant/components/ebusd/__init__.py index 14158b6c379..ab83759bb2d 100644 --- a/homeassistant/components/ebusd/__init__.py +++ b/homeassistant/components/ebusd/__init__.py @@ -66,7 +66,6 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool: server_address = (conf.get(CONF_HOST), conf.get(CONF_PORT)) try: - ebusdpy.init(server_address) hass.data[DOMAIN] = EbusdData(server_address, circuit) diff --git a/homeassistant/components/ecovacs/vacuum.py b/homeassistant/components/ecovacs/vacuum.py index ca1a153b5ae..f1bf7deb502 100644 --- a/homeassistant/components/ecovacs/vacuum.py +++ b/homeassistant/components/ecovacs/vacuum.py @@ -160,7 +160,6 @@ class EcovacsVacuum(VacuumEntity): def set_fan_speed(self, fan_speed: str, **kwargs: Any) -> None: """Set fan speed.""" if self.is_on: - self.device.run(sucks.Clean(mode=self.device.clean_status, speed=fan_speed)) def send_command( diff --git a/homeassistant/components/elv/switch.py b/homeassistant/components/elv/switch.py index d7e35f3e04c..b998e2dd737 100644 --- a/homeassistant/components/elv/switch.py +++ b/homeassistant/components/elv/switch.py @@ -87,7 +87,7 @@ class SmartPlugSwitch(SwitchEntity): self._state = self._pca.get_state(self._device_id) self._available = True - except (OSError) as ex: + except OSError as ex: if self._available: _LOGGER.warning("Could not read state for %s: %s", self.name, ex) self._available = False diff --git a/homeassistant/components/emoncms/sensor.py b/homeassistant/components/emoncms/sensor.py index 4a427615aaf..f26ed72f44c 100644 --- a/homeassistant/components/emoncms/sensor.py +++ b/homeassistant/components/emoncms/sensor.py @@ -106,7 +106,6 @@ def setup_platform( sensors = [] for elem in data.data: - if exclude_feeds is not None and int(elem["id"]) in exclude_feeds: continue diff --git a/homeassistant/components/emulated_hue/hue_api.py b/homeassistant/components/emulated_hue/hue_api.py index 272645909a5..a81544151ea 100644 --- a/homeassistant/components/emulated_hue/hue_api.py +++ b/homeassistant/components/emulated_hue/hue_api.py @@ -379,7 +379,7 @@ class HueOneLightChangeView(HomeAssistantView): else: parsed[STATE_ON] = entity.state != STATE_OFF - for (key, attr) in ( + for key, attr in ( (HUE_API_STATE_BRI, STATE_BRIGHTNESS), (HUE_API_STATE_HUE, STATE_HUE), (HUE_API_STATE_SAT, STATE_SATURATION), @@ -587,7 +587,7 @@ class HueOneLightChangeView(HomeAssistantView): ) ] - for (key, val) in ( + for key, val in ( (STATE_BRIGHTNESS, HUE_API_STATE_BRI), (STATE_HUE, HUE_API_STATE_HUE), (STATE_SATURATION, HUE_API_STATE_SAT), @@ -705,7 +705,7 @@ def get_entity_state_dict(config: Config, entity: State) -> dict[str, Any]: data[STATE_SATURATION] = 0 # Clamp brightness, hue, saturation, and color temp to valid values - for (key, v_min, v_max) in ( + for key, v_min, v_max in ( (STATE_BRIGHTNESS, HUE_API_STATE_BRI_MIN, HUE_API_STATE_BRI_MAX), (STATE_HUE, HUE_API_STATE_HUE_MIN, HUE_API_STATE_HUE_MAX), (STATE_SATURATION, HUE_API_STATE_SAT_MIN, HUE_API_STATE_SAT_MAX), diff --git a/homeassistant/components/escea/config_flow.py b/homeassistant/components/escea/config_flow.py index 5d0dfea1157..2a6e19343d9 100644 --- a/homeassistant/components/escea/config_flow.py +++ b/homeassistant/components/escea/config_flow.py @@ -21,7 +21,6 @@ _LOGGER = logging.getLogger(__name__) async def _async_has_devices(hass: HomeAssistant) -> bool: - controller_ready = asyncio.Event() @callback diff --git a/homeassistant/components/ezviz/camera.py b/homeassistant/components/ezviz/camera.py index 9fb7c1f8b5a..65b5df100dd 100644 --- a/homeassistant/components/ezviz/camera.py +++ b/homeassistant/components/ezviz/camera.py @@ -66,7 +66,6 @@ async def async_setup_entry( camera_entities = [] for camera, value in coordinator.data.items(): - camera_rtsp_entry = [ item for item in hass.config_entries.async_entries(DOMAIN) @@ -81,7 +80,6 @@ async def async_setup_entry( ) if camera_rtsp_entry: - ffmpeg_arguments = camera_rtsp_entry[0].options[CONF_FFMPEG_ARGUMENTS] camera_username = camera_rtsp_entry[0].data[CONF_USERNAME] camera_password = camera_rtsp_entry[0].data[CONF_PASSWORD] @@ -96,7 +94,6 @@ async def async_setup_entry( ) else: - discovery_flow.async_create_flow( hass, DOMAIN, diff --git a/homeassistant/components/ezviz/config_flow.py b/homeassistant/components/ezviz/config_flow.py index 61b66280ae8..4c8b1418fa5 100644 --- a/homeassistant/components/ezviz/config_flow.py +++ b/homeassistant/components/ezviz/config_flow.py @@ -182,7 +182,6 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN): errors = {} if user_input is not None: - if user_input[CONF_URL] == CONF_CUSTOMIZE: self.context["data"] = { CONF_USERNAME: user_input[CONF_USERNAME], diff --git a/homeassistant/components/faa_delays/config_flow.py b/homeassistant/components/faa_delays/config_flow.py index 1abd1f00fa5..023fe4d6a5b 100644 --- a/homeassistant/components/faa_delays/config_flow.py +++ b/homeassistant/components/faa_delays/config_flow.py @@ -25,7 +25,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): """Handle the initial step.""" errors = {} if user_input is not None: - await self.async_set_unique_id(user_input[CONF_ID]) self._abort_if_unique_id_configured() diff --git a/homeassistant/components/filter/sensor.py b/homeassistant/components/filter/sensor.py index e4166494ce4..6f290ccb293 100644 --- a/homeassistant/components/filter/sensor.py +++ b/homeassistant/components/filter/sensor.py @@ -507,7 +507,6 @@ class RangeFilter(Filter, SensorEntity): new_state_value = cast(float, new_state.state) if self._upper_bound is not None and new_state_value > self._upper_bound: - self._stats_internal["erasures_up"] += 1 _LOGGER.debug( @@ -519,7 +518,6 @@ class RangeFilter(Filter, SensorEntity): new_state.state = self._upper_bound elif self._lower_bound is not None and new_state_value < self._lower_bound: - self._stats_internal["erasures_low"] += 1 _LOGGER.debug( @@ -564,7 +562,6 @@ class OutlierFilter(Filter, SensorEntity): len(self.states) == self.states.maxlen and abs(new_state_value - median) > self._radius ): - self._stats_internal["erasures"] += 1 _LOGGER.debug( diff --git a/homeassistant/components/fints/sensor.py b/homeassistant/components/fints/sensor.py index dc6b40982b7..6ef0467f7b6 100644 --- a/homeassistant/components/fints/sensor.py +++ b/homeassistant/components/fints/sensor.py @@ -208,7 +208,6 @@ class FinTsClient: holdings_accounts = [] for account in self.client.get_sepa_accounts(): - if self.is_balance_account(account): balance_accounts.append(account) diff --git a/homeassistant/components/firmata/__init__.py b/homeassistant/components/firmata/__init__.py index a58cd0591d1..78b5592a54e 100644 --- a/homeassistant/components/firmata/__init__.py +++ b/homeassistant/components/firmata/__init__.py @@ -213,7 +213,7 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> _LOGGER.debug("Closing Firmata board %s", config_entry.data[CONF_NAME]) unload_entries = [] - for (conf, platform) in CONF_PLATFORM_MAP.items(): + for conf, platform in CONF_PLATFORM_MAP.items(): if conf in config_entry.data: unload_entries.append( hass.config_entries.async_forward_entry_unload(config_entry, platform) diff --git a/homeassistant/components/fleetgo/device_tracker.py b/homeassistant/components/fleetgo/device_tracker.py index e80acae8627..c901ccce3e7 100644 --- a/homeassistant/components/fleetgo/device_tracker.py +++ b/homeassistant/components/fleetgo/device_tracker.py @@ -86,7 +86,6 @@ class FleetGoDeviceScanner: for device in devices: if not self._include or device.license_plate in self._include: - if device.active or device.current_address is None: device.get_map_details() diff --git a/homeassistant/components/flipr/__init__.py b/homeassistant/components/flipr/__init__.py index 3f9f70e294c..f02911e30d5 100644 --- a/homeassistant/components/flipr/__init__.py +++ b/homeassistant/components/flipr/__init__.py @@ -74,7 +74,7 @@ class FliprDataUpdateCoordinator(DataUpdateCoordinator): data = await self.hass.async_add_executor_job( self.client.get_pool_measure_latest, self.flipr_id ) - except (FliprError) as error: + except FliprError as error: raise UpdateFailed(error) from error return data diff --git a/homeassistant/components/flo/device.py b/homeassistant/components/flo/device.py index d6e05c17136..1b28a2552a2 100644 --- a/homeassistant/components/flo/device.py +++ b/homeassistant/components/flo/device.py @@ -43,7 +43,7 @@ class FloDeviceDataUpdateCoordinator(DataUpdateCoordinator): await self.send_presence_ping() await self._update_device() await self._update_consumption_data() - except (RequestError) as error: + except RequestError as error: raise UpdateFailed(error) from error @property diff --git a/homeassistant/components/flume/sensor.py b/homeassistant/components/flume/sensor.py index 4b5fe5bc8e9..b656f5e9715 100644 --- a/homeassistant/components/flume/sensor.py +++ b/homeassistant/components/flume/sensor.py @@ -97,7 +97,6 @@ async def async_setup_entry( ] flume_entity_list = [] for device in flume_devices: - device_id = device[KEY_DEVICE_ID] device_timezone = device[KEY_DEVICE_LOCATION][KEY_DEVICE_LOCATION_TIMEZONE] device_location_name = device[KEY_DEVICE_LOCATION][KEY_DEVICE_LOCATION_NAME] diff --git a/homeassistant/components/fritz/switch.py b/homeassistant/components/fritz/switch.py index a83b39ebbb1..6072aee89a7 100644 --- a/homeassistant/components/fritz/switch.py +++ b/homeassistant/components/fritz/switch.py @@ -102,7 +102,6 @@ async def _async_port_entities_list( _LOGGER.debug("IP source for %s is %s", avm_wrapper.host, local_ip) for i in range(port_forwards_count): - portmap = await avm_wrapper.async_get_port_mapping( avm_wrapper.device_conn_type, i ) @@ -406,7 +405,6 @@ class FritzBoxPortSwitch(FritzBoxBaseSwitch, SwitchEntity): self._attributes[attr] = self.port_mapping[key] async def _async_switch_on_off_executor(self, turn_on: bool) -> bool: - if self.port_mapping is None: return False diff --git a/homeassistant/components/glances/sensor.py b/homeassistant/components/glances/sensor.py index ee959943b82..e0eaf3bb38a 100644 --- a/homeassistant/components/glances/sensor.py +++ b/homeassistant/components/glances/sensor.py @@ -262,7 +262,6 @@ async def async_setup_entry( if entity_id := ent_reg.async_get_entity_id( Platform.SENSOR, DOMAIN, old_unique_id ): - ent_reg.async_update_entity( entity_id, new_unique_id=f"{config_entry.entry_id}-{new_key}" ) diff --git a/homeassistant/components/google_assistant/helpers.py b/homeassistant/components/google_assistant/helpers.py index 2a011679d09..196fa580ea8 100644 --- a/homeassistant/components/google_assistant/helpers.py +++ b/homeassistant/components/google_assistant/helpers.py @@ -289,7 +289,6 @@ class AbstractConfig(ABC): return for user_agent_id, _ in self._store.agent_user_ids.items(): - if (webhook_id := self.get_local_webhook_id(user_agent_id)) is None: setup_successful = False break diff --git a/homeassistant/components/harmony/config_flow.py b/homeassistant/components/harmony/config_flow.py index 675acf600cb..f74a19425ab 100644 --- a/homeassistant/components/harmony/config_flow.py +++ b/homeassistant/components/harmony/config_flow.py @@ -64,7 +64,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): """Handle the initial step.""" errors = {} if user_input is not None: - try: validated = await validate_input(user_input) except CannotConnect: diff --git a/homeassistant/components/homematicip_cloud/climate.py b/homeassistant/components/homematicip_cloud/climate.py index 737ffaf8c19..6e2ca202fd3 100644 --- a/homeassistant/components/homematicip_cloud/climate.py +++ b/homeassistant/components/homematicip_cloud/climate.py @@ -316,7 +316,12 @@ class HomematicipHeatingGroup(HomematicipGenericEntity, ClimateEntity): @property def _first_radiator_thermostat( self, - ) -> AsyncHeatingThermostat | AsyncHeatingThermostatCompact | AsyncHeatingThermostatEvo | None: + ) -> ( + AsyncHeatingThermostat + | AsyncHeatingThermostatCompact + | AsyncHeatingThermostatEvo + | None + ): """Return the first radiator thermostat from the hmip heating group.""" for device in self._device.devices: if isinstance( diff --git a/homeassistant/components/honeywell/climate.py b/homeassistant/components/honeywell/climate.py index 8a98f70626c..4fdc1e58f7d 100644 --- a/homeassistant/components/honeywell/climate.py +++ b/homeassistant/components/honeywell/climate.py @@ -343,7 +343,6 @@ class HoneywellUSThermostat(ClimateEntity): _LOGGER.error("Can not get system mode") return try: - # Set permanent hold # and Set temperature if mode in COOLING_MODES: diff --git a/homeassistant/components/honeywell/config_flow.py b/homeassistant/components/honeywell/config_flow.py index 0f9d5663b3e..a5f50cdcca9 100644 --- a/homeassistant/components/honeywell/config_flow.py +++ b/homeassistant/components/honeywell/config_flow.py @@ -67,7 +67,6 @@ class HoneywellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): errors["base"] = "cannot_connect" else: - self.hass.config_entries.async_update_entry( self.entry, data={ diff --git a/homeassistant/components/hue/migration.py b/homeassistant/components/hue/migration.py index 221888b0854..035da145cc0 100644 --- a/homeassistant/components/hue/migration.py +++ b/homeassistant/components/hue/migration.py @@ -92,7 +92,6 @@ async def handle_v2_migration(hass: core.HomeAssistant, entry: ConfigEntry) -> N # initialize bridge connection just for the migration async with HueBridgeV2(host, api_key) as api: - sensor_class_mapping = { SensorDeviceClass.BATTERY.value: ResourceTypes.DEVICE_POWER, BinarySensorDeviceClass.MOTION.value: ResourceTypes.MOTION, @@ -130,7 +129,6 @@ async def handle_v2_migration(hass: core.HomeAssistant, entry: ConfigEntry) -> N # loop through all entities for device and find match for ent in async_entries_for_device(ent_reg, hass_dev_id, True): - if ent.entity_id.startswith("light"): # migrate light # should always return one lightid here diff --git a/homeassistant/components/hvv_departures/binary_sensor.py b/homeassistant/components/hvv_departures/binary_sensor.py index a99dea57447..36b1b5f927f 100644 --- a/homeassistant/components/hvv_departures/binary_sensor.py +++ b/homeassistant/components/hvv_departures/binary_sensor.py @@ -48,7 +48,6 @@ async def async_setup_entry( for partial_station in station_information.get("partialStations", []): for elevator in partial_station.get("elevators", []): - state = elevator.get("state") != "READY" available = elevator.get("state") != "UNKNOWN" label = elevator.get("label") diff --git a/homeassistant/components/hvv_departures/config_flow.py b/homeassistant/components/hvv_departures/config_flow.py index 5f07593eeb5..4cbd0a83321 100644 --- a/homeassistant/components/hvv_departures/config_flow.py +++ b/homeassistant/components/hvv_departures/config_flow.py @@ -81,7 +81,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_station(self, user_input=None): """Handle the step where the user inputs his/her station.""" if user_input is not None: - errors = {} check_name = await self.hub.gti.checkName( @@ -145,7 +144,6 @@ class OptionsFlowHandler(config_entries.OptionsFlow): """Manage the options.""" errors = {} if not self.departure_filters: - departure_list = {} hub: GTIHub = self.hass.data[DOMAIN][self.config_entry.entry_id] @@ -172,7 +170,6 @@ class OptionsFlowHandler(config_entries.OptionsFlow): } if user_input is not None and not errors: - options = { CONF_FILTER: [ self.departure_filters[x] for x in user_input[CONF_FILTER] diff --git a/homeassistant/components/hyperion/__init__.py b/homeassistant/components/hyperion/__init__.py index c3cd473c3f4..6c2842c190e 100644 --- a/homeassistant/components/hyperion/__init__.py +++ b/homeassistant/components/hyperion/__init__.py @@ -259,7 +259,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: for device_entry in dr.async_entries_for_config_entry( device_registry, entry.entry_id ): - for (kind, key) in device_entry.identifiers: + for kind, key in device_entry.identifiers: if kind == DOMAIN and key in known_devices: break else: diff --git a/homeassistant/components/ifttt/__init__.py b/homeassistant/components/ifttt/__init__.py index 40b44f00a73..0f8b7a0fa74 100644 --- a/homeassistant/components/ifttt/__init__.py +++ b/homeassistant/components/ifttt/__init__.py @@ -77,7 +77,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: target_keys[target] = api_keys[target] try: - for target, key in target_keys.items(): res = pyfttt.send_event(key, event, value1, value2, value3) if res.status_code != HTTPStatus.OK: diff --git a/homeassistant/components/intellifire/config_flow.py b/homeassistant/components/intellifire/config_flow.py index d2b019cb381..91676724a8b 100644 --- a/homeassistant/components/intellifire/config_flow.py +++ b/homeassistant/components/intellifire/config_flow.py @@ -119,7 +119,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): ) if user_input is not None: - control_schema = vol.Schema( { vol.Required( diff --git a/homeassistant/components/intellifire/coordinator.py b/homeassistant/components/intellifire/coordinator.py index 356ddedf16d..b6753adef76 100644 --- a/homeassistant/components/intellifire/coordinator.py +++ b/homeassistant/components/intellifire/coordinator.py @@ -33,7 +33,6 @@ class IntellifireDataUpdateCoordinator(DataUpdateCoordinator[IntellifirePollData self._api = api async def _async_update_data(self) -> IntellifirePollData: - if not self._api.is_polling_in_background: LOGGER.info("Starting Intellifire Background Polling Loop") await self._api.start_background_polling() diff --git a/homeassistant/components/isy994/binary_sensor.py b/homeassistant/components/isy994/binary_sensor.py index 521bfb41a80..90c2d6b3818 100644 --- a/homeassistant/components/isy994/binary_sensor.py +++ b/homeassistant/components/isy994/binary_sensor.py @@ -95,7 +95,7 @@ async def async_setup_entry( entities_by_address[node.address] = entity # Handle some special child node cases for Insteon Devices - for (node, device_class, device_type, device_info) in child_nodes: + for node, device_class, device_type, device_info in child_nodes: subnode_id = int(node.address.split(" ")[-1], 16) # Handle Insteon Thermostats if device_type is not None and device_type.startswith(TYPE_CATEGORY_CLIMATE): diff --git a/homeassistant/components/isy994/helpers.py b/homeassistant/components/isy994/helpers.py index b190638fb35..53ad87c9ddc 100644 --- a/homeassistant/components/isy994/helpers.py +++ b/homeassistant/components/isy994/helpers.py @@ -109,7 +109,6 @@ def _check_for_insteon_type( device_type.startswith(t) for t in set(NODE_FILTERS[platform][FILTER_INSTEON_TYPE]) ): - # Hacky special-cases for certain devices with different platforms # included as subnodes. Note that special-cases are not necessary # on ISY 5.x firmware as it uses the superior NodeDefs method diff --git a/homeassistant/components/izone/climate.py b/homeassistant/components/izone/climate.py index ee1fe418366..4fb3447488f 100644 --- a/homeassistant/components/izone/climate.py +++ b/homeassistant/components/izone/climate.py @@ -173,6 +173,7 @@ class ControllerDevice(ClimateEntity): async def async_added_to_hass(self) -> None: """Call on adding to hass.""" + # Register for connect/disconnect/update events @callback def controller_disconnected(ctrl: Controller, ex: Exception) -> None: @@ -290,7 +291,7 @@ class ControllerDevice(ClimateEntity): return HVACMode.OFF if (mode := self._controller.mode) == Controller.Mode.FREE_AIR: return HVACMode.FAN_ONLY - for (key, value) in self._state_to_pizone.items(): + for key, value in self._state_to_pizone.items(): if value == mode: return key raise RuntimeError("Should be unreachable") @@ -527,7 +528,7 @@ class ZoneDevice(ClimateEntity): def hvac_mode(self) -> HVACMode | None: """Return current operation ie. heat, cool, idle.""" mode = self._zone.mode - for (key, value) in self._state_to_pizone.items(): + for key, value in self._state_to_pizone.items(): if value == mode: return key return None diff --git a/homeassistant/components/izone/config_flow.py b/homeassistant/components/izone/config_flow.py index bc4fb8ceddc..af5205feb07 100644 --- a/homeassistant/components/izone/config_flow.py +++ b/homeassistant/components/izone/config_flow.py @@ -17,7 +17,6 @@ _LOGGER = logging.getLogger(__name__) async def _async_has_devices(hass: HomeAssistant) -> bool: - controller_ready = asyncio.Event() @callback diff --git a/homeassistant/components/juicenet/config_flow.py b/homeassistant/components/juicenet/config_flow.py index 93c46cd4834..35c1853b974 100644 --- a/homeassistant/components/juicenet/config_flow.py +++ b/homeassistant/components/juicenet/config_flow.py @@ -46,7 +46,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): """Handle the initial step.""" errors = {} if user_input is not None: - await self.async_set_unique_id(user_input[CONF_ACCESS_TOKEN]) self._abort_if_unique_id_configured() diff --git a/homeassistant/components/kitchen_sink/repairs.py b/homeassistant/components/kitchen_sink/repairs.py index 41db200dd72..51b474dcf0f 100644 --- a/homeassistant/components/kitchen_sink/repairs.py +++ b/homeassistant/components/kitchen_sink/repairs.py @@ -17,7 +17,7 @@ class DemoFixFlow(RepairsFlow): ) -> data_entry_flow.FlowResult: """Handle the first step of a fix flow.""" - return await (self.async_step_confirm()) + return await self.async_step_confirm() async def async_step_confirm( self, user_input: dict[str, str] | None = None diff --git a/homeassistant/components/landisgyr_heat_meter/__init__.py b/homeassistant/components/landisgyr_heat_meter/__init__.py index 6ef17cf24da..eae5e91196c 100644 --- a/homeassistant/components/landisgyr_heat_meter/__init__.py +++ b/homeassistant/components/landisgyr_heat_meter/__init__.py @@ -62,7 +62,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> # Removing domain name and config entry id from entity unique id's, replacing it with device number if config_entry.version == 1: - config_entry.version = 2 device_number = config_entry.data["device_number"] diff --git a/homeassistant/components/lifx/manager.py b/homeassistant/components/lifx/manager.py index 1eb80c0c5a2..9e72ded620e 100644 --- a/homeassistant/components/lifx/manager.py +++ b/homeassistant/components/lifx/manager.py @@ -296,7 +296,6 @@ class LIFXManager: ) elif service == SERVICE_EFFECT_MORPH: - theme_name = kwargs.get(ATTR_THEME, "exciting") palette = kwargs.get(ATTR_PALETTE, None) @@ -336,7 +335,6 @@ class LIFXManager: ) elif service == SERVICE_EFFECT_PULSE: - effect = aiolifx_effects.EffectPulse( power_on=kwargs.get(ATTR_POWER_ON), period=kwargs.get(ATTR_PERIOD), @@ -347,7 +345,6 @@ class LIFXManager: await self.effects_conductor.start(effect, bulbs) elif service == SERVICE_EFFECT_COLORLOOP: - brightness = None saturation_max = None saturation_min = None @@ -378,7 +375,6 @@ class LIFXManager: await self.effects_conductor.start(effect, bulbs) elif service == SERVICE_EFFECT_STOP: - await self.effects_conductor.stop(bulbs) for coordinator in coordinators: diff --git a/homeassistant/components/london_air/sensor.py b/homeassistant/components/london_air/sensor.py index 45f585da39d..6538c06d0ba 100644 --- a/homeassistant/components/london_air/sensor.py +++ b/homeassistant/components/london_air/sensor.py @@ -218,7 +218,6 @@ def parse_api_response(response): for authority in AUTHORITIES: for entry in response["HourlyAirQualityIndex"]["LocalAuthority"]: if entry["@LocalAuthorityName"] == authority: - if isinstance(entry["Site"], dict): entry_sites_data = [entry["Site"]] else: diff --git a/homeassistant/components/lovelace/__init__.py b/homeassistant/components/lovelace/__init__.py index 485579087a1..f880f83d766 100644 --- a/homeassistant/components/lovelace/__init__.py +++ b/homeassistant/components/lovelace/__init__.py @@ -157,7 +157,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: return if change_type == collection.CHANGE_ADDED: - existing = hass.data[DOMAIN]["dashboards"].get(url_path) if existing: diff --git a/homeassistant/components/lupusec/switch.py b/homeassistant/components/lupusec/switch.py index 546f96fd0a6..b4294216003 100644 --- a/homeassistant/components/lupusec/switch.py +++ b/homeassistant/components/lupusec/switch.py @@ -31,7 +31,6 @@ def setup_platform( devices = [] for device in data.lupusec.get_devices(generic_type=CONST.TYPE_SWITCH): - devices.append(LupusecSwitch(data, device)) add_entities(devices) diff --git a/homeassistant/components/lutron/binary_sensor.py b/homeassistant/components/lutron/binary_sensor.py index 4fc432bf66d..9f9851fb484 100644 --- a/homeassistant/components/lutron/binary_sensor.py +++ b/homeassistant/components/lutron/binary_sensor.py @@ -24,7 +24,7 @@ def setup_platform( if discovery_info is None: return devs = [] - for (area_name, device) in hass.data[LUTRON_DEVICES]["binary_sensor"]: + for area_name, device in hass.data[LUTRON_DEVICES]["binary_sensor"]: dev = LutronOccupancySensor(area_name, device, hass.data[LUTRON_CONTROLLER]) devs.append(dev) diff --git a/homeassistant/components/lutron/cover.py b/homeassistant/components/lutron/cover.py index 65a1c737d55..57fd8ac9d5b 100644 --- a/homeassistant/components/lutron/cover.py +++ b/homeassistant/components/lutron/cover.py @@ -26,7 +26,7 @@ def setup_platform( ) -> None: """Set up the Lutron shades.""" devs = [] - for (area_name, device) in hass.data[LUTRON_DEVICES]["cover"]: + for area_name, device in hass.data[LUTRON_DEVICES]["cover"]: dev = LutronCover(area_name, device, hass.data[LUTRON_CONTROLLER]) devs.append(dev) diff --git a/homeassistant/components/lutron/light.py b/homeassistant/components/lutron/light.py index 15024122338..6bd556d36d1 100644 --- a/homeassistant/components/lutron/light.py +++ b/homeassistant/components/lutron/light.py @@ -19,7 +19,7 @@ def setup_platform( ) -> None: """Set up the Lutron lights.""" devs = [] - for (area_name, device) in hass.data[LUTRON_DEVICES]["light"]: + for area_name, device in hass.data[LUTRON_DEVICES]["light"]: dev = LutronLight(area_name, device, hass.data[LUTRON_CONTROLLER]) devs.append(dev) diff --git a/homeassistant/components/lutron/switch.py b/homeassistant/components/lutron/switch.py index 8595f809035..f8ca93beb2e 100644 --- a/homeassistant/components/lutron/switch.py +++ b/homeassistant/components/lutron/switch.py @@ -21,7 +21,7 @@ def setup_platform( devs = [] # Add Lutron Switches - for (area_name, device) in hass.data[LUTRON_DEVICES]["switch"]: + for area_name, device in hass.data[LUTRON_DEVICES]["switch"]: dev = LutronSwitch(area_name, device, hass.data[LUTRON_CONTROLLER]) devs.append(dev) diff --git a/homeassistant/components/lutron_caseta/__init__.py b/homeassistant/components/lutron_caseta/__init__.py index b9418373b38..e1d71353426 100644 --- a/homeassistant/components/lutron_caseta/__init__.py +++ b/homeassistant/components/lutron_caseta/__init__.py @@ -256,7 +256,6 @@ def _async_setup_keypads( leap_to_keypad_button_names: dict[int, dict[int, str]] = {} for bridge_button in bridge_buttons.values(): - parent_device = cast(str, bridge_button["parent_device"]) bridge_keypad = bridge_devices[parent_device] keypad_lutron_device_id = cast(int, bridge_keypad["device_id"]) diff --git a/homeassistant/components/lutron_caseta/button.py b/homeassistant/components/lutron_caseta/button.py index ee737673082..b0e6d49de65 100644 --- a/homeassistant/components/lutron_caseta/button.py +++ b/homeassistant/components/lutron_caseta/button.py @@ -29,7 +29,6 @@ async def async_setup_entry( entities: list[LutronCasetaButton] = [] for device in button_devices.values(): - parent_keypad = keypads[device["parent_device"]] parent_device_info = parent_keypad["device_info"] diff --git a/homeassistant/components/mediaroom/media_player.py b/homeassistant/components/mediaroom/media_player.py index 09e137c96d1..4dc6d677abb 100644 --- a/homeassistant/components/mediaroom/media_player.py +++ b/homeassistant/components/mediaroom/media_player.py @@ -93,7 +93,6 @@ async def async_setup_platform( async_add_entities([new_stb]) if not config[CONF_OPTIMISTIC]: - already_installed = hass.data.get(DISCOVERY_MEDIAROOM) if not already_installed: hass.data[DISCOVERY_MEDIAROOM] = await install_mediaroom_protocol( diff --git a/homeassistant/components/melnor/config_flow.py b/homeassistant/components/melnor/config_flow.py index 7e9aed24e8a..7aad59acf7b 100644 --- a/homeassistant/components/melnor/config_flow.py +++ b/homeassistant/components/melnor/config_flow.py @@ -80,12 +80,10 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): for discovery_info in async_discovered_service_info( self.hass, connectable=True ): - if discovery_info.manufacturer_id == MANUFACTURER_ID and any( manufacturer_data.startswith(MANUFACTURER_DATA_START) for manufacturer_data in discovery_info.manufacturer_data.values() ): - address = discovery_info.address if ( address not in current_addresses diff --git a/homeassistant/components/met/weather.py b/homeassistant/components/met/weather.py index ba8ccadfca5..f507cf8cf32 100644 --- a/homeassistant/components/met/weather.py +++ b/homeassistant/components/met/weather.py @@ -94,7 +94,7 @@ class MetWeather(CoordinatorEntity[MetDataUpdateCoordinator], WeatherEntity): self._hourly = hourly @property - def track_home(self) -> (Any | bool): + def track_home(self) -> Any | bool: """Return if we are tracking home.""" return self._config.get(CONF_TRACK_HOME, False) diff --git a/homeassistant/components/meteo_france/__init__.py b/homeassistant/components/meteo_france/__init__.py index 6c9af12a322..3b82399f217 100644 --- a/homeassistant/components/meteo_france/__init__.py +++ b/homeassistant/components/meteo_france/__init__.py @@ -172,7 +172,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" if hass.data[DOMAIN][entry.entry_id][COORDINATOR_ALERT]: - department = hass.data[DOMAIN][entry.entry_id][ COORDINATOR_FORECAST ].data.position.get("dept") diff --git a/homeassistant/components/mikrotik/device_tracker.py b/homeassistant/components/mikrotik/device_tracker.py index 2c3e480c297..71d94a27fec 100644 --- a/homeassistant/components/mikrotik/device_tracker.py +++ b/homeassistant/components/mikrotik/device_tracker.py @@ -35,12 +35,10 @@ async def async_setup_entry( # Restore clients that is not a part of active clients list. for entity in registry.entities.values(): - if ( entity.config_entry_id == config_entry.entry_id and entity.domain == DEVICE_TRACKER ): - if ( entity.unique_id in coordinator.api.devices or entity.unique_id not in coordinator.api.all_devices diff --git a/homeassistant/components/minecraft_server/helpers.py b/homeassistant/components/minecraft_server/helpers.py index 7153c170a6a..d4a49d96f83 100644 --- a/homeassistant/components/minecraft_server/helpers.py +++ b/homeassistant/components/minecraft_server/helpers.py @@ -22,7 +22,7 @@ async def async_check_srv_record( srv_records = await aiodns.DNSResolver().query( host=f"{SRV_RECORD_PREFIX}.{host}", qtype="SRV" ) - except (aiodns.error.DNSError): + except aiodns.error.DNSError: # 'host' is not a SRV record. pass else: diff --git a/homeassistant/components/modbus/__init__.py b/homeassistant/components/modbus/__init__.py index a62d8537a33..24555704ac0 100644 --- a/homeassistant/components/modbus/__init__.py +++ b/homeassistant/components/modbus/__init__.py @@ -249,7 +249,10 @@ CLIMATE_SCHEMA = vol.All( COVERS_SCHEMA = BASE_COMPONENT_SCHEMA.extend( { - vol.Optional(CONF_INPUT_TYPE, default=CALL_TYPE_REGISTER_HOLDING,): vol.In( + vol.Optional( + CONF_INPUT_TYPE, + default=CALL_TYPE_REGISTER_HOLDING, + ): vol.In( [ CALL_TYPE_REGISTER_HOLDING, CALL_TYPE_COIL, diff --git a/homeassistant/components/mold_indicator/sensor.py b/homeassistant/components/mold_indicator/sensor.py index 95cb24fe7ed..ee3ab9817ea 100644 --- a/homeassistant/components/mold_indicator/sensor.py +++ b/homeassistant/components/mold_indicator/sensor.py @@ -315,7 +315,6 @@ class MoldIndicator(SensorEntity): def _calc_moldindicator(self): """Calculate the humidity at the (cold) calibration point.""" if None in (self._dewpoint, self._calib_factor) or self._calib_factor == 0: - _LOGGER.debug( "Invalid inputs - dewpoint: %s, calibration-factor: %s", self._dewpoint, diff --git a/homeassistant/components/mqtt/binary_sensor.py b/homeassistant/components/mqtt/binary_sensor.py index 135151f179c..d09e31f65f9 100644 --- a/homeassistant/components/mqtt/binary_sensor.py +++ b/homeassistant/components/mqtt/binary_sensor.py @@ -200,7 +200,6 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity, RestoreEntity): """Handle a new received MQTT state message.""" # auto-expire enabled? if self._expire_after: - # When expire_after is set, and we receive a message, assume device is # not expired since it has to be to receive the message self._expired = False diff --git a/homeassistant/components/mqtt/client.py b/homeassistant/components/mqtt/client.py index 755bf3636df..28d60a5fdb9 100644 --- a/homeassistant/components/mqtt/client.py +++ b/homeassistant/components/mqtt/client.py @@ -666,7 +666,6 @@ class MQTT: subscriptions = self._matching_subscriptions(msg.topic) for subscription in subscriptions: - payload: SubscribePayloadType = msg.payload if subscription.encoding is not None: try: diff --git a/homeassistant/components/mqtt/discovery.py b/homeassistant/components/mqtt/discovery.py index 3accb7c8ade..90f04b084b0 100644 --- a/homeassistant/components/mqtt/discovery.py +++ b/homeassistant/components/mqtt/discovery.py @@ -279,7 +279,7 @@ async def async_start( # noqa: C901 mqtt_data.last_discovery = time.time() mqtt_integrations = await async_get_mqtt(hass) - for (integration, topics) in mqtt_integrations.items(): + for integration, topics in mqtt_integrations.items(): async def async_integration_message_received( integration: str, msg: ReceiveMessage diff --git a/homeassistant/components/mqtt/subscription.py b/homeassistant/components/mqtt/subscription.py index e3fd5e50093..29beafdbe84 100644 --- a/homeassistant/components/mqtt/subscription.py +++ b/homeassistant/components/mqtt/subscription.py @@ -64,7 +64,11 @@ class EntitySubscription: if other is None: return True - return (self.topic, self.qos, self.encoding,) != ( + return ( + self.topic, + self.qos, + self.encoding, + ) != ( other.topic, other.qos, other.encoding, diff --git a/homeassistant/components/nam/config_flow.py b/homeassistant/components/nam/config_flow.py index 20021f1e6d4..6cf9dd55451 100644 --- a/homeassistant/components/nam/config_flow.py +++ b/homeassistant/components/nam/config_flow.py @@ -135,7 +135,6 @@ class NAMFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): _LOGGER.exception("Unexpected exception") errors["base"] = "unknown" else: - return self.async_create_entry( title=self.host, data={**user_input, CONF_HOST: self.host}, diff --git a/homeassistant/components/nest/config_flow.py b/homeassistant/components/nest/config_flow.py index 352a7ba1725..43900b068c5 100644 --- a/homeassistant/components/nest/config_flow.py +++ b/homeassistant/components/nest/config_flow.py @@ -428,7 +428,6 @@ class NestFlowHandler( _LOGGER.error("Error creating subscription: %s", err) errors[CONF_CLOUD_PROJECT_ID] = "subscriber_error" if not errors: - try: device_manager = await subscriber.async_get_device_manager() except ApiException as err: diff --git a/homeassistant/components/nfandroidtv/config_flow.py b/homeassistant/components/nfandroidtv/config_flow.py index 88eebe1b4d4..d4491cee48e 100644 --- a/homeassistant/components/nfandroidtv/config_flow.py +++ b/homeassistant/components/nfandroidtv/config_flow.py @@ -26,7 +26,6 @@ class NFAndroidTVFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): errors = {} if user_input is not None: - self._async_abort_entries_match( {CONF_HOST: user_input[CONF_HOST], CONF_NAME: user_input[CONF_NAME]} ) diff --git a/homeassistant/components/nibe_heatpump/__init__.py b/homeassistant/components/nibe_heatpump/__init__.py index a7b3c0968cc..57c5f680e01 100644 --- a/homeassistant/components/nibe_heatpump/__init__.py +++ b/homeassistant/components/nibe_heatpump/__init__.py @@ -265,7 +265,6 @@ class Coordinator(ContextCoordinator[dict[int, Coil], int]): self.task = None async def _async_update_data_internal(self) -> dict[int, Coil]: - result: dict[int, Coil] = {} def _get_coils() -> Iterable[Coil]: diff --git a/homeassistant/components/nina/__init__.py b/homeassistant/components/nina/__init__.py index 0555f175cfb..88d61a427b5 100644 --- a/homeassistant/components/nina/__init__.py +++ b/homeassistant/components/nina/__init__.py @@ -99,7 +99,6 @@ class NINADataUpdateCoordinator( all_filtered_warnings: dict[str, list[Any]] = {} for region_id, raw_warnings in warnings.items(): - filtered_warnings: list[Any] = [] processed_details: list[tuple[str, str]] = [] diff --git a/homeassistant/components/nina/config_flow.py b/homeassistant/components/nina/config_flow.py index bdaf164fadb..f1579bc05ec 100644 --- a/homeassistant/components/nina/config_flow.py +++ b/homeassistant/components/nina/config_flow.py @@ -126,7 +126,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): user_input[CONF_REGIONS] += group_input if user_input[CONF_REGIONS]: - return self.async_create_entry( title="NINA", data=prepare_user_input(user_input, self._all_region_codes_sorted), @@ -203,7 +202,6 @@ class OptionsFlowHandler(config_entries.OptionsFlow): user_input[CONF_REGIONS] += group_input if user_input[CONF_REGIONS]: - user_input = prepare_user_input( user_input, self._all_region_codes_sorted ) diff --git a/homeassistant/components/numato/binary_sensor.py b/homeassistant/components/numato/binary_sensor.py index cefec42ba3a..98e71b9fc2d 100644 --- a/homeassistant/components/numato/binary_sensor.py +++ b/homeassistant/components/numato/binary_sensor.py @@ -52,7 +52,6 @@ def setup_platform( ports = platform[CONF_PORTS] for port, port_name in ports.items(): try: - api.setup_input(device_id, port) api.edge_detect(device_id, port, partial(read_gpio, device_id)) diff --git a/homeassistant/components/onvif/config_flow.py b/homeassistant/components/onvif/config_flow.py index b4227b0cfa3..5eef092a5cb 100644 --- a/homeassistant/components/onvif/config_flow.py +++ b/homeassistant/components/onvif/config_flow.py @@ -108,7 +108,6 @@ class OnvifFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): If no device is found allow user to manually input configuration. """ if user_input: - if user_input[CONF_HOST] == CONF_MANUAL_INPUT: return await self.async_step_configure() diff --git a/homeassistant/components/open_meteo/weather.py b/homeassistant/components/open_meteo/weather.py index 614aed6eefb..2d06b20a30a 100644 --- a/homeassistant/components/open_meteo/weather.py +++ b/homeassistant/components/open_meteo/weather.py @@ -94,7 +94,6 @@ class OpenMeteoWeatherEntity( forecasts: list[Forecast] = [] daily = self.coordinator.data.daily for index, time in enumerate(self.coordinator.data.daily.time): - forecast = Forecast( datetime=time.isoformat(), ) diff --git a/homeassistant/components/opencv/image_processing.py b/homeassistant/components/opencv/image_processing.py index 463b5e0eed1..bef163252fa 100644 --- a/homeassistant/components/opencv/image_processing.py +++ b/homeassistant/components/opencv/image_processing.py @@ -189,7 +189,7 @@ class OpenCVImageProcessor(ImageProcessingEntity): ) regions = [] # pylint: disable=invalid-name - for (x, y, w, h) in detections: + for x, y, w, h in detections: regions.append((int(x), int(y), int(w), int(h))) total_matches += 1 diff --git a/homeassistant/components/openhome/media_player.py b/homeassistant/components/openhome/media_player.py index 707be76be3b..33f42ea949d 100644 --- a/homeassistant/components/openhome/media_player.py +++ b/homeassistant/components/openhome/media_player.py @@ -79,10 +79,12 @@ async def async_setup_platform( ) -def catch_request_errors() -> Callable[ - [Callable[Concatenate[_OpenhomeDeviceT, _P], Awaitable[_R]]], - Callable[Concatenate[_OpenhomeDeviceT, _P], Coroutine[Any, Any, _R | None]], -]: +def catch_request_errors() -> ( + Callable[ + [Callable[Concatenate[_OpenhomeDeviceT, _P], Awaitable[_R]]], + Callable[Concatenate[_OpenhomeDeviceT, _P], Coroutine[Any, Any, _R | None]], + ] +): """Catch asyncio.TimeoutError, aiohttp.ClientError, UpnpError errors.""" def call_wrapper( @@ -265,7 +267,7 @@ class OpenhomeDevice(MediaPlayerEntity): await self._device.invoke_pin(pin) else: _LOGGER.error("Pins service not supported") - except (UpnpError): + except UpnpError: _LOGGER.error("Error invoking pin %s", pin) @property diff --git a/homeassistant/components/openweathermap/weather_update_coordinator.py b/homeassistant/components/openweathermap/weather_update_coordinator.py index cedc33c1a8e..90e2c426d27 100644 --- a/homeassistant/components/openweathermap/weather_update_coordinator.py +++ b/homeassistant/components/openweathermap/weather_update_coordinator.py @@ -251,7 +251,6 @@ class WeatherUpdateCoordinator(DataUpdateCoordinator): def _get_condition(self, weather_code, timestamp=None): """Get weather condition from weather data.""" if weather_code == WEATHER_CODE_SUNNY_OR_CLEAR_NIGHT: - if timestamp: timestamp = dt.utc_from_timestamp(timestamp) diff --git a/homeassistant/components/philips_js/config_flow.py b/homeassistant/components/philips_js/config_flow.py index 39f1c78b070..dab8d4fbe24 100644 --- a/homeassistant/components/philips_js/config_flow.py +++ b/homeassistant/components/philips_js/config_flow.py @@ -49,7 +49,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self._pair_state: Any = None async def _async_create_current(self) -> FlowResult: - system = self._current[CONF_SYSTEM] return self.async_create_entry( title=f"{system['name']} ({system['serialnumber']})", diff --git a/homeassistant/components/philips_js/media_player.py b/homeassistant/components/philips_js/media_player.py index f88f02128e2..89cb29f0a07 100644 --- a/homeassistant/components/philips_js/media_player.py +++ b/homeassistant/components/philips_js/media_player.py @@ -437,7 +437,6 @@ class PhilipsTVMediaPlayer( @callback def _update_from_coordinator(self): - if self._tv.on: if self._tv.powerstate in ("Standby", "StandbyKeep"): self._attr_state = MediaPlayerState.OFF diff --git a/homeassistant/components/plex/__init__.py b/homeassistant/components/plex/__init__.py index 0012a5987e7..b215bc0d821 100644 --- a/homeassistant/components/plex/__init__.py +++ b/homeassistant/components/plex/__init__.py @@ -178,7 +178,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: def plex_websocket_callback(msgtype, data, error): """Handle callbacks from plexwebsocket library.""" if msgtype == SIGNAL_CONNECTION_STATE: - if data == STATE_CONNECTED: _LOGGER.debug("Websocket to %s successful", entry.data[CONF_SERVER]) hass.async_create_task(plex_server.async_update_platforms()) diff --git a/homeassistant/components/poolsense/__init__.py b/homeassistant/components/poolsense/__init__.py index a3e9a93da37..3652883b0f7 100644 --- a/homeassistant/components/poolsense/__init__.py +++ b/homeassistant/components/poolsense/__init__.py @@ -93,7 +93,7 @@ class PoolSenseDataUpdateCoordinator(DataUpdateCoordinator): async with async_timeout.timeout(10): try: data = await self.poolsense.get_poolsense_data() - except (PoolSenseError) as error: + except PoolSenseError as error: _LOGGER.error("PoolSense query did not complete") raise UpdateFailed(error) from error diff --git a/homeassistant/components/progettihwsw/config_flow.py b/homeassistant/components/progettihwsw/config_flow.py index 89d5916a3fd..5b996fd5eb4 100644 --- a/homeassistant/components/progettihwsw/config_flow.py +++ b/homeassistant/components/progettihwsw/config_flow.py @@ -42,7 +42,6 @@ class ProgettiHWSWConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): """Manage relay modes step.""" errors = {} if user_input is not None: - whole_data = user_input whole_data.update(self.s1_in) diff --git a/homeassistant/components/ps4/media_player.py b/homeassistant/components/ps4/media_player.py index 50c11781fa1..5df92fd795a 100644 --- a/homeassistant/components/ps4/media_player.py +++ b/homeassistant/components/ps4/media_player.py @@ -411,7 +411,6 @@ class PS4Device(MediaPlayerEntity): == game.lower().encode(encoding="utf-8") or source == title_id ): - _LOGGER.debug( "Starting PS4 game %s (%s) using source %s", game, title_id, source ) diff --git a/homeassistant/components/pushbullet/config_flow.py b/homeassistant/components/pushbullet/config_flow.py index bfa12a911b6..e6259fa8cee 100644 --- a/homeassistant/components/pushbullet/config_flow.py +++ b/homeassistant/components/pushbullet/config_flow.py @@ -36,7 +36,6 @@ class PushBulletConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): errors = {} if user_input is not None: - self._async_abort_entries_match({CONF_NAME: user_input[CONF_NAME]}) try: diff --git a/homeassistant/components/pushover/config_flow.py b/homeassistant/components/pushover/config_flow.py index 5119d91a174..32f91031351 100644 --- a/homeassistant/components/pushover/config_flow.py +++ b/homeassistant/components/pushover/config_flow.py @@ -89,7 +89,6 @@ class PushBulletConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): errors = {} if user_input is not None: - self._async_abort_entries_match( { CONF_USER_KEY: user_input[CONF_USER_KEY], diff --git a/homeassistant/components/pushover/notify.py b/homeassistant/components/pushover/notify.py index 9d6ae4b080d..2d79a0bf65a 100644 --- a/homeassistant/components/pushover/notify.py +++ b/homeassistant/components/pushover/notify.py @@ -52,7 +52,6 @@ async def async_get_service( ) -> PushoverNotificationService | None: """Get the Pushover notification service.""" if discovery_info is None: - async_create_issue( hass, DOMAIN, diff --git a/homeassistant/components/qvr_pro/camera.py b/homeassistant/components/qvr_pro/camera.py index 6ab918f26fe..f3caac864d9 100644 --- a/homeassistant/components/qvr_pro/camera.py +++ b/homeassistant/components/qvr_pro/camera.py @@ -30,7 +30,6 @@ def setup_platform( entities = [] for channel in hass.data[DOMAIN]["channels"]: - stream_source = get_stream_source(channel["guid"], client) entities.append( QVRProCamera(**channel, stream_source=stream_source, client=client) diff --git a/homeassistant/components/rachio/switch.py b/homeassistant/components/rachio/switch.py index 5e91d339d0d..bc27c0b2203 100644 --- a/homeassistant/components/rachio/switch.py +++ b/homeassistant/components/rachio/switch.py @@ -122,7 +122,7 @@ async def async_setup_entry( entity.entity_id: entity.zone_id for entity in zone_entities } - for (count, data) in enumerate(entity_id): + for count, data in enumerate(entity_id): if data in entity_to_zone_id: # Time can be passed as a list per zone, # or one time for all zones diff --git a/homeassistant/components/rainbird/config_flow.py b/homeassistant/components/rainbird/config_flow.py index 057fc6fe396..3ade67c79f7 100644 --- a/homeassistant/components/rainbird/config_flow.py +++ b/homeassistant/components/rainbird/config_flow.py @@ -138,7 +138,7 @@ class RainbirdConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): CONF_SERIAL_NUMBER: serial_number, } names: dict[str, str] = {} - for (zone, zone_config) in config.get(CONF_ZONES, {}).items(): + for zone, zone_config in config.get(CONF_ZONES, {}).items(): if name := zone_config.get(CONF_FRIENDLY_NAME): names[str(zone)] = name if names: diff --git a/homeassistant/components/recorder/pool.py b/homeassistant/components/recorder/pool.py index d839f183125..8f39bdb9b7f 100644 --- a/homeassistant/components/recorder/pool.py +++ b/homeassistant/components/recorder/pool.py @@ -121,7 +121,6 @@ class MutexPool(StaticPool): # type: ignore[misc] MutexPool.pool_lock.release() def _do_get(self) -> Any: - if DEBUG_MUTEX_POOL_TRACE: trace = traceback.extract_stack() trace_msg = "".join(traceback.format_list(trace[:-1])) diff --git a/homeassistant/components/recorder/purge.py b/homeassistant/components/recorder/purge.py index 01b10ea966a..4fb52dabb21 100644 --- a/homeassistant/components/recorder/purge.py +++ b/homeassistant/components/recorder/purge.py @@ -383,7 +383,6 @@ def _select_unused_event_data_ids( def _purge_unused_data_ids( instance: Recorder, session: Session, data_ids_batch: set[int], using_sqlite: bool ) -> None: - if unused_data_ids_set := _select_unused_event_data_ids( session, data_ids_batch, using_sqlite ): diff --git a/homeassistant/components/repairs/issue_handler.py b/homeassistant/components/repairs/issue_handler.py index 1dda2fb87a6..54b1f249ca6 100644 --- a/homeassistant/components/repairs/issue_handler.py +++ b/homeassistant/components/repairs/issue_handler.py @@ -27,7 +27,7 @@ class ConfirmRepairFlow(RepairsFlow): self, user_input: dict[str, str] | None = None ) -> data_entry_flow.FlowResult: """Handle the first step of a fix flow.""" - return await (self.async_step_confirm()) + return await self.async_step_confirm() async def async_step_confirm( self, user_input: dict[str, str] | None = None diff --git a/homeassistant/components/rest_command/__init__.py b/homeassistant/components/rest_command/__init__.py index c26f9711e1f..1007ee1d2de 100644 --- a/homeassistant/components/rest_command/__init__.py +++ b/homeassistant/components/rest_command/__init__.py @@ -125,7 +125,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: headers=headers, timeout=timeout, ) as response: - if response.status < HTTPStatus.BAD_REQUEST: _LOGGER.debug( "Success. Url: %s. Status code: %d. Payload: %s", diff --git a/homeassistant/components/rfxtrx/binary_sensor.py b/homeassistant/components/rfxtrx/binary_sensor.py index 03ad7ce071b..b729138f73e 100644 --- a/homeassistant/components/rfxtrx/binary_sensor.py +++ b/homeassistant/components/rfxtrx/binary_sensor.py @@ -104,7 +104,6 @@ async def async_setup_entry( device_id: DeviceTuple, entity_info: dict[str, Any], ) -> list[Entity]: - return [ RfxtrxBinarySensor( event.device, diff --git a/homeassistant/components/rss_feed_template/__init__.py b/homeassistant/components/rss_feed_template/__init__.py index 27a67fd6640..7b7cbb7e94f 100644 --- a/homeassistant/components/rss_feed_template/__init__.py +++ b/homeassistant/components/rss_feed_template/__init__.py @@ -43,7 +43,7 @@ CONFIG_SCHEMA = vol.Schema( def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the RSS feed template component.""" - for (feeduri, feedconfig) in config[DOMAIN].items(): + for feeduri, feedconfig in config[DOMAIN].items(): url = f"/api/rss_template/{feeduri}" requires_auth: bool = feedconfig["requires_api_password"] diff --git a/homeassistant/components/sabnzbd/__init__.py b/homeassistant/components/sabnzbd/__init__.py index fb3b4e46533..18f1ce9c451 100644 --- a/homeassistant/components/sabnzbd/__init__.py +++ b/homeassistant/components/sabnzbd/__init__.py @@ -225,7 +225,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: (SERVICE_RESUME, async_resume_queue, SERVICE_BASE_SCHEMA), (SERVICE_SET_SPEED, async_set_queue_speed, SERVICE_SPEED_SCHEMA), ): - if hass.services.has_service(DOMAIN, service): continue diff --git a/homeassistant/components/sabnzbd/config_flow.py b/homeassistant/components/sabnzbd/config_flow.py index 073f4a08f76..d433b562183 100644 --- a/homeassistant/components/sabnzbd/config_flow.py +++ b/homeassistant/components/sabnzbd/config_flow.py @@ -52,7 +52,6 @@ class SABnzbdConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): errors = {} if user_input is not None: - errors = await self._async_validate_input(user_input) if not errors: diff --git a/homeassistant/components/script/__init__.py b/homeassistant/components/script/__init__.py index 45786ae984a..b23f3d916cc 100644 --- a/homeassistant/components/script/__init__.py +++ b/homeassistant/components/script/__init__.py @@ -268,7 +268,6 @@ async def _create_script_entities( entities: list[ScriptEntity] = [] for script_config in script_configs: - entity = ScriptEntity( hass, script_config.key, diff --git a/homeassistant/components/sensibo/config_flow.py b/homeassistant/components/sensibo/config_flow.py index f3b413071e8..b7d4bca890e 100644 --- a/homeassistant/components/sensibo/config_flow.py +++ b/homeassistant/components/sensibo/config_flow.py @@ -82,7 +82,6 @@ class SensiboConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): errors: dict[str, str] = {} if user_input: - api_key = user_input[CONF_API_KEY] try: username = await async_validate_api(self.hass, api_key) diff --git a/homeassistant/components/shelly/climate.py b/homeassistant/components/shelly/climate.py index 5102ed9e4c3..6cd4c19c638 100644 --- a/homeassistant/components/shelly/climate.py +++ b/homeassistant/components/shelly/climate.py @@ -91,7 +91,6 @@ def async_restore_climate_entities( entries = async_entries_for_config_entry(ent_reg, config_entry.entry_id) for entry in entries: - if entry.domain != CLIMATE_DOMAIN: continue diff --git a/homeassistant/components/simplepush/config_flow.py b/homeassistant/components/simplepush/config_flow.py index 01ca508a5c4..702be4391e4 100644 --- a/homeassistant/components/simplepush/config_flow.py +++ b/homeassistant/components/simplepush/config_flow.py @@ -45,7 +45,6 @@ class SimplePushFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): """Handle a flow initiated by the user.""" errors: dict[str, str] | None = None if user_input is not None: - await self.async_set_unique_id(user_input[CONF_DEVICE_KEY]) self._abort_if_unique_id_configured() diff --git a/homeassistant/components/smartthings/__init__.py b/homeassistant/components/smartthings/__init__.py index 60cc2cea0d4..4f0c3aae2aa 100644 --- a/homeassistant/components/smartthings/__init__.py +++ b/homeassistant/components/smartthings/__init__.py @@ -318,6 +318,7 @@ class DeviceBroker: def connect(self): """Connect handlers/listeners for device/lifecycle events.""" + # Setup interval to regenerate the refresh token on a periodic basis. # Tokens expire in 30 days and once expired, cannot be recovered. async def regenerate_refresh_token(now): diff --git a/homeassistant/components/snmp/sensor.py b/homeassistant/components/snmp/sensor.py index 7fd192304a8..c20e5fe6e36 100644 --- a/homeassistant/components/snmp/sensor.py +++ b/homeassistant/components/snmp/sensor.py @@ -120,7 +120,6 @@ async def async_setup_platform( return if version == "3": - if not authkey: authproto = "none" if not privkey: diff --git a/homeassistant/components/snmp/switch.py b/homeassistant/components/snmp/switch.py index bd5078c4349..4699aaefd77 100644 --- a/homeassistant/components/snmp/switch.py +++ b/homeassistant/components/snmp/switch.py @@ -210,7 +210,6 @@ class SnmpSwitch(SwitchEntity): self._payload_off = payload_off if version == "3": - if not authkey: authproto = "none" if not privkey: diff --git a/homeassistant/components/sonos/speaker.py b/homeassistant/components/sonos/speaker.py index b1dfac7beed..09a6cfdf89f 100644 --- a/homeassistant/components/sonos/speaker.py +++ b/homeassistant/components/sonos/speaker.py @@ -180,7 +180,7 @@ class SonosSpeaker: (f"{SONOS_VANISHED}-{self.soco.uid}", self.async_vanished), ) - for (signal, target) in dispatch_pairs: + for signal, target in dispatch_pairs: entry.async_on_unload( async_dispatcher_connect( self.hass, diff --git a/homeassistant/components/spc/__init__.py b/homeassistant/components/spc/__init__.py index f3c829f5d0c..49dc7b13fca 100644 --- a/homeassistant/components/spc/__init__.py +++ b/homeassistant/components/spc/__init__.py @@ -41,7 +41,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the SPC component.""" async def async_upate_callback(spc_object): - if isinstance(spc_object, Area): async_dispatcher_send(hass, SIGNAL_UPDATE_ALARM.format(spc_object.id)) elif isinstance(spc_object, Zone): diff --git a/homeassistant/components/sql/config_flow.py b/homeassistant/components/sql/config_flow.py index cc8bbe672ba..f33aad68c3e 100644 --- a/homeassistant/components/sql/config_flow.py +++ b/homeassistant/components/sql/config_flow.py @@ -90,7 +90,6 @@ class SQLConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): ) if user_input is not None: - db_url = user_input.get(CONF_DB_URL, db_url_default) query = user_input[CONF_QUERY] column = user_input[CONF_COLUMN_NAME] diff --git a/homeassistant/components/srp_energy/__init__.py b/homeassistant/components/srp_energy/__init__.py index bed6780e523..b98b8a39dfa 100644 --- a/homeassistant/components/srp_energy/__init__.py +++ b/homeassistant/components/srp_energy/__init__.py @@ -26,7 +26,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: entry.data.get(CONF_PASSWORD), ) hass.data[SRP_ENERGY_DOMAIN] = srp_energy_client - except (Exception) as ex: + except Exception as ex: _LOGGER.error("Unable to connect to Srp Energy: %s", str(ex)) raise ConfigEntryNotReady from ex diff --git a/homeassistant/components/srp_energy/config_flow.py b/homeassistant/components/srp_energy/config_flow.py index f3df156f746..2d5505b7631 100644 --- a/homeassistant/components/srp_energy/config_flow.py +++ b/homeassistant/components/srp_energy/config_flow.py @@ -34,7 +34,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=SRP_ENERGY_DOMAIN): if user_input is not None: try: - srp_client = SrpEnergyClient( user_input[CONF_ID], user_input[CONF_USERNAME], diff --git a/homeassistant/components/srp_energy/sensor.py b/homeassistant/components/srp_energy/sensor.py index c4c7ec728e0..1aaf5175e53 100644 --- a/homeassistant/components/srp_energy/sensor.py +++ b/homeassistant/components/srp_energy/sensor.py @@ -61,7 +61,7 @@ async def async_setup_entry( for _, _, _, kwh, _ in hourly_usage: previous_daily_usage += float(kwh) return previous_daily_usage - except (TimeoutError) as timeout_err: + except TimeoutError as timeout_err: raise UpdateFailed("Timeout communicating with API") from timeout_err except (ConnectError, HTTPError, Timeout, ValueError, TypeError) as err: raise UpdateFailed(f"Error communicating with API: {err}") from err diff --git a/homeassistant/components/supla/__init__.py b/homeassistant/components/supla/__init__.py index 674855c6205..02818ccf8d6 100644 --- a/homeassistant/components/supla/__init__.py +++ b/homeassistant/components/supla/__init__.py @@ -63,7 +63,6 @@ async def async_setup(hass: HomeAssistant, base_config: ConfigType) -> bool: session = async_get_clientsession(hass) for server_conf in server_confs: - server_address = server_conf[CONF_SERVER] server = SuplaAPI(server_address, server_conf[CONF_ACCESS_TOKEN], session) diff --git a/homeassistant/components/surepetcare/binary_sensor.py b/homeassistant/components/surepetcare/binary_sensor.py index f4565ea3757..9af6c307d4c 100644 --- a/homeassistant/components/surepetcare/binary_sensor.py +++ b/homeassistant/components/surepetcare/binary_sensor.py @@ -31,7 +31,6 @@ async def async_setup_entry( coordinator: SurePetcareDataCoordinator = hass.data[DOMAIN][entry.entry_id] for surepy_entity in coordinator.data.values(): - # connectivity if surepy_entity.type in [ EntityType.CAT_FLAP, diff --git a/homeassistant/components/surepetcare/sensor.py b/homeassistant/components/surepetcare/sensor.py index 534f2396751..b6b2b75504e 100644 --- a/homeassistant/components/surepetcare/sensor.py +++ b/homeassistant/components/surepetcare/sensor.py @@ -29,7 +29,6 @@ async def async_setup_entry( coordinator: SurePetcareDataCoordinator = hass.data[DOMAIN][entry.entry_id] for surepy_entity in coordinator.data.values(): - if surepy_entity.type in [ EntityType.CAT_FLAP, EntityType.PET_FLAP, diff --git a/homeassistant/components/swiss_hydrological_data/sensor.py b/homeassistant/components/swiss_hydrological_data/sensor.py index dfa8b8fba04..d51ce18ada4 100644 --- a/homeassistant/components/swiss_hydrological_data/sensor.py +++ b/homeassistant/components/swiss_hydrological_data/sensor.py @@ -125,7 +125,6 @@ class SwissHydrologicalDataSensor(SensorEntity): attrs = {} if not self._data: - return attrs attrs[ATTR_WATER_BODY_TYPE] = self._data["water-body-type"] diff --git a/homeassistant/components/switchbee/climate.py b/homeassistant/components/switchbee/climate.py index 3b42287e89f..bf780e76eb0 100644 --- a/homeassistant/components/switchbee/climate.py +++ b/homeassistant/components/switchbee/climate.py @@ -115,7 +115,6 @@ class SwitchBeeClimateEntity(SwitchBeeDeviceEntity[SwitchBeeThermostat], Climate super()._handle_coordinator_update() def _update_attrs_from_coordinator(self) -> None: - coordinator_device = self._get_coordinator_device() self._attr_hvac_mode: HVACMode = ( diff --git a/homeassistant/components/switchbee/light.py b/homeassistant/components/switchbee/light.py index 0ff14a45e2f..7227815d976 100644 --- a/homeassistant/components/switchbee/light.py +++ b/homeassistant/components/switchbee/light.py @@ -71,7 +71,6 @@ class SwitchBeeLightEntity(SwitchBeeDeviceEntity[SwitchBeeDimmer], LightEntity): super()._handle_coordinator_update() def _update_attrs_from_coordinator(self) -> None: - coordinator_device = self._get_coordinator_device() brightness = coordinator_device.brightness diff --git a/homeassistant/components/switchbee/switch.py b/homeassistant/components/switchbee/switch.py index f8f6e30e368..d48a3e2e02a 100644 --- a/homeassistant/components/switchbee/switch.py +++ b/homeassistant/components/switchbee/switch.py @@ -79,7 +79,6 @@ class SwitchBeeSwitchEntity(SwitchBeeDeviceEntity[_DeviceTypeT], SwitchEntity): coordinator_device = self._get_coordinator_device() if coordinator_device.state == -1: - self._check_if_became_offline() return diff --git a/homeassistant/components/system_log/__init__.py b/homeassistant/components/system_log/__init__.py index 9f00009b322..cd46b4fd957 100644 --- a/homeassistant/components/system_log/__init__.py +++ b/homeassistant/components/system_log/__init__.py @@ -61,7 +61,6 @@ SERVICE_WRITE_SCHEMA = vol.Schema( def _figure_out_source( record: logging.LogRecord, call_stack: list[tuple[str, int]], paths_re: re.Pattern ) -> tuple[str, int]: - # If a stack trace exists, extract file names from the entire call stack. # The other case is when a regular "log" is made (without an attached # exception). In that case, just use the file where the log was made from. @@ -82,7 +81,6 @@ def _figure_out_source( # Iterate through the stack call (in reverse) and find the last call from # a file in Home Assistant. Try to figure out where error happened. for pathname in reversed(stack): - # Try to match with a file within Home Assistant if match := paths_re.match(pathname[0]): return (cast(str, match.group(1)), pathname[1]) diff --git a/homeassistant/components/tasmota/discovery.py b/homeassistant/components/tasmota/discovery.py index 4ab3f780ad3..b490b4c724c 100644 --- a/homeassistant/components/tasmota/discovery.py +++ b/homeassistant/components/tasmota/discovery.py @@ -290,7 +290,7 @@ async def async_start( # noqa: C901 for platform in PLATFORMS: tasmota_entities = tasmota_get_entities_for_platform(payload, platform) - for (tasmota_entity_config, discovery_hash) in tasmota_entities: + for tasmota_entity_config, discovery_hash in tasmota_entities: _discover_entity(tasmota_entity_config, discovery_hash, platform) async def async_sensors_discovered( @@ -316,7 +316,7 @@ async def async_start( # noqa: C901 ) if entry.domain == sensor.DOMAIN and entry.platform == DOMAIN } - for (tasmota_sensor_config, discovery_hash) in sensors: + for tasmota_sensor_config, discovery_hash in sensors: if tasmota_sensor_config: orphaned_entities.discard(tasmota_sensor_config.unique_id) _discover_entity(tasmota_sensor_config, discovery_hash, platform) diff --git a/homeassistant/components/tellduslive/config_flow.py b/homeassistant/components/tellduslive/config_flow.py index 18ae324a572..18bbe59a25f 100644 --- a/homeassistant/components/tellduslive/config_flow.py +++ b/homeassistant/components/tellduslive/config_flow.py @@ -42,7 +42,6 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): self._scan_interval = SCAN_INTERVAL def _get_auth_url(self): - self._session = Session( public_key=PUBLIC_KEY, private_key=NOT_SO_PRIVATE_KEY, diff --git a/homeassistant/components/template/cover.py b/homeassistant/components/template/cover.py index 4c234e21875..e36ca75ed01 100644 --- a/homeassistant/components/template/cover.py +++ b/homeassistant/components/template/cover.py @@ -105,7 +105,6 @@ async def _async_create_entities(hass, config): covers = [] for object_id, entity_config in config[CONF_COVERS].items(): - entity_config = rewrite_common_legacy_to_modern_conf(entity_config) unique_id = entity_config.get(CONF_UNIQUE_ID) diff --git a/homeassistant/components/template/fan.py b/homeassistant/components/template/fan.py index 3d3c17551ca..88309810ad2 100644 --- a/homeassistant/components/template/fan.py +++ b/homeassistant/components/template/fan.py @@ -93,7 +93,6 @@ async def _async_create_entities(hass, config): fans = [] for object_id, entity_config in config[CONF_FANS].items(): - entity_config = rewrite_common_legacy_to_modern_conf(entity_config) unique_id = entity_config.get(CONF_UNIQUE_ID) diff --git a/homeassistant/components/template/switch.py b/homeassistant/components/template/switch.py index 9f282cb9b11..b21e02e4074 100644 --- a/homeassistant/components/template/switch.py +++ b/homeassistant/components/template/switch.py @@ -134,7 +134,6 @@ class SwitchTemplate(TemplateEntity, SwitchEntity, RestoreEntity): async def async_added_to_hass(self) -> None: """Register callbacks.""" if self._template is None: - # restore state after startup await super().async_added_to_hass() if state := await self.async_get_last_state(): diff --git a/homeassistant/components/tomato/device_tracker.py b/homeassistant/components/tomato/device_tracker.py index c99a44120e5..e10bc3b81d6 100644 --- a/homeassistant/components/tomato/device_tracker.py +++ b/homeassistant/components/tomato/device_tracker.py @@ -108,9 +108,7 @@ class TomatoDeviceScanner(DeviceScanner): # Calling and parsing the Tomato api here. We only need the # wldev and dhcpd_lease values. if response.status_code == HTTPStatus.OK: - for param, value in self.parse_api_pattern.findall(response.text): - if param in ("wldev", "dhcpd_lease"): self.last_results[param] = json.loads(value.replace("'", '"')) return True diff --git a/homeassistant/components/toon/coordinator.py b/homeassistant/components/toon/coordinator.py index 5819ff12743..58165935215 100644 --- a/homeassistant/components/toon/coordinator.py +++ b/homeassistant/components/toon/coordinator.py @@ -54,7 +54,6 @@ class ToonDataUpdateCoordinator(DataUpdateCoordinator[Status]): self.hass.config_entries.async_update_entry(self.entry, data=data) if cloud.async_active_subscription(self.hass): - if CONF_CLOUDHOOK_URL not in self.entry.data: try: webhook_url = await cloud.async_create_cloudhook( diff --git a/homeassistant/components/traccar/device_tracker.py b/homeassistant/components/traccar/device_tracker.py index 601229ed2e0..bbc089de0c9 100644 --- a/homeassistant/components/traccar/device_tracker.py +++ b/homeassistant/components/traccar/device_tracker.py @@ -251,7 +251,11 @@ class TraccarScanner: """Update info from Traccar.""" _LOGGER.debug("Updating device data") try: - (self._devices, self._positions, self._geofences,) = await asyncio.gather( + ( + self._devices, + self._positions, + self._geofences, + ) = await asyncio.gather( self._api.get_devices(), self._api.get_positions(), self._api.get_geofences(), diff --git a/homeassistant/components/trafikverket_train/sensor.py b/homeassistant/components/trafikverket_train/sensor.py index 8ecf0a99c31..678a0af2294 100644 --- a/homeassistant/components/trafikverket_train/sensor.py +++ b/homeassistant/components/trafikverket_train/sensor.py @@ -138,7 +138,6 @@ class TrainSensor(SensorEntity): self._from_station, self._to_station, when ) else: - _state = await self._train_api.async_get_next_train_stop( self._from_station, self._to_station, when ) diff --git a/homeassistant/components/transmission/config_flow.py b/homeassistant/components/transmission/config_flow.py index a21fe9b8837..b7784fbe4a9 100644 --- a/homeassistant/components/transmission/config_flow.py +++ b/homeassistant/components/transmission/config_flow.py @@ -62,7 +62,6 @@ class TransmissionFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): errors = {} if user_input is not None: - for entry in self._async_current_entries(): if ( entry.data[CONF_HOST] == user_input[CONF_HOST] diff --git a/homeassistant/components/tuya/number.py b/homeassistant/components/tuya/number.py index 8a65c06b70e..f7b051f52c2 100644 --- a/homeassistant/components/tuya/number.py +++ b/homeassistant/components/tuya/number.py @@ -372,7 +372,6 @@ class TuyaNumberEntity(TuyaEntity, NumberEntity): and not self.device_class.startswith(DOMAIN) and description.native_unit_of_measurement is None ): - # We cannot have a device class, if the UOM isn't set or the # device class cannot be found in the validation mapping. if ( diff --git a/homeassistant/components/twinkly/light.py b/homeassistant/components/twinkly/light.py index 0145439493b..1a04f6c712e 100644 --- a/homeassistant/components/twinkly/light.py +++ b/homeassistant/components/twinkly/light.py @@ -196,7 +196,6 @@ class TwinklyLight(LightEntity): ATTR_RGBW_COLOR in kwargs and kwargs[ATTR_RGBW_COLOR] != self._attr_rgbw_color ): - await self._client.interview() if LightEntityFeature.EFFECT & self.supported_features: # Static color only supports rgb @@ -223,7 +222,6 @@ class TwinklyLight(LightEntity): self._attr_rgbw_color = kwargs[ATTR_RGBW_COLOR] if ATTR_RGB_COLOR in kwargs and kwargs[ATTR_RGB_COLOR] != self._attr_rgb_color: - await self._client.interview() if LightEntityFeature.EFFECT & self.supported_features: await self._client.set_static_colour(kwargs[ATTR_RGB_COLOR]) diff --git a/homeassistant/components/uk_transport/sensor.py b/homeassistant/components/uk_transport/sensor.py index cd1983f9479..d98f9d5011c 100644 --- a/homeassistant/components/uk_transport/sensor.py +++ b/homeassistant/components/uk_transport/sensor.py @@ -173,7 +173,7 @@ class UkTransportLiveBusTimeSensor(UkTransportSensor): if self._data != {}: self._next_buses = [] - for (route, departures) in self._data["departures"].items(): + for route, departures in self._data["departures"].items(): for departure in departures: if self._destination_re.search(departure["direction"]): self._next_buses.append( diff --git a/homeassistant/components/unifi/config_flow.py b/homeassistant/components/unifi/config_flow.py index 64ea7b39778..d4e885b295e 100644 --- a/homeassistant/components/unifi/config_flow.py +++ b/homeassistant/components/unifi/config_flow.py @@ -86,7 +86,6 @@ class UnifiFlowHandler(config_entries.ConfigFlow, domain=UNIFI_DOMAIN): errors = {} if user_input is not None: - self.config = { CONF_HOST: user_input[CONF_HOST], CONF_USERNAME: user_input[CONF_USERNAME], @@ -148,7 +147,6 @@ class UnifiFlowHandler(config_entries.ConfigFlow, domain=UNIFI_DOMAIN): ) -> FlowResult: """Select site to control.""" if user_input is not None: - unique_id = user_input[CONF_SITE_ID] self.config[CONF_SITE_ID] = self.site_ids[unique_id] diff --git a/homeassistant/components/unifi/controller.py b/homeassistant/components/unifi/controller.py index d26780ab019..2721e254de8 100644 --- a/homeassistant/components/unifi/controller.py +++ b/homeassistant/components/unifi/controller.py @@ -228,7 +228,6 @@ class UniFiController: def async_unifi_signalling_callback(self, signal, data): """Handle messages back from UniFi library.""" if signal == WebsocketSignal.CONNECTION_STATE: - if data == WebsocketState.DISCONNECTED and self.available: LOGGER.warning("Lost connection to UniFi Network") @@ -244,14 +243,12 @@ class UniFiController: LOGGER.info("Connected to UniFi Network") elif signal == WebsocketSignal.DATA and data: - if DATA_EVENT in data: clients_connected = set() devices_connected = set() wireless_clients_connected = False for event in data[DATA_EVENT]: - if event.key in CLIENT_CONNECTED: clients_connected.add(event.mac) diff --git a/homeassistant/components/unifi/device_tracker.py b/homeassistant/components/unifi/device_tracker.py index a7678445c8c..c845b6d5d38 100644 --- a/homeassistant/components/unifi/device_tracker.py +++ b/homeassistant/components/unifi/device_tracker.py @@ -272,7 +272,6 @@ class UniFiClientTracker(UniFiClientBase, ScannerEntity): self.client.last_updated == SOURCE_EVENT and not self._only_listen_to_data_source ): - if (self.is_wired and self.client.event.key in WIRED_CONNECTION) or ( not self.is_wired and self.client.event.key in WIRELESS_CONNECTION ): diff --git a/homeassistant/components/unifi/services.py b/homeassistant/components/unifi/services.py index ee7bbbe8581..06de01d822a 100644 --- a/homeassistant/components/unifi/services.py +++ b/homeassistant/components/unifi/services.py @@ -91,14 +91,12 @@ async def async_remove_clients(hass: HomeAssistant, data: Mapping[str, Any]) -> - Neither IP, hostname nor name is configured. """ for controller in hass.data[UNIFI_DOMAIN].values(): - if not controller.available: continue clients_to_remove = [] for client in controller.api.clients_all.values(): - if ( client.last_seen and client.first_seen diff --git a/homeassistant/components/unifi_direct/device_tracker.py b/homeassistant/components/unifi_direct/device_tracker.py index d0ac37f312c..42f83dad5d5 100644 --- a/homeassistant/components/unifi_direct/device_tracker.py +++ b/homeassistant/components/unifi_direct/device_tracker.py @@ -102,7 +102,6 @@ class UnifiDeviceScanner(DeviceScanner): self.connected = False def _get_update(self): - try: if not self.connected: self._connect() diff --git a/homeassistant/components/unifiprotect/button.py b/homeassistant/components/unifiprotect/button.py index 29007571927..8c620402e77 100644 --- a/homeassistant/components/unifiprotect/button.py +++ b/homeassistant/components/unifiprotect/button.py @@ -98,7 +98,6 @@ CHIME_BUTTONS: tuple[ProtectButtonEntityDescription, ...] = ( def _async_remove_adopt_button( hass: HomeAssistant, device: ProtectAdoptableDeviceModel ) -> None: - entity_registry = er.async_get(hass) if entity_id := entity_registry.async_get_entity_id( Platform.BUTTON, DOMAIN, f"{device.mac}_adopt" diff --git a/homeassistant/components/unifiprotect/sensor.py b/homeassistant/components/unifiprotect/sensor.py index 4be8b489de9..1af4d82ff98 100644 --- a/homeassistant/components/unifiprotect/sensor.py +++ b/homeassistant/components/unifiprotect/sensor.py @@ -104,7 +104,6 @@ def _get_nvr_memory(obj: NVR) -> float | None: def _get_alarm_sound(obj: Sensor) -> str: - alarm_type = OBJECT_TYPE_NONE if ( obj.is_alarm_detected diff --git a/homeassistant/components/w800rf32/binary_sensor.py b/homeassistant/components/w800rf32/binary_sensor.py index ef8e02803f6..04007469992 100644 --- a/homeassistant/components/w800rf32/binary_sensor.py +++ b/homeassistant/components/w800rf32/binary_sensor.py @@ -54,7 +54,6 @@ async def async_setup_platform( # device_id --> "c1 or a3" X10 device. entity (type dictionary) # --> name, device_class etc for device_id, entity in config[CONF_DEVICES].items(): - _LOGGER.debug( "Add %s w800rf32.binary_sensor (class %s)", entity[CONF_NAME], @@ -128,7 +127,6 @@ class W800rf32BinarySensor(BinarySensorEntity): self.update_state(is_on) if self.is_on and self._off_delay is not None and self._delay_listener is None: - self._delay_listener = evt.async_track_point_in_time( self.hass, self._off_delay_listener, dt_util.utcnow() + self._off_delay ) diff --git a/homeassistant/components/whirlpool/sensor.py b/homeassistant/components/whirlpool/sensor.py index 972760f5af6..b026dd0ce32 100644 --- a/homeassistant/components/whirlpool/sensor.py +++ b/homeassistant/components/whirlpool/sensor.py @@ -295,6 +295,5 @@ class WasherDryerTimeClass(RestoreSensor): if isinstance(self._attr_native_value, datetime) and abs( new_timestamp - self._attr_native_value ) > timedelta(seconds=60): - self._attr_native_value = new_timestamp self._async_write_ha_state() diff --git a/homeassistant/components/ws66i/__init__.py b/homeassistant/components/ws66i/__init__.py index cffedc2f684..64f049aa9ac 100644 --- a/homeassistant/components/ws66i/__init__.py +++ b/homeassistant/components/ws66i/__init__.py @@ -41,7 +41,6 @@ def _find_zones(hass: HomeAssistant, ws66i: WS66i) -> list[int]: # Zones 21,31 - 26,36 are the daisy-chained amps zone_list = [] for amp_num in range(1, 4): - if amp_num > 1: # Don't add entities that aren't present status = ws66i.zone_status(amp_num * 10 + 1) diff --git a/homeassistant/components/zamg/coordinator.py b/homeassistant/components/zamg/coordinator.py index 4b25f4f7fbc..f785524e866 100644 --- a/homeassistant/components/zamg/coordinator.py +++ b/homeassistant/components/zamg/coordinator.py @@ -44,7 +44,7 @@ class ZamgDataUpdateCoordinator(DataUpdateCoordinator[ZamgDevice]): device = await self.zamg.update() except ZamgNoDataError as error: raise UpdateFailed("No response from API") from error - except (ZamgError) as error: + except ZamgError as error: raise UpdateFailed(f"Invalid response from API: {error}") from error self.data = device self.data["last_update"] = self.zamg.last_update diff --git a/homeassistant/components/zamg/sensor.py b/homeassistant/components/zamg/sensor.py index 348052bc5f4..21e0dd8de1e 100644 --- a/homeassistant/components/zamg/sensor.py +++ b/homeassistant/components/zamg/sensor.py @@ -214,7 +214,7 @@ class ZamgSensor(CoordinatorEntity, SensorEntity): return self.coordinator.data[self.station_id][ self.entity_description.para_name ]["data"] - except (KeyError): + except KeyError: return None @property diff --git a/homeassistant/components/zha/core/device.py b/homeassistant/components/zha/core/device.py index c0959cb40c0..dd8b3b9c2a7 100644 --- a/homeassistant/components/zha/core/device.py +++ b/homeassistant/components/zha/core/device.py @@ -725,10 +725,8 @@ class ZHADevice(LogMixin): response = await getattr(cluster, commands[command].name)(*args) else: assert params is not None - response = await ( - getattr(cluster, commands[command].name)( - **convert_to_zcl_values(params, commands[command].schema) - ) + response = await getattr(cluster, commands[command].name)( + **convert_to_zcl_values(params, commands[command].schema) ) self.debug( "Issued cluster command: %s %s %s %s %s %s %s %s", diff --git a/homeassistant/components/zha/core/helpers.py b/homeassistant/components/zha/core/helpers.py index e2d8ff8baee..34b484cc21d 100644 --- a/homeassistant/components/zha/core/helpers.py +++ b/homeassistant/components/zha/core/helpers.py @@ -338,7 +338,6 @@ def retryable_req( def decorator(func): @functools.wraps(func) async def wrapper(channel, *args, **kwargs): - exceptions = (zigpy.exceptions.ZigbeeException, asyncio.TimeoutError) try_count, errors = 1, [] for delay in itertools.chain(delays, [None]): diff --git a/homeassistant/helpers/entity_platform.py b/homeassistant/helpers/entity_platform.py index 18dd9aea344..f003d755033 100644 --- a/homeassistant/helpers/entity_platform.py +++ b/homeassistant/helpers/entity_platform.py @@ -210,9 +210,9 @@ class EntityPlatform: return @callback - def async_create_setup_task() -> Coroutine[ - Any, Any, None - ] | asyncio.Future[None]: + def async_create_setup_task() -> ( + Coroutine[Any, Any, None] | asyncio.Future[None] + ): """Get task to set up platform.""" if getattr(platform, "async_setup_platform", None): return platform.async_setup_platform( # type: ignore[union-attr] diff --git a/homeassistant/helpers/network.py b/homeassistant/helpers/network.py index a6060226d7b..12accf2725a 100644 --- a/homeassistant/helpers/network.py +++ b/homeassistant/helpers/network.py @@ -140,7 +140,6 @@ def get_url( # Try finding an URL in the order specified for url_type in order: - if allow_internal and url_type == TYPE_URL_INTERNAL: with suppress(NoURLAvailableError): return _get_internal_url( diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index ef8bee1fc7e..3c3da10db7c 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -613,7 +613,6 @@ async def entity_service_call( # noqa: C901 for platform in platforms: platform_entities = [] for entity in platform.entities.values(): - if entity.entity_id not in all_referenced: continue diff --git a/requirements_test_pre_commit.txt b/requirements_test_pre_commit.txt index 9396a6173bb..358cff0bf36 100644 --- a/requirements_test_pre_commit.txt +++ b/requirements_test_pre_commit.txt @@ -2,7 +2,7 @@ autoflake==2.0.0 bandit==1.7.4 -black==22.12.0 +black==23.1.0 codespell==2.2.2 flake8-comprehensions==3.10.1 flake8-docstrings==1.6.0 diff --git a/script/translations/migrate.py b/script/translations/migrate.py index d3efdc28d13..f5bd60c30b4 100644 --- a/script/translations/migrate.py +++ b/script/translations/migrate.py @@ -263,7 +263,6 @@ def find_frontend_states(): from_key_base = f"state::{domain}" if domain in STATES_WITH_DEV_CLASS: - domain_to_write = dict(states) for device_class, dev_class_states in domain_to_write.items(): @@ -338,7 +337,6 @@ def apply_data_references(to_migrate): for step_data in steps.values(): step_data = step_data.get("data", {}) for key, value in step_data.items(): - if key in to_migrate and value != to_migrate[key]: if key.split("_")[0].lower() in value.lower(): step_data[key] = to_migrate[key] diff --git a/tests/components/abode/test_config_flow.py b/tests/components/abode/test_config_flow.py index c16fea4ef20..5982a02c59d 100644 --- a/tests/components/abode/test_config_flow.py +++ b/tests/components/abode/test_config_flow.py @@ -99,7 +99,6 @@ async def test_step_user(hass: HomeAssistant) -> None: conf = {CONF_USERNAME: "user@email.com", CONF_PASSWORD: "password"} with patch("homeassistant.components.abode.config_flow.Abode"): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=conf ) diff --git a/tests/components/accuweather/test_config_flow.py b/tests/components/accuweather/test_config_flow.py index 4abde4d7620..b0b0def1d9a 100644 --- a/tests/components/accuweather/test_config_flow.py +++ b/tests/components/accuweather/test_config_flow.py @@ -53,7 +53,6 @@ async def test_invalid_api_key(hass): "homeassistant.components.accuweather.AccuWeather._async_get_data", side_effect=InvalidApiKeyError("Invalid API key"), ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, @@ -69,7 +68,6 @@ async def test_api_error(hass): "homeassistant.components.accuweather.AccuWeather._async_get_data", side_effect=ApiError("Invalid response from AccuWeather API"), ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, @@ -87,7 +85,6 @@ async def test_requests_exceeded_error(hass): "The allowed number of requests has been exceeded" ), ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, @@ -127,7 +124,6 @@ async def test_create_entry(hass): ), patch( "homeassistant.components.accuweather.async_setup_entry", return_value=True ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, diff --git a/tests/components/accuweather/test_init.py b/tests/components/accuweather/test_init.py index ee91fa4d219..6210aba2cec 100644 --- a/tests/components/accuweather/test_init.py +++ b/tests/components/accuweather/test_init.py @@ -75,7 +75,6 @@ async def test_update_interval(hass): "homeassistant.components.accuweather.AccuWeather.async_get_current_conditions", return_value=current, ) as mock_current: - assert mock_current.call_count == 0 async_fire_time_changed(hass, future) @@ -101,7 +100,6 @@ async def test_update_interval_forecast(hass): "homeassistant.components.accuweather.AccuWeather.async_get_forecast", return_value=forecast, ) as mock_forecast: - assert mock_current.call_count == 0 assert mock_forecast.call_count == 0 diff --git a/tests/components/adax/test_config_flow.py b/tests/components/adax/test_config_flow.py index 0c12c486754..ce6bf3ac9ae 100644 --- a/tests/components/adax/test_config_flow.py +++ b/tests/components/adax/test_config_flow.py @@ -41,7 +41,10 @@ async def test_form(hass: HomeAssistant) -> None: ) assert result2["type"] == FlowResultType.FORM - with patch("adax.get_adax_token", return_value="test_token",), patch( + with patch( + "adax.get_adax_token", + return_value="test_token", + ), patch( "homeassistant.components.adax.async_setup_entry", return_value=True, ) as mock_setup_entry: diff --git a/tests/components/airthings/test_config_flow.py b/tests/components/airthings/test_config_flow.py index 6e3a1579f70..3a0c852535e 100644 --- a/tests/components/airthings/test_config_flow.py +++ b/tests/components/airthings/test_config_flow.py @@ -25,7 +25,10 @@ async def test_form(hass: HomeAssistant) -> None: assert result["type"] == FlowResultType.FORM assert result["errors"] is None - with patch("airthings.get_token", return_value="test_token",), patch( + with patch( + "airthings.get_token", + return_value="test_token", + ), patch( "homeassistant.components.airthings.async_setup_entry", return_value=True, ) as mock_setup_entry: diff --git a/tests/components/aladdin_connect/test_cover.py b/tests/components/aladdin_connect/test_cover.py index 2192017c26f..f78bf36775f 100644 --- a/tests/components/aladdin_connect/test_cover.py +++ b/tests/components/aladdin_connect/test_cover.py @@ -129,7 +129,6 @@ async def test_cover_operation( "homeassistant.components.aladdin_connect.AladdinConnectClient", return_value=mock_aladdinconnect_api, ): - await hass.services.async_call( COVER_DOMAIN, SERVICE_CLOSE_COVER, @@ -183,7 +182,6 @@ async def test_cover_operation( "homeassistant.components.aladdin_connect.AladdinConnectClient", return_value=mock_aladdinconnect_api, ): - await hass.services.async_call( COVER_DOMAIN, SERVICE_CLOSE_COVER, diff --git a/tests/components/aladdin_connect/test_init.py b/tests/components/aladdin_connect/test_init.py index 9084754d569..4d5e2678725 100644 --- a/tests/components/aladdin_connect/test_init.py +++ b/tests/components/aladdin_connect/test_init.py @@ -49,7 +49,6 @@ async def test_setup_login_error( "homeassistant.components.aladdin_connect.cover.AladdinConnectClient", return_value=mock_aladdinconnect_api, ): - assert await hass.config_entries.async_setup(config_entry.entry_id) is False @@ -68,7 +67,6 @@ async def test_setup_connection_error( "homeassistant.components.aladdin_connect.AladdinConnectClient", return_value=mock_aladdinconnect_api, ): - assert await hass.config_entries.async_setup(config_entry.entry_id) is False @@ -84,7 +82,6 @@ async def test_setup_component_no_error(hass: HomeAssistant) -> None: "homeassistant.components.aladdin_connect.cover.AladdinConnectClient.login", return_value=True, ): - assert await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() @@ -107,7 +104,6 @@ async def test_entry_password_fail( "homeassistant.components.aladdin_connect.AladdinConnectClient", return_value=mock_aladdinconnect_api, ): - await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() assert entry.state is ConfigEntryState.SETUP_ERROR @@ -128,7 +124,6 @@ async def test_load_and_unload( "homeassistant.components.aladdin_connect.AladdinConnectClient", return_value=mock_aladdinconnect_api, ): - await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() diff --git a/tests/components/alexa/test_smart_home.py b/tests/components/alexa/test_smart_home.py index 7695d25dba6..0bb134ac954 100644 --- a/tests/components/alexa/test_smart_home.py +++ b/tests/components/alexa/test_smart_home.py @@ -1508,7 +1508,10 @@ async def test_media_player_speaker(hass): ) assert call.data["is_volume_muted"] - call, _, = await assert_request_calls_service( + ( + call, + _, + ) = await assert_request_calls_service( "Alexa.Speaker", "SetMute", "media_player#test_speaker", @@ -1558,7 +1561,10 @@ async def test_media_player_step_speaker(hass): ) assert call.data["is_volume_muted"] - call, _, = await assert_request_calls_service( + ( + call, + _, + ) = await assert_request_calls_service( "Alexa.StepSpeaker", "SetMute", "media_player#test_step_speaker", diff --git a/tests/components/analytics/test_analytics.py b/tests/components/analytics/test_analytics.py index bd16ce96ffe..f4f09fc160f 100644 --- a/tests/components/analytics/test_analytics.py +++ b/tests/components/analytics/test_analytics.py @@ -400,7 +400,6 @@ async def test_dev_url_error(hass, aioclient_mock, caplog): with patch( "homeassistant.components.analytics.analytics.HA_VERSION", MOCK_VERSION_DEV ): - await analytics.send_analytics() payload = aioclient_mock.mock_calls[0] @@ -420,7 +419,6 @@ async def test_nightly_endpoint(hass, aioclient_mock): with patch( "homeassistant.components.analytics.analytics.HA_VERSION", MOCK_VERSION_NIGHTLY ): - await analytics.send_analytics() payload = aioclient_mock.mock_calls[0] diff --git a/tests/components/androidtv/test_config_flow.py b/tests/components/androidtv/test_config_flow.py index 03101733019..856762a3d3e 100644 --- a/tests/components/androidtv/test_config_flow.py +++ b/tests/components/androidtv/test_config_flow.py @@ -125,7 +125,6 @@ async def test_user_adbkey(hass): CONNECT_METHOD, return_value=(MockConfigDevice(), None), ), PATCH_ISFILE, PATCH_ACCESS, PATCH_SETUP_ENTRY as mock_setup_entry: - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER, "show_advanced_options": True}, diff --git a/tests/components/aurora_abb_powerone/test_config_flow.py b/tests/components/aurora_abb_powerone/test_config_flow.py index 73b4b67bc04..88d024356d8 100644 --- a/tests/components/aurora_abb_powerone/test_config_flow.py +++ b/tests/components/aurora_abb_powerone/test_config_flow.py @@ -33,7 +33,10 @@ async def test_form(hass): assert result["type"] == "form" assert result["errors"] == {} - with patch("aurorapy.client.AuroraSerialClient.connect", return_value=None,), patch( + with patch( + "aurorapy.client.AuroraSerialClient.connect", + return_value=None, + ), patch( "aurorapy.client.AuroraSerialClient.serial_number", return_value="9876543", ), patch( @@ -52,7 +55,6 @@ async def test_form(hass): "homeassistant.components.aurora_abb_powerone.async_setup_entry", return_value=True, ) as mock_setup_entry: - result2 = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_PORT: "/dev/ttyUSB7", CONF_ADDRESS: 7}, @@ -140,7 +142,10 @@ async def test_form_invalid_com_ports(hass): "aurorapy.client.AuroraSerialClient.connect", side_effect=AuroraError("...Some other message!!!123..."), return_value=None, - ), patch("serial.Serial.isOpen", return_value=True,), patch( + ), patch( + "serial.Serial.isOpen", + return_value=True, + ), patch( "aurorapy.client.AuroraSerialClient.close", ) as mock_clientclose: result2 = await hass.config_entries.flow.async_configure( diff --git a/tests/components/aussie_broadband/test_config_flow.py b/tests/components/aussie_broadband/test_config_flow.py index ed98924e19d..9b4be6d9463 100644 --- a/tests/components/aussie_broadband/test_config_flow.py +++ b/tests/components/aussie_broadband/test_config_flow.py @@ -187,7 +187,6 @@ async def test_reauth(hass: HomeAssistant) -> None: with patch("aussiebb.asyncio.AussieBB.__init__", return_value=None), patch( "aussiebb.asyncio.AussieBB.login", side_effect=AuthenticationException() ), patch("aussiebb.asyncio.AussieBB.get_services", return_value=[FAKE_SERVICES[0]]): - result6 = await hass.config_entries.flow.async_configure( result5["flow_id"], { @@ -202,7 +201,6 @@ async def test_reauth(hass: HomeAssistant) -> None: with patch("aussiebb.asyncio.AussieBB.__init__", return_value=None), patch( "aussiebb.asyncio.AussieBB.login", return_value=True ), patch("aussiebb.asyncio.AussieBB.get_services", return_value=[FAKE_SERVICES[0]]): - result7 = await hass.config_entries.flow.async_configure( result6["flow_id"], { diff --git a/tests/components/aws/test_init.py b/tests/components/aws/test_init.py index 3b1dcaea1e5..7875f366fcc 100644 --- a/tests/components/aws/test_init.py +++ b/tests/components/aws/test_init.py @@ -85,7 +85,6 @@ async def test_profile_credential(hass): with async_patch( "homeassistant.components.aws.AioSession", return_value=mock_session ): - await async_setup_component( hass, "aws", diff --git a/tests/components/axis/conftest.py b/tests/components/axis/conftest.py index ccaa983c5fd..6be1793cc24 100644 --- a/tests/components/axis/conftest.py +++ b/tests/components/axis/conftest.py @@ -205,7 +205,6 @@ async def setup_config_entry_fixture(hass, config_entry, setup_default_vapix_req def mock_axis_rtspclient(): """No real RTSP communication allowed.""" with patch("axis.stream_manager.RTSPClient") as rtsp_client_mock: - rtsp_client_mock.return_value.session.state = State.STOPPED async def start_stream(): diff --git a/tests/components/backup/test_http.py b/tests/components/backup/test_http.py index 708abec057b..f3c459e2efd 100644 --- a/tests/components/backup/test_http.py +++ b/tests/components/backup/test_http.py @@ -27,7 +27,6 @@ async def test_downloading_backup( "homeassistant.components.backup.http.FileResponse", return_value=web.Response(text=""), ): - resp = await client.get("/api/backup/download/abc123") assert resp.status == 200 diff --git a/tests/components/backup/test_websocket.py b/tests/components/backup/test_websocket.py index 4179eb026c5..2e8ac8f2f56 100644 --- a/tests/components/backup/test_websocket.py +++ b/tests/components/backup/test_websocket.py @@ -24,7 +24,6 @@ async def test_info( "homeassistant.components.backup.websocket.BackupManager.get_backups", return_value={TEST_BACKUP.slug: TEST_BACKUP}, ): - await client.send_json({"id": 1, "type": "backup/info"}) msg = await client.receive_json() diff --git a/tests/components/blink/test_config_flow.py b/tests/components/blink/test_config_flow.py index 9d5d92f8dd2..22834f48314 100644 --- a/tests/components/blink/test_config_flow.py +++ b/tests/components/blink/test_config_flow.py @@ -149,7 +149,9 @@ async def test_form_2fa_invalid_key(hass): assert result2["type"] == "form" assert result2["step_id"] == "2fa" - with patch("homeassistant.components.blink.config_flow.Auth.startup",), patch( + with patch( + "homeassistant.components.blink.config_flow.Auth.startup", + ), patch( "homeassistant.components.blink.config_flow.Auth.check_key_required", return_value=False, ), patch( diff --git a/tests/components/bluetooth/test_base_scanner.py b/tests/components/bluetooth/test_base_scanner.py index 5c6bbccd443..b0fc9cfa40e 100644 --- a/tests/components/bluetooth/test_base_scanner.py +++ b/tests/components/bluetooth/test_base_scanner.py @@ -361,7 +361,10 @@ async def test_restore_history_remote_adapter( if address != "E3:A5:63:3E:5E:23": timestamps[address] = now - with patch("bluetooth_adapters.systems.linux.LinuxAdapters.history", {},), patch( + with patch( + "bluetooth_adapters.systems.linux.LinuxAdapters.history", + {}, + ), patch( "bluetooth_adapters.systems.linux.LinuxAdapters.refresh", ): assert await async_setup_component(hass, bluetooth.DOMAIN, {}) diff --git a/tests/components/bluetooth/test_diagnostics.py b/tests/components/bluetooth/test_diagnostics.py index f4c9beafd4a..17807bf8d3a 100644 --- a/tests/components/bluetooth/test_diagnostics.py +++ b/tests/components/bluetooth/test_diagnostics.py @@ -450,7 +450,6 @@ async def test_diagnostics_remote_adapter( "homeassistant.components.bluetooth.diagnostics.get_dbus_managed_objects", return_value={}, ): - entry1 = MockConfigEntry( domain=bluetooth.DOMAIN, data={}, unique_id="00:00:00:00:00:01" ) diff --git a/tests/components/bluetooth/test_wrappers.py b/tests/components/bluetooth/test_wrappers.py index b2be6bf7280..1237fd89407 100644 --- a/tests/components/bluetooth/test_wrappers.py +++ b/tests/components/bluetooth/test_wrappers.py @@ -180,10 +180,10 @@ def _generate_scanners_with_fake_devices(hass): hass, "00:00:00:00:00:02", "hci1", new_info_callback, None, True ) - for (device, adv_data) in hci0_device_advs.values(): + for device, adv_data in hci0_device_advs.values(): scanner_hci0.inject_advertisement(device, adv_data) - for (device, adv_data) in hci1_device_advs.values(): + for device, adv_data in hci1_device_advs.values(): scanner_hci1.inject_advertisement(device, adv_data) cancel_hci0 = manager.async_register_scanner(scanner_hci0, True, 2) diff --git a/tests/components/bluetooth_le_tracker/test_device_tracker.py b/tests/components/bluetooth_le_tracker/test_device_tracker.py index 04f8c534cf2..4bacd9a4479 100644 --- a/tests/components/bluetooth_le_tracker/test_device_tracker.py +++ b/tests/components/bluetooth_le_tracker/test_device_tracker.py @@ -78,7 +78,6 @@ async def test_preserve_new_tracked_device_name( ) as mock_async_discovered_service_info, patch.object( device_tracker, "MIN_SEEN_NEW", 3 ): - device = BluetoothServiceInfoBleak( name=name, address=address, @@ -147,7 +146,6 @@ async def test_tracking_battery_times_out( ) as mock_async_discovered_service_info, patch.object( device_tracker, "MIN_SEEN_NEW", 3 ): - device = BluetoothServiceInfoBleak( name=name, address=address, @@ -213,7 +211,6 @@ async def test_tracking_battery_fails(hass, mock_bluetooth, mock_device_tracker_ ) as mock_async_discovered_service_info, patch.object( device_tracker, "MIN_SEEN_NEW", 3 ): - device = BluetoothServiceInfoBleak( name=name, address=address, @@ -281,7 +278,6 @@ async def test_tracking_battery_successful( ) as mock_async_discovered_service_info, patch.object( device_tracker, "MIN_SEEN_NEW", 3 ): - device = BluetoothServiceInfoBleak( name=name, address=address, diff --git a/tests/components/brother/test_config_flow.py b/tests/components/brother/test_config_flow.py index 5a145edf030..832e874a466 100644 --- a/tests/components/brother/test_config_flow.py +++ b/tests/components/brother/test_config_flow.py @@ -118,7 +118,6 @@ async def test_unsupported_model_error(hass: HomeAssistant) -> None: with patch("brother.Brother.initialize"), patch( "brother.Brother._get_data", side_effect=UnsupportedModel("error") ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=CONFIG ) @@ -149,7 +148,6 @@ async def test_zeroconf_snmp_error(hass: HomeAssistant) -> None: with patch("brother.Brother.initialize"), patch( "brother.Brother._get_data", side_effect=SnmpError("error") ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_ZEROCONF}, @@ -259,7 +257,6 @@ async def test_zeroconf_confirm_create_entry(hass: HomeAssistant) -> None: "brother.Brother._get_data", return_value=json.loads(load_fixture("printer_data.json", "brother")), ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_ZEROCONF}, diff --git a/tests/components/canary/test_sensor.py b/tests/components/canary/test_sensor.py index 0a895dbe297..7de66613255 100644 --- a/tests/components/canary/test_sensor.py +++ b/tests/components/canary/test_sensor.py @@ -73,7 +73,7 @@ async def test_sensors_pro(hass, canary) -> None: ), } - for (sensor_id, data) in sensors.items(): + for sensor_id, data in sensors.items(): entity_entry = registry.async_get(f"sensor.{sensor_id}") assert entity_entry assert entity_entry.original_device_class == data[3] @@ -192,7 +192,7 @@ async def test_sensors_flex(hass, canary) -> None: ), } - for (sensor_id, data) in sensors.items(): + for sensor_id, data in sensors.items(): entity_entry = registry.async_get(f"sensor.{sensor_id}") assert entity_entry assert entity_entry.original_device_class == data[3] diff --git a/tests/components/cloudflare/test_init.py b/tests/components/cloudflare/test_init.py index c476b3ef376..773d65f27d8 100644 --- a/tests/components/cloudflare/test_init.py +++ b/tests/components/cloudflare/test_init.py @@ -99,7 +99,6 @@ async def test_integration_services(hass, cfupdate): True, ), ): - await hass.services.async_call( DOMAIN, SERVICE_UPDATE_RECORDS, diff --git a/tests/components/co2signal/test_config_flow.py b/tests/components/co2signal/test_config_flow.py index d85279fc30c..08d87d5e987 100644 --- a/tests/components/co2signal/test_config_flow.py +++ b/tests/components/co2signal/test_config_flow.py @@ -20,7 +20,10 @@ async def test_form_home(hass: HomeAssistant) -> None: assert result["type"] == FlowResultType.FORM assert result["errors"] is None - with patch("CO2Signal.get_latest", return_value=VALID_PAYLOAD,), patch( + with patch( + "CO2Signal.get_latest", + return_value=VALID_PAYLOAD, + ), patch( "homeassistant.components.co2signal.async_setup_entry", return_value=True, ) as mock_setup_entry: @@ -59,7 +62,10 @@ async def test_form_coordinates(hass: HomeAssistant) -> None: ) assert result2["type"] == FlowResultType.FORM - with patch("CO2Signal.get_latest", return_value=VALID_PAYLOAD,), patch( + with patch( + "CO2Signal.get_latest", + return_value=VALID_PAYLOAD, + ), patch( "homeassistant.components.co2signal.async_setup_entry", return_value=True, ) as mock_setup_entry: @@ -100,7 +106,10 @@ async def test_form_country(hass: HomeAssistant) -> None: ) assert result2["type"] == FlowResultType.FORM - with patch("CO2Signal.get_latest", return_value=VALID_PAYLOAD,), patch( + with patch( + "CO2Signal.get_latest", + return_value=VALID_PAYLOAD, + ), patch( "homeassistant.components.co2signal.async_setup_entry", return_value=True, ) as mock_setup_entry: diff --git a/tests/components/coinbase/test_config_flow.py b/tests/components/coinbase/test_config_flow.py index 80d394c38ef..2ffb714975a 100644 --- a/tests/components/coinbase/test_config_flow.py +++ b/tests/components/coinbase/test_config_flow.py @@ -196,7 +196,6 @@ async def test_option_form(hass): ), patch( "homeassistant.components.coinbase.update_listener" ) as mock_update_listener: - config_entry = await init_mock_coinbase(hass) await hass.async_block_till_done() result = await hass.config_entries.options.async_init(config_entry.entry_id) diff --git a/tests/components/coinbase/test_diagnostics.py b/tests/components/coinbase/test_diagnostics.py index f997b02f853..726f0ef4cab 100644 --- a/tests/components/coinbase/test_diagnostics.py +++ b/tests/components/coinbase/test_diagnostics.py @@ -27,7 +27,6 @@ async def test_entry_diagnostics(hass, hass_client: ClientSession): "coinbase.wallet.client.Client.get_exchange_rates", return_value=mock_get_exchange_rates(), ): - config_entry = await init_mock_coinbase(hass) await hass.async_block_till_done() diff --git a/tests/components/deconz/test_alarm_control_panel.py b/tests/components/deconz/test_alarm_control_panel.py index 213ce3b2e08..afa63579572 100644 --- a/tests/components/deconz/test_alarm_control_panel.py +++ b/tests/components/deconz/test_alarm_control_panel.py @@ -169,7 +169,6 @@ async def test_alarm_control_panel(hass, aioclient_mock, mock_deconz_websocket): AncillaryControlPanel.ARMING_NIGHT, AncillaryControlPanel.ARMING_STAY, }: - event_changed_sensor = { "t": "event", "e": "changed", @@ -188,7 +187,6 @@ async def test_alarm_control_panel(hass, aioclient_mock, mock_deconz_websocket): AncillaryControlPanel.ENTRY_DELAY, AncillaryControlPanel.EXIT_DELAY, }: - event_changed_sensor = { "t": "event", "e": "changed", diff --git a/tests/components/dhcp/test_init.py b/tests/components/dhcp/test_init.py index ffd58ec5ea8..1eb97f3e6a6 100644 --- a/tests/components/dhcp/test_init.py +++ b/tests/components/dhcp/test_init.py @@ -146,7 +146,9 @@ async def _async_get_handle_dhcp_packet(hass, integration_matchers): async_handle_dhcp_packet = _async_handle_dhcp_packet return MagicMock() - with patch("homeassistant.components.dhcp._verify_l2socket_setup",), patch( + with patch( + "homeassistant.components.dhcp._verify_l2socket_setup", + ), patch( "scapy.arch.common.compile_filter" ), patch("scapy.sendrecv.AsyncSniffer", _mock_sniffer): await dhcp_watcher.async_start() diff --git a/tests/components/dlna_dmr/test_media_player.py b/tests/components/dlna_dmr/test_media_player.py index 889cc92c969..35beed727e6 100644 --- a/tests/components/dlna_dmr/test_media_player.py +++ b/tests/components/dlna_dmr/test_media_player.py @@ -434,7 +434,7 @@ async def test_available_device( assert device.name == "device_name" # Check entity state gets updated when device changes state - for (dev_state, ent_state) in [ + for dev_state, ent_state in [ (None, MediaPlayerState.ON), (TransportState.STOPPED, MediaPlayerState.IDLE), (TransportState.PLAYING, MediaPlayerState.PLAYING), diff --git a/tests/components/ecobee/test_config_flow.py b/tests/components/ecobee/test_config_flow.py index ca94d05f743..95da581aafb 100644 --- a/tests/components/ecobee/test_config_flow.py +++ b/tests/components/ecobee/test_config_flow.py @@ -175,7 +175,6 @@ async def test_import_flow_triggered_with_ecobee_conf_and_invalid_data(hass): ), patch.object( flow, "async_step_user", return_value=mock_coro() ) as mock_async_step_user: - await flow.async_step_import(import_data=None) mock_async_step_user.assert_called_once_with( diff --git a/tests/components/elkm1/__init__.py b/tests/components/elkm1/__init__.py index b818570ec6d..cb34f78360a 100644 --- a/tests/components/elkm1/__init__.py +++ b/tests/components/elkm1/__init__.py @@ -50,7 +50,10 @@ def _patch_elk(elk=None): @contextmanager def _patcher(): - with patch("homeassistant.components.elkm1.config_flow.Elk", new=_elk,), patch( + with patch( + "homeassistant.components.elkm1.config_flow.Elk", + new=_elk, + ), patch( "homeassistant.components.elkm1.config_flow.Elk", new=_elk, ): diff --git a/tests/components/file/test_notify.py b/tests/components/file/test_notify.py index 5c91460237e..ba007a9987a 100644 --- a/tests/components/file/test_notify.py +++ b/tests/components/file/test_notify.py @@ -51,7 +51,6 @@ async def test_notify_file(hass: HomeAssistant, timestamp: bool): with patch("homeassistant.components.file.notify.open", m_open, create=True), patch( "homeassistant.components.file.notify.os.stat" ) as mock_st, patch("homeassistant.util.dt.utcnow", return_value=dt_util.utcnow()): - mock_st.return_value.st_size = 0 title = ( f"{ATTR_TITLE_DEFAULT} notifications " diff --git a/tests/components/filesize/test_config_flow.py b/tests/components/filesize/test_config_flow.py index 2bdc1ed82a0..7010a3e9a4d 100644 --- a/tests/components/filesize/test_config_flow.py +++ b/tests/components/filesize/test_config_flow.py @@ -73,7 +73,9 @@ async def test_flow_fails_on_validation(hass: HomeAssistant) -> None: await async_create_file(hass, TEST_FILE) - with patch("homeassistant.components.filesize.config_flow.pathlib.Path",), patch( + with patch( + "homeassistant.components.filesize.config_flow.pathlib.Path", + ), patch( "homeassistant.components.filesize.async_setup_entry", return_value=True, ): @@ -87,7 +89,9 @@ async def test_flow_fails_on_validation(hass: HomeAssistant) -> None: assert result2["errors"] == {"base": "not_allowed"} hass.config.allowlist_external_dirs = {TEST_DIR} - with patch("homeassistant.components.filesize.config_flow.pathlib.Path",), patch( + with patch( + "homeassistant.components.filesize.config_flow.pathlib.Path", + ), patch( "homeassistant.components.filesize.async_setup_entry", return_value=True, ): diff --git a/tests/components/fireservicerota/test_config_flow.py b/tests/components/fireservicerota/test_config_flow.py index 35467ffc449..a26f8030513 100644 --- a/tests/components/fireservicerota/test_config_flow.py +++ b/tests/components/fireservicerota/test_config_flow.py @@ -81,7 +81,6 @@ async def test_step_user(hass): "homeassistant.components.fireservicerota.async_setup_entry", return_value=True, ) as mock_setup_entry: - mock_fireservicerota = mock_fsr.return_value mock_fireservicerota.request_tokens.return_value = MOCK_TOKEN_INFO diff --git a/tests/components/firmata/test_config_flow.py b/tests/components/firmata/test_config_flow.py index 22f8b326781..d4bf159c5c9 100644 --- a/tests/components/firmata/test_config_flow.py +++ b/tests/components/firmata/test_config_flow.py @@ -70,7 +70,6 @@ async def test_import(hass: HomeAssistant) -> None: ) as mock_setup, patch( "homeassistant.components.firmata.async_setup_entry", return_value=True ) as mock_setup_entry: - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, diff --git a/tests/components/freedompro/test_binary_sensor.py b/tests/components/freedompro/test_binary_sensor.py index f43857038ef..f366d89a9a9 100644 --- a/tests/components/freedompro/test_binary_sensor.py +++ b/tests/components/freedompro/test_binary_sensor.py @@ -71,7 +71,6 @@ async def test_binary_sensor_get_state( "homeassistant.components.freedompro.get_states", return_value=[], ): - async_fire_time_changed(hass, utcnow() + timedelta(hours=2)) await hass.async_block_till_done() @@ -98,7 +97,6 @@ async def test_binary_sensor_get_state( "homeassistant.components.freedompro.get_states", return_value=states_response, ): - async_fire_time_changed(hass, utcnow() + timedelta(hours=2)) await hass.async_block_till_done() diff --git a/tests/components/freedompro/test_config_flow.py b/tests/components/freedompro/test_config_flow.py index d80bd22736c..c06e37a0333 100644 --- a/tests/components/freedompro/test_config_flow.py +++ b/tests/components/freedompro/test_config_flow.py @@ -32,7 +32,6 @@ async def test_invalid_auth(hass): "code": -201, }, ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, @@ -51,7 +50,6 @@ async def test_connection_error(hass): "code": -200, }, ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, @@ -70,7 +68,6 @@ async def test_create_entry(hass): "devices": DEVICES, }, ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, diff --git a/tests/components/freedompro/test_sensor.py b/tests/components/freedompro/test_sensor.py index 0405c5393ce..47a29fa8db9 100644 --- a/tests/components/freedompro/test_sensor.py +++ b/tests/components/freedompro/test_sensor.py @@ -60,7 +60,6 @@ async def test_sensor_get_state( "homeassistant.components.freedompro.get_states", return_value=states_response, ): - async_fire_time_changed(hass, utcnow() + timedelta(hours=2)) await hass.async_block_till_done() diff --git a/tests/components/fritz/conftest.py b/tests/components/fritz/conftest.py index bdda6d59e39..5e86c3b83f6 100644 --- a/tests/components/fritz/conftest.py +++ b/tests/components/fritz/conftest.py @@ -57,7 +57,6 @@ class FritzConnectionMock: # pylint: disable=too-few-public-methods service = service + "1" if kwargs: - if (index := kwargs.get("NewIndex")) is None: index = next(iter(kwargs.values())) diff --git a/tests/components/fritz/test_config_flow.py b/tests/components/fritz/test_config_flow.py index 800b1e68183..65bef0d709f 100644 --- a/tests/components/fritz/test_config_flow.py +++ b/tests/components/fritz/test_config_flow.py @@ -55,7 +55,6 @@ async def test_user(hass: HomeAssistant, fc_class_mock, mock_get_source_ip): "homeassistant.components.fritz.config_flow.socket.gethostbyname", return_value=MOCK_IPS["fritz.box"], ): - mock_request_get.return_value.status_code = 200 mock_request_get.return_value.content = MOCK_REQUEST mock_request_post.return_value.status_code = 200 @@ -106,7 +105,6 @@ async def test_user_already_configured( "homeassistant.components.fritz.config_flow.socket.gethostbyname", return_value=MOCK_IPS["fritz.box"], ): - mock_request_get.return_value.status_code = 200 mock_request_get.return_value.content = MOCK_REQUEST mock_request_post.return_value.status_code = 200 @@ -143,7 +141,6 @@ async def test_exception_security(hass: HomeAssistant, mock_get_source_ip, error "homeassistant.components.fritz.config_flow.FritzConnection", side_effect=error, ): - result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input=MOCK_USER_DATA ) @@ -166,7 +163,6 @@ async def test_exception_connection(hass: HomeAssistant, mock_get_source_ip): "homeassistant.components.fritz.config_flow.FritzConnection", side_effect=FritzConnectionException, ): - result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input=MOCK_USER_DATA ) @@ -189,7 +185,6 @@ async def test_exception_unknown(hass: HomeAssistant, mock_get_source_ip): "homeassistant.components.fritz.config_flow.FritzConnection", side_effect=OSError, ): - result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input=MOCK_USER_DATA ) @@ -220,7 +215,6 @@ async def test_reauth_successful( ) as mock_request_get, patch( "requests.post" ) as mock_request_post: - mock_request_get.return_value.status_code = 200 mock_request_get.return_value.content = MOCK_REQUEST mock_request_post.return_value.status_code = 200 @@ -269,7 +263,6 @@ async def test_reauth_not_successful( "homeassistant.components.fritz.config_flow.FritzConnection", side_effect=side_effect, ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_REAUTH, "entry_id": mock_config.entry_id}, @@ -311,7 +304,6 @@ async def test_ssdp_already_configured( "homeassistant.components.fritz.config_flow.socket.gethostbyname", return_value=MOCK_IPS["fritz.box"], ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_SSDP}, data=MOCK_SSDP_DATA ) @@ -338,7 +330,6 @@ async def test_ssdp_already_configured_host( "homeassistant.components.fritz.config_flow.socket.gethostbyname", return_value=MOCK_IPS["fritz.box"], ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_SSDP}, data=MOCK_SSDP_DATA ) @@ -365,7 +356,6 @@ async def test_ssdp_already_configured_host_uuid( "homeassistant.components.fritz.config_flow.socket.gethostbyname", return_value=MOCK_IPS["fritz.box"], ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_SSDP}, data=MOCK_SSDP_DATA ) @@ -381,7 +371,6 @@ async def test_ssdp_already_in_progress_host( "homeassistant.components.fritz.config_flow.FritzConnection", side_effect=fc_class_mock, ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_SSDP}, data=MOCK_SSDP_DATA ) @@ -413,7 +402,6 @@ async def test_ssdp(hass: HomeAssistant, fc_class_mock, mock_get_source_ip): ) as mock_request_get, patch( "requests.post" ) as mock_request_post: - mock_request_get.return_value.status_code = 200 mock_request_get.return_value.content = MOCK_REQUEST mock_request_post.return_value.status_code = 200 @@ -447,7 +435,6 @@ async def test_ssdp_exception(hass: HomeAssistant, mock_get_source_ip): "homeassistant.components.fritz.config_flow.FritzConnection", side_effect=FritzConnectionException, ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_SSDP}, data=MOCK_SSDP_DATA ) diff --git a/tests/components/fronius/test_config_flow.py b/tests/components/fronius/test_config_flow.py index 69f1dffa64b..9c586352052 100644 --- a/tests/components/fronius/test_config_flow.py +++ b/tests/components/fronius/test_config_flow.py @@ -302,7 +302,10 @@ async def test_dhcp_invalid(hass, aioclient_mock): """Test starting a flow from discovery.""" with patch( "homeassistant.components.fronius.config_flow.DHCP_REQUEST_DELAY", 0 - ), patch("pyfronius.Fronius.current_logger_info", side_effect=FroniusError,), patch( + ), patch( + "pyfronius.Fronius.current_logger_info", + side_effect=FroniusError, + ), patch( "pyfronius.Fronius.inverter_info", side_effect=FroniusError, ): diff --git a/tests/components/generic/test_camera.py b/tests/components/generic/test_camera.py index 04c7fcca5b5..f41f4c4f592 100644 --- a/tests/components/generic/test_camera.py +++ b/tests/components/generic/test_camera.py @@ -486,7 +486,6 @@ async def test_no_still_image_url(hass, hass_client): "homeassistant.components.generic.camera.GenericCamera.stream_source", return_value=None, ) as mock_stream_source: - # First test when there is no stream_source should fail resp = await client.get("/api/camera_proxy/camera.config_test") await hass.async_block_till_done() @@ -494,7 +493,6 @@ async def test_no_still_image_url(hass, hass_client): assert resp.status == HTTPStatus.INTERNAL_SERVER_ERROR with patch("homeassistant.components.camera.create_stream") as mock_create_stream: - # Now test when creating the stream succeeds mock_stream = Mock() mock_stream.async_get_image = AsyncMock() diff --git a/tests/components/greeneye_monitor/conftest.py b/tests/components/greeneye_monitor/conftest.py index eabac97d1cc..70b337430c5 100644 --- a/tests/components/greeneye_monitor/conftest.py +++ b/tests/components/greeneye_monitor/conftest.py @@ -27,7 +27,7 @@ def assert_sensor_state( assert state actual_state = state.state assert actual_state == expected_state - for (key, value) in attributes.items(): + for key, value in attributes.items(): assert key in state.attributes assert state.attributes[key] == value diff --git a/tests/components/hddtemp/test_sensor.py b/tests/components/hddtemp/test_sensor.py index c95c6af50f4..710f97cdc59 100644 --- a/tests/components/hddtemp/test_sensor.py +++ b/tests/components/hddtemp/test_sensor.py @@ -161,7 +161,6 @@ async def test_hddtemp_multiple_disks(hass, telnetmock): "sensor.hd_temperature_dev_sdb1", "sensor.hd_temperature_dev_sdc1", ]: - state = hass.states.get(sensor) reference = REFERENCE[state.attributes.get("device")] diff --git a/tests/components/history_stats/test_sensor.py b/tests/components/history_stats/test_sensor.py index 3caf634c6bf..2521bd9dda8 100644 --- a/tests/components/history_stats/test_sensor.py +++ b/tests/components/history_stats/test_sensor.py @@ -961,7 +961,6 @@ async def test_does_not_work_into_the_future(recorder_mock, hass): "homeassistant.components.recorder.history.state_changes_during_period", _fake_states, ): - with freeze_time(start_time): await async_setup_component( hass, diff --git a/tests/components/honeywell/test_config_flow.py b/tests/components/honeywell/test_config_flow.py index 2d76962b028..1a1ea42a406 100644 --- a/tests/components/honeywell/test_config_flow.py +++ b/tests/components/honeywell/test_config_flow.py @@ -134,7 +134,6 @@ async def test_reauth_flow(hass: HomeAssistant) -> None: "homeassistant.components.honeywell.async_setup_entry", return_value=True, ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={ diff --git a/tests/components/hue/test_config_flow.py b/tests/components/hue/test_config_flow.py index aad574bd1db..4be703c808f 100644 --- a/tests/components/hue/test_config_flow.py +++ b/tests/components/hue/test_config_flow.py @@ -34,7 +34,7 @@ def create_mock_api_discovery(aioclient_mock, bridges): URL_NUPNP, json=[{"internalipaddress": host, "id": id} for (host, id) in bridges], ) - for (host, bridge_id) in bridges: + for host, bridge_id in bridges: aioclient_mock.get( f"http://{host}/api/config", json={"bridgeid": bridge_id}, diff --git a/tests/components/hue/test_init.py b/tests/components/hue/test_init.py index 3bce9f9ec83..74ece83c3df 100644 --- a/tests/components/hue/test_init.py +++ b/tests/components/hue/test_init.py @@ -151,7 +151,6 @@ async def test_security_vuln_check(hass): ) ), ): - assert await async_setup_component(hass, "hue", {}) await hass.async_block_till_done() diff --git a/tests/components/huisbaasje/test_config_flow.py b/tests/components/huisbaasje/test_config_flow.py index e270079de8c..ab77729e86d 100644 --- a/tests/components/huisbaasje/test_config_flow.py +++ b/tests/components/huisbaasje/test_config_flow.py @@ -206,7 +206,10 @@ async def test_form_entry_exists(hass): with patch("energyflip.EnergyFlip.authenticate", return_value=None), patch( "energyflip.EnergyFlip.customer_overview", return_value=None - ), patch("energyflip.EnergyFlip.get_user_id", return_value="test-id",), patch( + ), patch( + "energyflip.EnergyFlip.get_user_id", + return_value="test-id", + ), patch( "homeassistant.components.huisbaasje.async_setup_entry", return_value=True, ): diff --git a/tests/components/huisbaasje/test_sensor.py b/tests/components/huisbaasje/test_sensor.py index bd792f3230f..16b6b87fbb1 100644 --- a/tests/components/huisbaasje/test_sensor.py +++ b/tests/components/huisbaasje/test_sensor.py @@ -36,7 +36,6 @@ async def test_setup_entry(hass: HomeAssistant): "energyflip.EnergyFlip.current_measurements", return_value=MOCK_CURRENT_MEASUREMENTS, ) as mock_current_measurements: - hass.config.components.add(huisbaasje.DOMAIN) config_entry = MockConfigEntry( version=1, @@ -364,7 +363,6 @@ async def test_setup_entry_absent_measurement(hass: HomeAssistant): "energyflip.EnergyFlip.current_measurements", return_value=MOCK_LIMITED_CURRENT_MEASUREMENTS, ) as mock_current_measurements: - hass.config.components.add(huisbaasje.DOMAIN) config_entry = MockConfigEntry( version=1, diff --git a/tests/components/hvv_departures/test_config_flow.py b/tests/components/hvv_departures/test_config_flow.py index 126e61cf629..82995473b27 100644 --- a/tests/components/hvv_departures/test_config_flow.py +++ b/tests/components/hvv_departures/test_config_flow.py @@ -42,7 +42,6 @@ async def test_user_flow(hass): "homeassistant.components.hvv_departures.async_setup_entry", return_value=True, ): - # step: user result_user = await hass.config_entries.flow.async_init( @@ -103,7 +102,6 @@ async def test_user_flow_no_results(hass): "homeassistant.components.hvv_departures.async_setup_entry", return_value=True, ): - # step: user result_user = await hass.config_entries.flow.async_init( @@ -139,7 +137,6 @@ async def test_user_flow_invalid_auth(hass): "Authentication failed!", ), ): - # step: user result_user = await hass.config_entries.flow.async_init( DOMAIN, @@ -162,7 +159,6 @@ async def test_user_flow_cannot_connect(hass): "homeassistant.components.hvv_departures.hub.GTI.init", side_effect=CannotConnect(), ): - # step: user result_user = await hass.config_entries.flow.async_init( DOMAIN, @@ -188,7 +184,6 @@ async def test_user_flow_station(hass): "homeassistant.components.hvv_departures.hub.GTI.checkName", return_value={"returnCode": "OK", "results": []}, ): - # step: user result_user = await hass.config_entries.flow.async_init( diff --git a/tests/components/insteon/test_config_flow.py b/tests/components/insteon/test_config_flow.py index 99a505cc630..c18b4e48946 100644 --- a/tests/components/insteon/test_config_flow.py +++ b/tests/components/insteon/test_config_flow.py @@ -84,9 +84,10 @@ async def _init_form(hass, modem_type): async def _device_form(hass, flow_id, connection, user_input): """Test the PLM, Hub v1 or Hub v2 form.""" - with patch(PATCH_CONNECTION, new=connection,), patch( - PATCH_ASYNC_SETUP, return_value=True - ) as mock_setup, patch( + with patch( + PATCH_CONNECTION, + new=connection, + ), patch(PATCH_ASYNC_SETUP, return_value=True) as mock_setup, patch( PATCH_ASYNC_SETUP_ENTRY, return_value=True, ) as mock_setup_entry: @@ -200,7 +201,10 @@ async def test_failed_connection_hub(hass: HomeAssistant): async def _import_config(hass, config): """Run the import step.""" - with patch(PATCH_CONNECTION, new=mock_successful_connection,), patch( + with patch( + PATCH_CONNECTION, + new=mock_successful_connection, + ), patch( PATCH_ASYNC_SETUP, return_value=True ), patch(PATCH_ASYNC_SETUP_ENTRY, return_value=True): return await hass.config_entries.flow.async_init( @@ -287,7 +291,10 @@ async def test_import_existing(hass: HomeAssistant): async def test_import_failed_connection(hass: HomeAssistant): """Test a failed connection on import.""" - with patch(PATCH_CONNECTION, new=mock_failed_connection,), patch( + with patch( + PATCH_CONNECTION, + new=mock_failed_connection, + ), patch( PATCH_ASYNC_SETUP, return_value=True ), patch(PATCH_ASYNC_SETUP_ENTRY, return_value=True): result = await hass.config_entries.flow.async_init( diff --git a/tests/components/intellifire/test_config_flow.py b/tests/components/intellifire/test_config_flow.py index 9e5d5627a94..93aef0944aa 100644 --- a/tests/components/intellifire/test_config_flow.py +++ b/tests/components/intellifire/test_config_flow.py @@ -144,7 +144,6 @@ async def test_manual_entry( "homeassistant.components.intellifire.config_flow.AsyncUDPFireplaceFinder.search_fireplace", return_value=["192.168.1.69", "192.168.1.33", "192.168.169"], ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) @@ -190,7 +189,6 @@ async def test_multi_discovery_cannot_connect( "homeassistant.components.intellifire.config_flow.AsyncUDPFireplaceFinder.search_fireplace", return_value=["192.168.1.69", "192.168.1.33", "192.168.169"], ): - mock_intellifire_config_flow.poll.side_effect = ConnectionError result = await hass.config_entries.flow.async_init( diff --git a/tests/components/ipma/test_config_flow.py b/tests/components/ipma/test_config_flow.py index e254ba402fb..c2a590b5b31 100644 --- a/tests/components/ipma/test_config_flow.py +++ b/tests/components/ipma/test_config_flow.py @@ -89,7 +89,6 @@ async def test_flow_entry_created_from_user_input(): "async_entries", return_value=[], ) as config_entries: - result = await flow.async_step_user(user_input=test_data) assert result["type"] == "create_entry" @@ -116,7 +115,6 @@ async def test_flow_entry_config_entry_already_exists(): ) as config_form, patch.object( flow.hass.config_entries, "async_entries", return_value={"home": test_data} ) as config_entries: - await flow.async_step_user(user_input=test_data) assert len(config_form.mock_calls) == 1 diff --git a/tests/components/ipma/test_init.py b/tests/components/ipma/test_init.py index 8dd808b1b1b..f80e1b0743d 100644 --- a/tests/components/ipma/test_init.py +++ b/tests/components/ipma/test_init.py @@ -19,7 +19,6 @@ async def test_async_setup_raises_entry_not_ready(hass): with patch( "pyipma.location.Location.get", side_effect=IPMAException("API unavailable") ): - config_entry = MockConfigEntry( domain=DOMAIN, title="Home", diff --git a/tests/components/iss/test_config_flow.py b/tests/components/iss/test_config_flow.py index a806bea3056..b73dc6681cf 100644 --- a/tests/components/iss/test_config_flow.py +++ b/tests/components/iss/test_config_flow.py @@ -21,7 +21,6 @@ async def test_create_entry(hass: HomeAssistant): assert result.get("step_id") == SOURCE_USER with patch("homeassistant.components.iss.async_setup_entry", return_value=True): - result = await hass.config_entries.flow.async_configure( result["flow_id"], {}, diff --git a/tests/components/lacrosse_view/test_config_flow.py b/tests/components/lacrosse_view/test_config_flow.py index 8325cec9209..67c9bf5752c 100644 --- a/tests/components/lacrosse_view/test_config_flow.py +++ b/tests/components/lacrosse_view/test_config_flow.py @@ -19,7 +19,10 @@ async def test_form(hass: HomeAssistant) -> None: assert result["type"] == FlowResultType.FORM assert result["errors"] is None - with patch("lacrosse_view.LaCrosse.login", return_value=True,), patch( + with patch( + "lacrosse_view.LaCrosse.login", + return_value=True, + ), patch( "lacrosse_view.LaCrosse.get_locations", return_value=[Location(id=1, name="Test")], ), patch( @@ -189,7 +192,10 @@ async def test_already_configured_device(hass: HomeAssistant) -> None: assert result["type"] == FlowResultType.FORM assert result["errors"] is None - with patch("lacrosse_view.LaCrosse.login", return_value=True,), patch( + with patch( + "lacrosse_view.LaCrosse.login", + return_value=True, + ), patch( "lacrosse_view.LaCrosse.get_locations", return_value=[Location(id=1, name="Test")], ): diff --git a/tests/components/launch_library/test_config_flow.py b/tests/components/launch_library/test_config_flow.py index a9dd794d05e..a33b957b329 100644 --- a/tests/components/launch_library/test_config_flow.py +++ b/tests/components/launch_library/test_config_flow.py @@ -21,7 +21,6 @@ async def test_create_entry(hass): with patch( "homeassistant.components.launch_library.async_setup_entry", return_value=True ): - result = await hass.config_entries.flow.async_configure( result["flow_id"], {}, diff --git a/tests/components/led_ble/test_config_flow.py b/tests/components/led_ble/test_config_flow.py index 6767302af50..3948a599260 100644 --- a/tests/components/led_ble/test_config_flow.py +++ b/tests/components/led_ble/test_config_flow.py @@ -31,7 +31,9 @@ async def test_user_step_success(hass: HomeAssistant) -> None: assert result["step_id"] == "user" assert result["errors"] == {} - with patch("homeassistant.components.led_ble.config_flow.LEDBLE.update",), patch( + with patch( + "homeassistant.components.led_ble.config_flow.LEDBLE.update", + ), patch( "homeassistant.components.led_ble.async_setup_entry", return_value=True, ) as mock_setup_entry: @@ -115,7 +117,9 @@ async def test_user_step_cannot_connect(hass: HomeAssistant) -> None: assert result2["step_id"] == "user" assert result2["errors"] == {"base": "cannot_connect"} - with patch("homeassistant.components.led_ble.config_flow.LEDBLE.update",), patch( + with patch( + "homeassistant.components.led_ble.config_flow.LEDBLE.update", + ), patch( "homeassistant.components.led_ble.async_setup_entry", return_value=True, ) as mock_setup_entry: @@ -165,7 +169,9 @@ async def test_user_step_unknown_exception(hass: HomeAssistant) -> None: assert result2["step_id"] == "user" assert result2["errors"] == {"base": "unknown"} - with patch("homeassistant.components.led_ble.config_flow.LEDBLE.update",), patch( + with patch( + "homeassistant.components.led_ble.config_flow.LEDBLE.update", + ), patch( "homeassistant.components.led_ble.async_setup_entry", return_value=True, ) as mock_setup_entry: @@ -197,7 +203,9 @@ async def test_bluetooth_step_success(hass: HomeAssistant) -> None: assert result["step_id"] == "user" assert result["errors"] == {} - with patch("homeassistant.components.led_ble.config_flow.LEDBLE.update",), patch( + with patch( + "homeassistant.components.led_ble.config_flow.LEDBLE.update", + ), patch( "homeassistant.components.led_ble.async_setup_entry", return_value=True, ) as mock_setup_entry: diff --git a/tests/components/litterrobot/test_config_flow.py b/tests/components/litterrobot/test_config_flow.py index ee5b718fa60..05a114e7188 100644 --- a/tests/components/litterrobot/test_config_flow.py +++ b/tests/components/litterrobot/test_config_flow.py @@ -140,7 +140,6 @@ async def test_step_reauth(hass: HomeAssistant, mock_account: Account) -> None: "homeassistant.components.litterrobot.async_setup_entry", return_value=True, ) as mock_setup_entry: - result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={CONF_PASSWORD: CONFIG[litterrobot.DOMAIN][CONF_PASSWORD]}, @@ -190,7 +189,6 @@ async def test_step_reauth_failed(hass: HomeAssistant, mock_account: Account) -> "homeassistant.components.litterrobot.async_setup_entry", return_value=True, ) as mock_setup_entry: - result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={CONF_PASSWORD: CONFIG[litterrobot.DOMAIN][CONF_PASSWORD]}, diff --git a/tests/components/local_file/test_camera.py b/tests/components/local_file/test_camera.py index 8432420244e..56d79a0c06c 100644 --- a/tests/components/local_file/test_camera.py +++ b/tests/components/local_file/test_camera.py @@ -145,7 +145,6 @@ async def test_update_file_path(hass): "homeassistant.components.local_file.camera.mimetypes.guess_type", mock.Mock(return_value=(None, None)), ): - camera_1 = {"platform": "local_file", "file_path": "mock/path.jpg"} camera_2 = { "platform": "local_file", diff --git a/tests/components/melnor/conftest.py b/tests/components/melnor/conftest.py index 2f3c765cfa8..e030e198787 100644 --- a/tests/components/melnor/conftest.py +++ b/tests/components/melnor/conftest.py @@ -118,7 +118,6 @@ def mock_melnor_device(): """Return a mocked Melnor device.""" with patch("melnor_bluetooth.device.Device") as mock: - device = mock.return_value device.connect = AsyncMock(return_value=True) diff --git a/tests/components/melnor/test_config_flow.py b/tests/components/melnor/test_config_flow.py index 364531a314a..9fda8dcae7c 100644 --- a/tests/components/melnor/test_config_flow.py +++ b/tests/components/melnor/test_config_flow.py @@ -22,7 +22,6 @@ async def test_user_step_no_devices(hass): with patch_async_setup_entry() as mock_setup_entry, patch_async_discovered_service_info( [] ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER}, @@ -38,7 +37,6 @@ async def test_user_step_discovered_devices(hass): """Test we properly handle device picking.""" with patch_async_setup_entry() as mock_setup_entry, patch_async_discovered_service_info(): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER}, @@ -68,7 +66,6 @@ async def test_user_step_with_existing_device(hass): with patch_async_setup_entry() as mock_setup_entry, patch_async_discovered_service_info( [FAKE_SERVICE_INFO_1, FAKE_SERVICE_INFO_2] ): - # Create the config flow result = await hass.config_entries.flow.async_init( DOMAIN, @@ -105,7 +102,6 @@ async def test_bluetooth_discovered(hass): """Test we short circuit to config entry creation.""" with patch_async_setup_entry() as mock_setup_entry: - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_BLUETOOTH}, @@ -123,7 +119,6 @@ async def test_bluetooth_confirm(hass): """Test we short circuit to config entry creation.""" with patch_async_setup_entry() as mock_setup_entry: - # Create the config flow result = await hass.config_entries.flow.async_init( DOMAIN, diff --git a/tests/components/melnor/test_number.py b/tests/components/melnor/test_number.py index 9cddbfceb77..1366e428fc1 100644 --- a/tests/components/melnor/test_number.py +++ b/tests/components/melnor/test_number.py @@ -16,7 +16,6 @@ async def test_manual_watering_minutes(hass): entry = mock_config_entry(hass) with patch_async_ble_device_from_address(), patch_melnor_device() as device_patch, patch_async_register_callback(): - device = device_patch.return_value assert await hass.config_entries.async_setup(entry.entry_id) diff --git a/tests/components/melnor/test_switch.py b/tests/components/melnor/test_switch.py index 9539b00d9c6..822892dcf32 100644 --- a/tests/components/melnor/test_switch.py +++ b/tests/components/melnor/test_switch.py @@ -33,7 +33,6 @@ async def test_manual_watering_switch_on_off(hass): entry = mock_config_entry(hass) with patch_async_ble_device_from_address(), patch_melnor_device() as device_patch, patch_async_register_callback(): - device = device_patch.return_value assert await hass.config_entries.async_setup(entry.entry_id) diff --git a/tests/components/minecraft_server/test_config_flow.py b/tests/components/minecraft_server/test_config_flow.py index 7d6b8227396..25c0cec441b 100644 --- a/tests/components/minecraft_server/test_config_flow.py +++ b/tests/components/minecraft_server/test_config_flow.py @@ -99,7 +99,10 @@ async def test_invalid_ip(hass: HomeAssistant) -> None: async def test_same_host(hass: HomeAssistant) -> None: """Test abort in case of same host name.""" - with patch("aiodns.DNSResolver.query", side_effect=aiodns.error.DNSError,), patch( + with patch( + "aiodns.DNSResolver.query", + side_effect=aiodns.error.DNSError, + ), patch( "mcstatus.server.MinecraftServer.status", return_value=PingResponse(STATUS_RESPONSE_RAW), ): @@ -166,7 +169,10 @@ async def test_connection_failed(hass: HomeAssistant) -> None: async def test_connection_succeeded_with_srv_record(hass: HomeAssistant) -> None: """Test config entry in case of a successful connection with a SRV record.""" - with patch("aiodns.DNSResolver.query", return_value=SRV_RECORDS,), patch( + with patch( + "aiodns.DNSResolver.query", + return_value=SRV_RECORDS, + ), patch( "mcstatus.server.MinecraftServer.status", return_value=PingResponse(STATUS_RESPONSE_RAW), ): @@ -182,7 +188,10 @@ async def test_connection_succeeded_with_srv_record(hass: HomeAssistant) -> None async def test_connection_succeeded_with_host(hass: HomeAssistant) -> None: """Test config entry in case of a successful connection with a host name.""" - with patch("aiodns.DNSResolver.query", side_effect=aiodns.error.DNSError,), patch( + with patch( + "aiodns.DNSResolver.query", + side_effect=aiodns.error.DNSError, + ), patch( "mcstatus.server.MinecraftServer.status", return_value=PingResponse(STATUS_RESPONSE_RAW), ): diff --git a/tests/components/modbus/test_init.py b/tests/components/modbus/test_init.py index 8603b3e278b..addb9cbc94a 100644 --- a/tests/components/modbus/test_init.py +++ b/tests/components/modbus/test_init.py @@ -135,7 +135,7 @@ async def test_number_validator(): try: number_validator("x15.1") - except (vol.Invalid): + except vol.Invalid: return pytest.fail("Number_validator not throwing exception") diff --git a/tests/components/moehlenhoff_alpha2/test_config_flow.py b/tests/components/moehlenhoff_alpha2/test_config_flow.py index a1f98454015..4842d648828 100644 --- a/tests/components/moehlenhoff_alpha2/test_config_flow.py +++ b/tests/components/moehlenhoff_alpha2/test_config_flow.py @@ -60,7 +60,6 @@ async def test_form_duplicate_error(hass: HomeAssistant) -> None: assert config_entry.data["host"] == MOCK_BASE_HOST with patch("moehlenhoff_alpha2.Alpha2Base.update_data", mock_update_data): - result = await hass.config_entries.flow.async_init( DOMAIN, data={"host": MOCK_BASE_HOST}, diff --git a/tests/components/mqtt/test_common.py b/tests/components/mqtt/test_common.py index f0a22987aa3..654fb2009ca 100644 --- a/tests/components/mqtt/test_common.py +++ b/tests/components/mqtt/test_common.py @@ -728,14 +728,14 @@ async def help_test_discovery_update( assert state.name == "Beer" if state_data1: - for (mqtt_messages, expected_state, attributes) in state_data1: - for (topic, data) in mqtt_messages: + for mqtt_messages, expected_state, attributes in state_data1: + for topic, data in mqtt_messages: async_fire_mqtt_message(hass, topic, data) state = hass.states.get(f"{domain}.beer") if expected_state: assert state.state == expected_state if attributes: - for (attr, value) in attributes: + for attr, value in attributes: assert state.attributes.get(attr) == value async_fire_mqtt_message(hass, f"homeassistant/{domain}/bla/config", discovery_data2) @@ -746,14 +746,14 @@ async def help_test_discovery_update( assert state.name == "Milk" if state_data2: - for (mqtt_messages, expected_state, attributes) in state_data2: - for (topic, data) in mqtt_messages: + for mqtt_messages, expected_state, attributes in state_data2: + for topic, data in mqtt_messages: async_fire_mqtt_message(hass, topic, data) state = hass.states.get(f"{domain}.beer") if expected_state: assert state.state == expected_state if attributes: - for (attr, value) in attributes: + for attr, value in attributes: assert state.attributes.get(attr) == value state = hass.states.get(f"{domain}.milk") diff --git a/tests/components/mqtt/test_discovery.py b/tests/components/mqtt/test_discovery.py index 251c0af24a6..c716cb4dae7 100644 --- a/tests/components/mqtt/test_discovery.py +++ b/tests/components/mqtt/test_discovery.py @@ -105,7 +105,6 @@ async def test_invalid_json(hass, mqtt_mock_entry_no_yaml_config, caplog): with patch( "homeassistant.components.mqtt.discovery.async_dispatcher_send" ) as mock_dispatcher_send: - mock_dispatcher_send = AsyncMock(return_value=None) async_fire_mqtt_message( @@ -122,7 +121,6 @@ async def test_only_valid_components(hass, mqtt_mock_entry_no_yaml_config, caplo with patch( "homeassistant.components.mqtt.discovery.async_dispatcher_send" ) as mock_dispatcher_send: - invalid_component = "timer" mock_dispatcher_send = AsyncMock(return_value=None) diff --git a/tests/components/mqtt_json/test_device_tracker.py b/tests/components/mqtt_json/test_device_tracker.py index b0cba664250..03719c39c59 100644 --- a/tests/components/mqtt_json/test_device_tracker.py +++ b/tests/components/mqtt_json/test_device_tracker.py @@ -46,7 +46,6 @@ async def test_ensure_device_tracker_platform_validation(hass): autospec=True, side_effect=mock_setup_scanner, ) as mock_sp: - dev_id = "paulus" topic = "location/paulus" assert await async_setup_component( diff --git a/tests/components/mutesync/test_config_flow.py b/tests/components/mutesync/test_config_flow.py index 934eb190742..5550ed899c0 100644 --- a/tests/components/mutesync/test_config_flow.py +++ b/tests/components/mutesync/test_config_flow.py @@ -19,7 +19,10 @@ async def test_form(hass: HomeAssistant) -> None: assert result["type"] == "form" assert result["errors"] is None - with patch("mutesync.authenticate", return_value="bla",), patch( + with patch( + "mutesync.authenticate", + return_value="bla", + ), patch( "homeassistant.components.mutesync.async_setup_entry", return_value=True, ) as mock_setup_entry: diff --git a/tests/components/nam/test_config_flow.py b/tests/components/nam/test_config_flow.py index aef0fa41fe5..2531263e58a 100644 --- a/tests/components/nam/test_config_flow.py +++ b/tests/components/nam/test_config_flow.py @@ -219,7 +219,6 @@ async def test_form_errors(hass, error): "homeassistant.components.nam.NettigoAirMonitor.initialize", side_effect=exc, ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, diff --git a/tests/components/netatmo/test_init.py b/tests/components/netatmo/test_init.py index 65cc991ec67..137c26e1c4f 100644 --- a/tests/components/netatmo/test_init.py +++ b/tests/components/netatmo/test_init.py @@ -304,7 +304,6 @@ async def test_setup_component_with_delay(hass, config_entry): ) as mock_post_api_request, patch( "homeassistant.components.netatmo.data_handler.PLATFORMS", ["light"] ): - assert await async_setup_component( hass, "netatmo", {"netatmo": {"client_id": "123", "client_secret": "abc"}} ) diff --git a/tests/components/nexia/test_config_flow.py b/tests/components/nexia/test_config_flow.py index 5bfd7fb582c..cdf81ea09d3 100644 --- a/tests/components/nexia/test_config_flow.py +++ b/tests/components/nexia/test_config_flow.py @@ -53,7 +53,9 @@ async def test_form_invalid_auth(hass): DOMAIN, context={"source": config_entries.SOURCE_USER} ) - with patch("homeassistant.components.nexia.config_flow.NexiaHome.login",), patch( + with patch( + "homeassistant.components.nexia.config_flow.NexiaHome.login", + ), patch( "homeassistant.components.nexia.config_flow.NexiaHome.get_name", return_value=None, ): diff --git a/tests/components/nina/test_binary_sensor.py b/tests/components/nina/test_binary_sensor.py index 855b733ef46..6238496ed09 100644 --- a/tests/components/nina/test_binary_sensor.py +++ b/tests/components/nina/test_binary_sensor.py @@ -46,7 +46,6 @@ async def test_sensors(hass: HomeAssistant) -> None: "pynina.baseApi.BaseAPI._makeRequest", wraps=mocked_request_function, ): - conf_entry: MockConfigEntry = MockConfigEntry( domain=DOMAIN, title="NINA", data=ENTRY_DATA ) @@ -155,7 +154,6 @@ async def test_sensors_without_corona_filter(hass: HomeAssistant) -> None: "pynina.baseApi.BaseAPI._makeRequest", wraps=mocked_request_function, ): - conf_entry: MockConfigEntry = MockConfigEntry( domain=DOMAIN, title="NINA", data=ENTRY_DATA_NO_CORONA ) diff --git a/tests/components/nina/test_config_flow.py b/tests/components/nina/test_config_flow.py index bfea7781780..e09bdfc739b 100644 --- a/tests/components/nina/test_config_flow.py +++ b/tests/components/nina/test_config_flow.py @@ -54,7 +54,6 @@ async def test_show_set_form(hass: HomeAssistant) -> None: "pynina.baseApi.BaseAPI._makeRequest", wraps=mocked_request_function, ): - result: dict[str, Any] = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER} ) @@ -69,7 +68,6 @@ async def test_step_user_connection_error(hass: HomeAssistant) -> None: "pynina.baseApi.BaseAPI._makeRequest", side_effect=ApiError("Could not connect to Api"), ): - result: dict[str, Any] = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=deepcopy(DUMMY_DATA) ) @@ -84,7 +82,6 @@ async def test_step_user_unexpected_exception(hass: HomeAssistant) -> None: "pynina.baseApi.BaseAPI._makeRequest", side_effect=Exception("DUMMY"), ): - result: dict[str, Any] = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=deepcopy(DUMMY_DATA) ) @@ -101,7 +98,6 @@ async def test_step_user(hass: HomeAssistant) -> None: "homeassistant.components.nina.async_setup_entry", return_value=True, ): - result: dict[str, Any] = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=deepcopy(DUMMY_DATA) ) @@ -116,7 +112,6 @@ async def test_step_user_no_selection(hass: HomeAssistant) -> None: "pynina.baseApi.BaseAPI._makeRequest", wraps=mocked_request_function, ): - result: dict[str, Any] = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data={} ) diff --git a/tests/components/nina/test_init.py b/tests/components/nina/test_init.py index 66e8edb2806..d75e35473ca 100644 --- a/tests/components/nina/test_init.py +++ b/tests/components/nina/test_init.py @@ -27,7 +27,6 @@ async def init_integration(hass) -> MockConfigEntry: "pynina.baseApi.BaseAPI._makeRequest", wraps=mocked_request_function, ): - entry: MockConfigEntry = MockConfigEntry( domain=DOMAIN, title="NINA", data=ENTRY_DATA ) diff --git a/tests/components/nzbget/test_sensor.py b/tests/components/nzbget/test_sensor.py index 524133cf957..5e82879209a 100644 --- a/tests/components/nzbget/test_sensor.py +++ b/tests/components/nzbget/test_sensor.py @@ -73,7 +73,7 @@ async def test_sensors(hass, nzbget_api) -> None: ), } - for (sensor_id, data) in sensors.items(): + for sensor_id, data in sensors.items(): entity_entry = registry.async_get(f"sensor.nzbgettest_{sensor_id}") assert entity_entry assert entity_entry.original_device_class == data[3] diff --git a/tests/components/oncue/__init__.py b/tests/components/oncue/__init__.py index 2ddaf1987f8..26b08460a93 100644 --- a/tests/components/oncue/__init__.py +++ b/tests/components/oncue/__init__.py @@ -801,7 +801,9 @@ MOCK_ASYNC_FETCH_ALL_UNAVAILABLE_DEVICE = { def _patch_login_and_data(): @contextmanager def _patcher(): - with patch("homeassistant.components.oncue.Oncue.async_login",), patch( + with patch( + "homeassistant.components.oncue.Oncue.async_login", + ), patch( "homeassistant.components.oncue.Oncue.async_fetch_all", return_value=MOCK_ASYNC_FETCH_ALL, ): @@ -813,7 +815,9 @@ def _patch_login_and_data(): def _patch_login_and_data_offline_device(): @contextmanager def _patcher(): - with patch("homeassistant.components.oncue.Oncue.async_login",), patch( + with patch( + "homeassistant.components.oncue.Oncue.async_login", + ), patch( "homeassistant.components.oncue.Oncue.async_fetch_all", return_value=MOCK_ASYNC_FETCH_ALL_OFFLINE_DEVICE, ): @@ -837,7 +841,6 @@ def _patch_login_and_data_unavailable(): def _patch_login_and_data_unavailable_device(): @contextmanager def _patcher(): - with patch("homeassistant.components.oncue.Oncue.async_login"), patch( "homeassistant.components.oncue.Oncue.async_fetch_all", return_value=MOCK_ASYNC_FETCH_ALL_UNAVAILABLE_DEVICE, diff --git a/tests/components/plaato/test_config_flow.py b/tests/components/plaato/test_config_flow.py index f3abd5a6905..14fa1dd8069 100644 --- a/tests/components/plaato/test_config_flow.py +++ b/tests/components/plaato/test_config_flow.py @@ -294,7 +294,6 @@ async def test_options(hass): with patch( "homeassistant.components.plaato.async_setup_entry", return_value=True ) as mock_setup_entry: - await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() @@ -329,7 +328,6 @@ async def test_options_webhook(hass, webhook_id): with patch( "homeassistant.components.plaato.async_setup_entry", return_value=True ) as mock_setup_entry: - await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() diff --git a/tests/components/plant/test_init.py b/tests/components/plant/test_init.py index d143bbef00d..15ad409b4cc 100644 --- a/tests/components/plant/test_init.py +++ b/tests/components/plant/test_init.py @@ -152,7 +152,6 @@ async def test_load_from_db(recorder_mock, hass): """ plant_name = "wise_plant" for value in [20, 30, 10]: - hass.states.async_set( BRIGHTNESS_ENTITY, value, {ATTR_UNIT_OF_MEASUREMENT: "Lux"} ) diff --git a/tests/components/prosegur/test_alarm_control_panel.py b/tests/components/prosegur/test_alarm_control_panel.py index a0a81a50c73..a389478b70f 100644 --- a/tests/components/prosegur/test_alarm_control_panel.py +++ b/tests/components/prosegur/test_alarm_control_panel.py @@ -73,7 +73,6 @@ async def test_connection_error(hass, mock_auth): install.status = Status.ARMED with patch("pyprosegur.installation.Installation.retrieve", return_value=install): - await setup_platform(hass) await hass.async_block_till_done() @@ -81,7 +80,6 @@ async def test_connection_error(hass, mock_auth): with patch( "pyprosegur.installation.Installation.retrieve", side_effect=ConnectionError ): - await entity_component.async_update_entity(hass, PROSEGUR_ALARM_ENTITY) state = hass.states.get(PROSEGUR_ALARM_ENTITY) diff --git a/tests/components/prosegur/test_init.py b/tests/components/prosegur/test_init.py index cf689ba6526..ad81a52b856 100644 --- a/tests/components/prosegur/test_init.py +++ b/tests/components/prosegur/test_init.py @@ -64,7 +64,6 @@ async def test_unload_entry(hass, aioclient_mock): "homeassistant.components.prosegur.config_flow.Installation.retrieve", return_value=install, ): - assert await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() diff --git a/tests/components/radiotherm/test_config_flow.py b/tests/components/radiotherm/test_config_flow.py index 862b7b30032..cc8abef93e2 100644 --- a/tests/components/radiotherm/test_config_flow.py +++ b/tests/components/radiotherm/test_config_flow.py @@ -106,7 +106,6 @@ async def test_import(hass): "homeassistant.components.radiotherm.async_setup_entry", return_value=True, ) as mock_setup_entry: - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, diff --git a/tests/components/recorder/test_migrate.py b/tests/components/recorder/test_migrate.py index d04d436f72c..9cf7c1d7c09 100644 --- a/tests/components/recorder/test_migrate.py +++ b/tests/components/recorder/test_migrate.py @@ -195,7 +195,10 @@ async def test_events_during_migration_are_queued(hass): assert recorder.util.async_migration_in_progress(hass) is False - with patch("homeassistant.components.recorder.ALLOW_IN_MEMORY_DB", True,), patch( + with patch( + "homeassistant.components.recorder.ALLOW_IN_MEMORY_DB", + True, + ), patch( "homeassistant.components.recorder.core.create_engine", new=create_engine_test, ): diff --git a/tests/components/repairs/test_websocket_api.py b/tests/components/repairs/test_websocket_api.py index 206cedbe6a5..d35591b660a 100644 --- a/tests/components/repairs/test_websocket_api.py +++ b/tests/components/repairs/test_websocket_api.py @@ -92,7 +92,7 @@ class MockFixFlow(RepairsFlow): assert self.issue_id in EXPECTED_DATA assert self.data == EXPECTED_DATA[self.issue_id] - return await (self.async_step_custom_step()) + return await self.async_step_custom_step() async def async_step_custom_step( self, user_input: dict[str, str] | None = None diff --git a/tests/components/roon/test_config_flow.py b/tests/components/roon/test_config_flow.py index 32810d22789..5698d1de31c 100644 --- a/tests/components/roon/test_config_flow.py +++ b/tests/components/roon/test_config_flow.py @@ -81,7 +81,6 @@ async def test_successful_discovery_and_auth(hass): "homeassistant.components.roon.async_setup_entry", return_value=True, ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) @@ -120,7 +119,6 @@ async def test_unsuccessful_discovery_user_form_and_auth(hass): "homeassistant.components.roon.async_setup_entry", return_value=True, ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) @@ -165,7 +163,6 @@ async def test_duplicate_config(hass): "homeassistant.components.roon.config_flow.RoonDiscovery", return_value=RoonDiscoveryFailedMock(), ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) @@ -207,7 +204,6 @@ async def test_successful_discovery_no_auth(hass): "homeassistant.components.roon.async_setup_entry", return_value=True, ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) @@ -239,7 +235,6 @@ async def test_unexpected_exception(hass): "homeassistant.components.roon.async_setup_entry", return_value=True, ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) diff --git a/tests/components/samsungtv/test_config_flow.py b/tests/components/samsungtv/test_config_flow.py index 6679f1d786e..943f91eec1e 100644 --- a/tests/components/samsungtv/test_config_flow.py +++ b/tests/components/samsungtv/test_config_flow.py @@ -822,7 +822,6 @@ async def test_ssdp_not_successful(hass: HomeAssistant) -> None: "homeassistant.components.samsungtv.bridge.SamsungTVWSBridge.async_device_info", return_value=MOCK_DEVICE_INFO, ): - # confirm to add the entry result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA @@ -851,7 +850,6 @@ async def test_ssdp_not_successful_2(hass: HomeAssistant) -> None: "homeassistant.components.samsungtv.bridge.SamsungTVWSBridge.async_device_info", return_value=MOCK_DEVICE_INFO, ): - # confirm to add the entry result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA @@ -874,7 +872,6 @@ async def test_ssdp_already_in_progress(hass: HomeAssistant) -> None: "homeassistant.components.samsungtv.bridge.SamsungTVWSBridge.async_device_info", return_value=MOCK_DEVICE_INFO, ): - # confirm to add the entry result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA @@ -897,7 +894,6 @@ async def test_ssdp_already_configured(hass: HomeAssistant) -> None: "homeassistant.components.samsungtv.bridge.SamsungTVWSBridge.async_device_info", return_value=MOCK_DEVICE_INFO, ): - # entry was added result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA diff --git a/tests/components/samsungtv/test_media_player.py b/tests/components/samsungtv/test_media_player.py index aec072ab448..b9fa2202afa 100644 --- a/tests/components/samsungtv/test_media_player.py +++ b/tests/components/samsungtv/test_media_player.py @@ -292,7 +292,6 @@ async def test_update_off(hass: HomeAssistant, mock_now: datetime) -> None: "homeassistant.components.samsungtv.bridge.Remote", side_effect=[OSError("Boom"), DEFAULT_MOCK], ): - next_update = mock_now + timedelta(minutes=5) with patch("homeassistant.util.dt.utcnow", return_value=next_update): async_fire_time_changed(hass, next_update) @@ -526,7 +525,6 @@ async def test_update_unhandled_response( "homeassistant.components.samsungtv.bridge.Remote", side_effect=[exceptions.UnhandledResponse("Boom"), DEFAULT_MOCK], ): - next_update = mock_now + timedelta(minutes=5) with patch("homeassistant.util.dt.utcnow", return_value=next_update): async_fire_time_changed(hass, next_update) @@ -547,7 +545,6 @@ async def test_connection_closed_during_update_can_recover( "homeassistant.components.samsungtv.bridge.Remote", side_effect=[exceptions.ConnectionClosed(), DEFAULT_MOCK], ): - next_update = mock_now + timedelta(minutes=5) with patch("homeassistant.util.dt.utcnow", return_value=next_update): async_fire_time_changed(hass, next_update) diff --git a/tests/components/scrape/test_config_flow.py b/tests/components/scrape/test_config_flow.py index f6df8a80f21..e12a7c15a0c 100644 --- a/tests/components/scrape/test_config_flow.py +++ b/tests/components/scrape/test_config_flow.py @@ -131,7 +131,10 @@ async def test_flow_fails(hass: HomeAssistant, get_data: MockRestData) -> None: assert result2["errors"] == {"base": "resource_error"} - with patch("homeassistant.components.rest.RestData", return_value=get_data,), patch( + with patch( + "homeassistant.components.rest.RestData", + return_value=get_data, + ), patch( "homeassistant.components.scrape.async_setup_entry", return_value=True, ): diff --git a/tests/components/script/test_blueprint.py b/tests/components/script/test_blueprint.py index 48bdd294420..8368eb06140 100644 --- a/tests/components/script/test_blueprint.py +++ b/tests/components/script/test_blueprint.py @@ -78,7 +78,6 @@ async def test_confirmable_notification(hass: HomeAssistant) -> None: with patch( "homeassistant.components.mobile_app.device_action.async_call_action_from_config" ) as mock_call_action: - # Trigger script await hass.services.async_call(script.DOMAIN, "confirm", context=context) diff --git a/tests/components/senseme/__init__.py b/tests/components/senseme/__init__.py index 8c9a7669889..43d586328bb 100644 --- a/tests/components/senseme/__init__.py +++ b/tests/components/senseme/__init__.py @@ -119,7 +119,6 @@ def _patch_discovery(device=None, no_device=None): @contextmanager def _patcher(): - with patch.object(config_flow, "DISCOVER_TIMEOUT", 0), patch( "homeassistant.components.senseme.discovery.SensemeDiscovery", return_value=mock_senseme_discovery, diff --git a/tests/components/shelly/test_config_flow.py b/tests/components/shelly/test_config_flow.py index cfdfbab1b49..5c444541526 100644 --- a/tests/components/shelly/test_config_flow.py +++ b/tests/components/shelly/test_config_flow.py @@ -327,7 +327,6 @@ async def test_user_setup_ignored_device(hass, mock_block_device): "homeassistant.components.shelly.async_setup_entry", return_value=True, ) as mock_setup_entry: - result2 = await hass.config_entries.flow.async_configure( result["flow_id"], {"host": "1.1.1.1"}, diff --git a/tests/components/shelly/test_init.py b/tests/components/shelly/test_init.py index 707e8d5cfb1..57b756402ec 100644 --- a/tests/components/shelly/test_init.py +++ b/tests/components/shelly/test_init.py @@ -184,7 +184,6 @@ async def test_entry_unload_not_connected(hass, mock_rpc_device, monkeypatch): with patch( "homeassistant.components.shelly.coordinator.async_stop_scanner" ) as mock_stop_scanner: - entry = await init_integration( hass, 2, options={CONF_BLE_SCANNER_MODE: BLEScannerMode.ACTIVE} ) @@ -211,7 +210,6 @@ async def test_entry_unload_not_connected_but_we_think_we_are( "homeassistant.components.shelly.coordinator.async_stop_scanner", side_effect=DeviceConnectionError, ) as mock_stop_scanner: - entry = await init_integration( hass, 2, options={CONF_BLE_SCANNER_MODE: BLEScannerMode.ACTIVE} ) diff --git a/tests/components/sleepiq/test_config_flow.py b/tests/components/sleepiq/test_config_flow.py index 3e944ec69f8..44ea613ed3a 100644 --- a/tests/components/sleepiq/test_config_flow.py +++ b/tests/components/sleepiq/test_config_flow.py @@ -84,7 +84,6 @@ async def test_success(hass: HomeAssistant) -> None: "homeassistant.components.sleepiq.async_setup_entry", return_value=True, ) as mock_setup_entry: - result2 = await hass.config_entries.flow.async_configure( result["flow_id"], SLEEPIQ_CONFIG ) diff --git a/tests/components/sma/test_config_flow.py b/tests/components/sma/test_config_flow.py index eeaa0d75f07..3fbcd2c0ed0 100644 --- a/tests/components/sma/test_config_flow.py +++ b/tests/components/sma/test_config_flow.py @@ -128,7 +128,6 @@ async def test_form_already_configured(hass, mock_config_entry): ), patch( "pysma.SMA.close_session", return_value=True ), _patch_async_setup_entry() as mock_setup_entry: - result = await hass.config_entries.flow.async_configure( result["flow_id"], MOCK_USER_INPUT, diff --git a/tests/components/smappee/test_config_flow.py b/tests/components/smappee/test_config_flow.py index b29207afbca..06c90b0c54d 100644 --- a/tests/components/smappee/test_config_flow.py +++ b/tests/components/smappee/test_config_flow.py @@ -538,7 +538,10 @@ async def test_full_zeroconf_flow_next_generation(hass): """Test the full zeroconf flow.""" with patch( "pysmappee.mqtt.SmappeeLocalMqtt.start_attempt", return_value=True - ), patch("pysmappee.mqtt.SmappeeLocalMqtt.start", return_value=None,), patch( + ), patch( + "pysmappee.mqtt.SmappeeLocalMqtt.start", + return_value=None, + ), patch( "pysmappee.mqtt.SmappeeLocalMqtt.is_config_ready", return_value=None, ): diff --git a/tests/components/smartthings/test_config_flow.py b/tests/components/smartthings/test_config_flow.py index 93b646c44dc..5c277b38c9c 100644 --- a/tests/components/smartthings/test_config_flow.py +++ b/tests/components/smartthings/test_config_flow.py @@ -363,7 +363,6 @@ async def test_entry_created_with_cloudhook( "async_create_cloudhook", AsyncMock(return_value="http://cloud.test"), ) as mock_create_cloudhook: - await smartapp.setup_smartapp_endpoint(hass) # Webhook confirmation shown diff --git a/tests/components/sonarr/test_sensor.py b/tests/components/sonarr/test_sensor.py index 9240e99d3e0..c00236c54e6 100644 --- a/tests/components/sonarr/test_sensor.py +++ b/tests/components/sonarr/test_sensor.py @@ -42,7 +42,7 @@ async def test_sensors( await hass.config_entries.async_setup(mock_config_entry.entry_id) await hass.async_block_till_done() - for (unique, oid) in sensors.items(): + for unique, oid in sensors.items(): entity = registry.async_get(f"sensor.{oid}") assert entity assert entity.unique_id == f"{mock_config_entry.entry_id}_{unique}" diff --git a/tests/components/sql/test_sensor.py b/tests/components/sql/test_sensor.py index fdcf8fe1a5b..d586ccbe3b1 100644 --- a/tests/components/sql/test_sensor.py +++ b/tests/components/sql/test_sensor.py @@ -202,7 +202,9 @@ async def test_invalid_url_on_update( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - with patch("homeassistant.components.recorder",), patch( + with patch( + "homeassistant.components.recorder", + ), patch( "homeassistant.components.sql.sensor.sqlalchemy.engine.cursor.CursorResult", side_effect=SQLAlchemyError( "sqlite://homeassistant:hunter2@homeassistant.local" diff --git a/tests/components/squeezebox/test_config_flow.py b/tests/components/squeezebox/test_config_flow.py index a36abcc77aa..afe46ffdef5 100644 --- a/tests/components/squeezebox/test_config_flow.py +++ b/tests/components/squeezebox/test_config_flow.py @@ -37,7 +37,10 @@ async def patch_async_query_unauthorized(self, *args): async def test_user_form(hass): """Test user-initiated flow, including discovery and the edit step.""" - with patch("pysqueezebox.Server.async_query", return_value={"uuid": UUID},), patch( + with patch( + "pysqueezebox.Server.async_query", + return_value={"uuid": UUID}, + ), patch( "homeassistant.components.squeezebox.async_setup_entry", return_value=True, ) as mock_setup_entry, patch( @@ -191,7 +194,10 @@ async def test_discovery_no_uuid(hass): async def test_dhcp_discovery(hass): """Test we can process discovery from dhcp.""" - with patch("pysqueezebox.Server.async_query", return_value={"uuid": UUID},), patch( + with patch( + "pysqueezebox.Server.async_query", + return_value={"uuid": UUID}, + ), patch( "homeassistant.components.squeezebox.config_flow.async_discover", mock_discover ): result = await hass.config_entries.flow.async_init( diff --git a/tests/components/srp_energy/__init__.py b/tests/components/srp_energy/__init__.py index c3966e940b0..682a43c4429 100644 --- a/tests/components/srp_energy/__init__.py +++ b/tests/components/srp_energy/__init__.py @@ -47,7 +47,6 @@ async def init_integration( ), patch("srpenergy.client.SrpEnergyClient.usage", return_value=usage), patch( "homeassistant.components.srp_energy.SrpEnergyClient.usage", return_value=usage ): - config_entry.add_to_hass(hass) await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() diff --git a/tests/components/srp_energy/test_config_flow.py b/tests/components/srp_energy/test_config_flow.py index 6eac5298ae4..21d808fef5d 100644 --- a/tests/components/srp_energy/test_config_flow.py +++ b/tests/components/srp_energy/test_config_flow.py @@ -24,7 +24,6 @@ async def test_form(hass): "homeassistant.components.srp_energy.async_setup_entry", return_value=True, ) as mock_setup_entry: - result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input=ENTRY_CONFIG, diff --git a/tests/components/subaru/conftest.py b/tests/components/subaru/conftest.py index 20d70a7d496..94b803fea01 100644 --- a/tests/components/subaru/conftest.py +++ b/tests/components/subaru/conftest.py @@ -105,7 +105,10 @@ async def setup_subaru_config_entry( MOCK_API_CONNECT, return_value=connect_effect is None, side_effect=connect_effect, - ), patch(MOCK_API_GET_VEHICLES, return_value=vehicle_list,), patch( + ), patch( + MOCK_API_GET_VEHICLES, + return_value=vehicle_list, + ), patch( MOCK_API_VIN_TO_NAME, return_value=vehicle_data[VEHICLE_NAME], ), patch( diff --git a/tests/components/subaru/test_config_flow.py b/tests/components/subaru/test_config_flow.py index 0a48c736ef7..7b290a4df1b 100644 --- a/tests/components/subaru/test_config_flow.py +++ b/tests/components/subaru/test_config_flow.py @@ -257,7 +257,9 @@ async def test_pin_form_init(pin_form): async def test_pin_form_bad_pin_format(hass, pin_form): """Test we handle invalid pin.""" - with patch(MOCK_API_TEST_PIN,) as mock_test_pin, patch( + with patch( + MOCK_API_TEST_PIN, + ) as mock_test_pin, patch( MOCK_API_UPDATE_SAVED_PIN, return_value=True, ) as mock_update_saved_pin: @@ -272,7 +274,10 @@ async def test_pin_form_bad_pin_format(hass, pin_form): async def test_pin_form_success(hass, pin_form): """Test successful PIN entry.""" - with patch(MOCK_API_TEST_PIN, return_value=True,) as mock_test_pin, patch( + with patch( + MOCK_API_TEST_PIN, + return_value=True, + ) as mock_test_pin, patch( MOCK_API_UPDATE_SAVED_PIN, return_value=True, ) as mock_update_saved_pin, patch( diff --git a/tests/components/subaru/test_init.py b/tests/components/subaru/test_init.py index 46a8b2e103b..1e3b3d6743e 100644 --- a/tests/components/subaru/test_init.py +++ b/tests/components/subaru/test_init.py @@ -122,7 +122,10 @@ async def test_update_skip_unsubscribed(hass, subaru_config_entry): async def test_update_disabled(hass, ev_entry): """Test update function disable option.""" - with patch(MOCK_API_FETCH, side_effect=SubaruException("403 Error"),), patch( + with patch( + MOCK_API_FETCH, + side_effect=SubaruException("403 Error"), + ), patch( MOCK_API_UPDATE, ) as mock_update: await hass.services.async_call( diff --git a/tests/components/switchbee/test_config_flow.py b/tests/components/switchbee/test_config_flow.py index 1745d6c5d40..80bdb18a874 100644 --- a/tests/components/switchbee/test_config_flow.py +++ b/tests/components/switchbee/test_config_flow.py @@ -35,7 +35,6 @@ async def test_form(hass): ), patch( "switchbee.api.polling.CentralUnitPolling._login", return_value=None ): - result2 = await hass.config_entries.flow.async_configure( result["flow_id"], { diff --git a/tests/components/synology_dsm/test_config_flow.py b/tests/components/synology_dsm/test_config_flow.py index 6ce4851fb09..38a3cc55f36 100644 --- a/tests/components/synology_dsm/test_config_flow.py +++ b/tests/components/synology_dsm/test_config_flow.py @@ -65,7 +65,6 @@ from tests.common import MockConfigEntry def mock_controller_service(): """Mock a successful service.""" with patch("homeassistant.components.synology_dsm.config_flow.SynologyDSM") as dsm: - dsm.login = AsyncMock(return_value=True) dsm.update = AsyncMock(return_value=True) @@ -109,7 +108,6 @@ def mock_controller_service_2sa(): def mock_controller_service_vdsm(): """Mock a successful service.""" with patch("homeassistant.components.synology_dsm.config_flow.SynologyDSM") as dsm: - dsm.login = AsyncMock(return_value=True) dsm.update = AsyncMock(return_value=True) @@ -131,7 +129,6 @@ def mock_controller_service_vdsm(): def mock_controller_service_failed(): """Mock a failed service.""" with patch("homeassistant.components.synology_dsm.config_flow.SynologyDSM") as dsm: - dsm.login = AsyncMock(return_value=True) dsm.update = AsyncMock(return_value=True) @@ -333,7 +330,6 @@ async def test_reauth(hass: HomeAssistant, service: MagicMock): "homeassistant.config_entries.ConfigEntries.async_reload", return_value=True, ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={ diff --git a/tests/components/tankerkoenig/test_config_flow.py b/tests/components/tankerkoenig/test_config_flow.py index 266f9b67376..0f814f494f7 100644 --- a/tests/components/tankerkoenig/test_config_flow.py +++ b/tests/components/tankerkoenig/test_config_flow.py @@ -146,7 +146,6 @@ async def test_exception_security(hass: HomeAssistant): "homeassistant.components.tankerkoenig.config_flow.getNearbyStations", side_effect=customException, ): - result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input=MOCK_USER_DATA ) diff --git a/tests/components/tibber/test_statistics.py b/tests/components/tibber/test_statistics.py index 661297f9a37..002f8b7d15a 100644 --- a/tests/components/tibber/test_statistics.py +++ b/tests/components/tibber/test_statistics.py @@ -22,7 +22,7 @@ async def test_async_setup_entry(recorder_mock, hass): await coordinator._async_update_data() await async_wait_recording_done(hass) - for (statistic_id, data, key) in ( + for statistic_id, data, key in ( ("tibber:energy_consumption_home_id", CONSUMPTION_DATA_1, "consumption"), ("tibber:energy_totalcost_home_id", CONSUMPTION_DATA_1, "totalCost"), ("tibber:energy_production_home_id", PRODUCTION_DATA_1, "production"), diff --git a/tests/components/totalconnect/test_config_flow.py b/tests/components/totalconnect/test_config_flow.py index 5e5124db71c..eb8e1af0d9c 100644 --- a/tests/components/totalconnect/test_config_flow.py +++ b/tests/components/totalconnect/test_config_flow.py @@ -54,10 +54,12 @@ async def test_user_show_locations(hass): RESPONSE_SUCCESS, ] - with patch(TOTALCONNECT_REQUEST, side_effect=responses,) as mock_request, patch( + with patch( + TOTALCONNECT_REQUEST, + side_effect=responses, + ) as mock_request, patch( "homeassistant.components.totalconnect.async_setup_entry", return_value=True ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, @@ -178,13 +180,15 @@ async def test_no_locations(hass): RESPONSE_DISARMED, ] - with patch(TOTALCONNECT_REQUEST, side_effect=responses,) as mock_request, patch( + with patch( + TOTALCONNECT_REQUEST, + side_effect=responses, + ) as mock_request, patch( "homeassistant.components.totalconnect.async_setup_entry", return_value=True ), patch( "homeassistant.components.totalconnect.TotalConnectClient.get_number_locations", return_value=0, ): - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, diff --git a/tests/components/upnp/conftest.py b/tests/components/upnp/conftest.py index 4c125a9d6e9..0952b14303d 100644 --- a/tests/components/upnp/conftest.py +++ b/tests/components/upnp/conftest.py @@ -141,6 +141,7 @@ async def silent_ssdp_scanner(hass): @pytest.fixture async def ssdp_instant_discovery(): """Instance discovery.""" + # Set up device discovery callback. async def register_callback(hass, callback, match_dict): """Immediately do callback.""" @@ -160,6 +161,7 @@ async def ssdp_instant_discovery(): @pytest.fixture async def ssdp_no_discovery(): """No discovery.""" + # Set up device discovery callback. async def register_callback(hass, callback, match_dict): """Don't do callback.""" diff --git a/tests/components/uptimerobot/common.py b/tests/components/uptimerobot/common.py index 2003f411358..6a82d75a9f8 100644 --- a/tests/components/uptimerobot/common.py +++ b/tests/components/uptimerobot/common.py @@ -110,7 +110,6 @@ async def setup_uptimerobot_integration(hass: HomeAssistant) -> MockConfigEntry: "pyuptimerobot.UptimeRobot.async_get_monitors", return_value=mock_uptimerobot_api_response(data=[MOCK_UPTIMEROBOT_MONITOR]), ): - assert await hass.config_entries.async_setup(mock_entry.entry_id) await hass.async_block_till_done() diff --git a/tests/components/uptimerobot/test_config_flow.py b/tests/components/uptimerobot/test_config_flow.py index 10919ecbe30..7ff958bcd82 100644 --- a/tests/components/uptimerobot/test_config_flow.py +++ b/tests/components/uptimerobot/test_config_flow.py @@ -182,7 +182,6 @@ async def test_reauthentication( "homeassistant.components.uptimerobot.async_setup_entry", return_value=True, ): - result2 = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_API_KEY: MOCK_UPTIMEROBOT_API_KEY}, @@ -221,7 +220,6 @@ async def test_reauthentication_failure( "homeassistant.components.uptimerobot.async_setup_entry", return_value=True, ): - result2 = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_API_KEY: MOCK_UPTIMEROBOT_API_KEY}, @@ -263,7 +261,6 @@ async def test_reauthentication_failure_no_existing_entry( "homeassistant.components.uptimerobot.async_setup_entry", return_value=True, ): - result2 = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_API_KEY: MOCK_UPTIMEROBOT_API_KEY}, @@ -305,7 +302,6 @@ async def test_reauthentication_failure_account_not_matching( "homeassistant.components.uptimerobot.async_setup_entry", return_value=True, ): - result2 = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_API_KEY: MOCK_UPTIMEROBOT_API_KEY}, diff --git a/tests/components/uptimerobot/test_diagnostics.py b/tests/components/uptimerobot/test_diagnostics.py index a0780f64e90..ae7371f8e90 100644 --- a/tests/components/uptimerobot/test_diagnostics.py +++ b/tests/components/uptimerobot/test_diagnostics.py @@ -33,7 +33,6 @@ async def test_entry_diagnostics( data=MOCK_UPTIMEROBOT_ACCOUNT, ), ): - result = await get_diagnostics_for_config_entry( hass, hass_client, @@ -68,7 +67,6 @@ async def test_entry_diagnostics_exception( "pyuptimerobot.UptimeRobot.async_get_account_details", side_effect=UptimeRobotException("Test exception"), ): - result = await get_diagnostics_for_config_entry( hass, hass_client, diff --git a/tests/components/uptimerobot/test_init.py b/tests/components/uptimerobot/test_init.py index 8a44de02fc1..0d849242418 100644 --- a/tests/components/uptimerobot/test_init.py +++ b/tests/components/uptimerobot/test_init.py @@ -38,7 +38,6 @@ async def test_reauthentication_trigger_in_setup( "pyuptimerobot.UptimeRobot.async_get_monitors", side_effect=UptimeRobotAuthenticationException, ): - await hass.config_entries.async_setup(mock_config_entry.entry_id) await hass.async_block_till_done() @@ -107,7 +106,6 @@ async def test_reauthentication_trigger_after_setup( "pyuptimerobot.UptimeRobot.async_get_monitors", side_effect=UptimeRobotAuthenticationException, ): - async_fire_time_changed(hass, dt.utcnow() + COORDINATOR_UPDATE_INTERVAL) await hass.async_block_till_done() diff --git a/tests/components/uptimerobot/test_switch.py b/tests/components/uptimerobot/test_switch.py index 82ea06ce836..4560909d3e4 100644 --- a/tests/components/uptimerobot/test_switch.py +++ b/tests/components/uptimerobot/test_switch.py @@ -53,7 +53,6 @@ async def test_switch_off(hass: HomeAssistant) -> None: "pyuptimerobot.UptimeRobot.async_edit_monitor", return_value=mock_uptimerobot_api_response(), ): - assert await hass.config_entries.async_setup(mock_entry.entry_id) await hass.async_block_till_done() @@ -81,7 +80,6 @@ async def test_switch_on(hass: HomeAssistant) -> None: "pyuptimerobot.UptimeRobot.async_edit_monitor", return_value=mock_uptimerobot_api_response(), ): - assert await hass.config_entries.async_setup(mock_entry.entry_id) await hass.async_block_till_done() diff --git a/tests/components/vera/test_sensor.py b/tests/components/vera/test_sensor.py index b6641402c83..9ddf05a5b0a 100644 --- a/tests/components/vera/test_sensor.py +++ b/tests/components/vera/test_sensor.py @@ -40,7 +40,7 @@ async def run_sensor_test( ) update_callback = component_data.controller_data[0].update_callback - for (initial_value, state_value) in assert_states: + for initial_value, state_value in assert_states: setattr(vera_device, class_property, initial_value) update_callback(vera_device) await hass.async_block_till_done() diff --git a/tests/components/version/common.py b/tests/components/version/common.py index b210a8600b8..a6b554d780d 100644 --- a/tests/components/version/common.py +++ b/tests/components/version/common.py @@ -47,7 +47,6 @@ async def mock_get_version_update( return_value=(version, data), side_effect=side_effect, ): - async_fire_time_changed(hass, dt.utcnow() + UPDATE_COORDINATOR_UPDATE_INTERVAL) await hass.async_block_till_done() @@ -69,7 +68,6 @@ async def setup_version_integration( "pyhaversion.HaVersion.get_version", return_value=(MOCK_VERSION, MOCK_VERSION_DATA), ): - assert await hass.config_entries.async_setup(mock_entry.entry_id) await hass.async_block_till_done() diff --git a/tests/components/vulcan/test_config_flow.py b/tests/components/vulcan/test_config_flow.py index c45ab430c2e..3e6588c1caf 100644 --- a/tests/components/vulcan/test_config_flow.py +++ b/tests/components/vulcan/test_config_flow.py @@ -209,7 +209,6 @@ async def test_config_flow_reauth_with_errors(mock_account, mock_keystore, hass) "homeassistant.components.vulcan.config_flow.Account.register", side_effect=InvalidTokenException, ): - result = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_TOKEN: "token", CONF_REGION: "region", CONF_PIN: "000000"}, @@ -223,7 +222,6 @@ async def test_config_flow_reauth_with_errors(mock_account, mock_keystore, hass) "homeassistant.components.vulcan.config_flow.Account.register", side_effect=ExpiredTokenException, ): - result = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_TOKEN: "token", CONF_REGION: "region", CONF_PIN: "000000"}, @@ -237,7 +235,6 @@ async def test_config_flow_reauth_with_errors(mock_account, mock_keystore, hass) "homeassistant.components.vulcan.config_flow.Account.register", side_effect=InvalidPINException, ): - result = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_TOKEN: "token", CONF_REGION: "region", CONF_PIN: "000000"}, @@ -251,7 +248,6 @@ async def test_config_flow_reauth_with_errors(mock_account, mock_keystore, hass) "homeassistant.components.vulcan.config_flow.Account.register", side_effect=InvalidSymbolException, ): - result = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_TOKEN: "token", CONF_REGION: "region", CONF_PIN: "000000"}, @@ -265,7 +261,6 @@ async def test_config_flow_reauth_with_errors(mock_account, mock_keystore, hass) "homeassistant.components.vulcan.config_flow.Account.register", side_effect=ClientConnectionError, ): - result = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_TOKEN: "token", CONF_REGION: "region", CONF_PIN: "000000"}, @@ -279,7 +274,6 @@ async def test_config_flow_reauth_with_errors(mock_account, mock_keystore, hass) "homeassistant.components.vulcan.config_flow.Account.register", side_effect=Exception, ): - result = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_TOKEN: "token", CONF_REGION: "region", CONF_PIN: "000000"}, diff --git a/tests/components/vultr/test_binary_sensor.py b/tests/components/vultr/test_binary_sensor.py index 80cd198e371..899b36e59b1 100644 --- a/tests/components/vultr/test_binary_sensor.py +++ b/tests/components/vultr/test_binary_sensor.py @@ -41,7 +41,6 @@ def test_binary_sensor(hass: HomeAssistant): assert len(hass_devices) == 3 for device in hass_devices: - # Test pre data retrieval if device.subscription == "555555": assert device.name == "Vultr {}" diff --git a/tests/components/vultr/test_sensor.py b/tests/components/vultr/test_sensor.py index f3b21bd446b..7610a44a53d 100644 --- a/tests/components/vultr/test_sensor.py +++ b/tests/components/vultr/test_sensor.py @@ -51,7 +51,6 @@ def test_sensor(hass: HomeAssistant): tested = 0 for device in hass_devices: - # Test pre update if device.subscription == "576965": assert device.name == vultr.DEFAULT_NAME @@ -74,7 +73,6 @@ def test_sensor(hass: HomeAssistant): tested += 1 elif device.unit_of_measurement == "US$": # Test Pending Charges - if device.subscription == "576965": # Default 'Vultr {} {}' assert device.name == "Vultr my new server Pending Charges" assert device.icon == "mdi:currency-usd" diff --git a/tests/components/wake_on_lan/test_switch.py b/tests/components/wake_on_lan/test_switch.py index b73f5223576..8a7fe185662 100644 --- a/tests/components/wake_on_lan/test_switch.py +++ b/tests/components/wake_on_lan/test_switch.py @@ -39,7 +39,6 @@ async def test_valid_hostname( assert state.state == STATE_OFF with patch.object(subprocess, "call", return_value=0): - await hass.services.async_call( switch.DOMAIN, SERVICE_TURN_ON, @@ -87,7 +86,6 @@ async def test_broadcast_config_ip_and_port( assert state.state == STATE_OFF with patch.object(subprocess, "call", return_value=0): - await hass.services.async_call( switch.DOMAIN, SERVICE_TURN_ON, @@ -125,7 +123,6 @@ async def test_broadcast_config_ip( assert state.state == STATE_OFF with patch.object(subprocess, "call", return_value=0): - await hass.services.async_call( switch.DOMAIN, SERVICE_TURN_ON, @@ -155,7 +152,6 @@ async def test_broadcast_config_port( assert state.state == STATE_OFF with patch.object(subprocess, "call", return_value=0): - await hass.services.async_call( switch.DOMAIN, SERVICE_TURN_ON, @@ -190,7 +186,6 @@ async def test_off_script( assert state.state == STATE_OFF with patch.object(subprocess, "call", return_value=0): - await hass.services.async_call( switch.DOMAIN, SERVICE_TURN_ON, @@ -203,7 +198,6 @@ async def test_off_script( assert len(calls) == 0 with patch.object(subprocess, "call", return_value=2): - await hass.services.async_call( switch.DOMAIN, SERVICE_TURN_OFF, @@ -237,7 +231,6 @@ async def test_no_hostname_state( assert state.state == STATE_OFF with patch.object(subprocess, "call", return_value=0): - await hass.services.async_call( switch.DOMAIN, SERVICE_TURN_ON, diff --git a/tests/components/wallbox/test_number.py b/tests/components/wallbox/test_number.py index c16c85d3696..eb11c4fc0cc 100644 --- a/tests/components/wallbox/test_number.py +++ b/tests/components/wallbox/test_number.py @@ -65,7 +65,6 @@ async def test_wallbox_number_class_connection_error(hass: HomeAssistant) -> Non ) with pytest.raises(ConnectionError): - await hass.services.async_call( "number", SERVICE_SET_VALUE, diff --git a/tests/components/whirlpool/test_config_flow.py b/tests/components/whirlpool/test_config_flow.py index ad6620dc057..d408ac1d15e 100644 --- a/tests/components/whirlpool/test_config_flow.py +++ b/tests/components/whirlpool/test_config_flow.py @@ -198,7 +198,6 @@ async def test_no_appliances_flow(hass: HomeAssistant, region) -> None: "homeassistant.components.whirlpool.config_flow.AppliancesManager.fetch_appliances", return_value=True, ): - result2 = await hass.config_entries.flow.async_configure( result["flow_id"], CONFIG_INPUT | {"region": region[0]}, diff --git a/tests/components/wolflink/test_config_flow.py b/tests/components/wolflink/test_config_flow.py index 9a6105a4b8b..e09d6821362 100644 --- a/tests/components/wolflink/test_config_flow.py +++ b/tests/components/wolflink/test_config_flow.py @@ -124,7 +124,6 @@ async def test_already_configured_error(hass): "homeassistant.components.wolflink.config_flow.WolfClient.fetch_system_list", return_value=[DEVICE], ), patch("homeassistant.components.wolflink.async_setup_entry", return_value=True): - MockConfigEntry( domain=DOMAIN, unique_id=CONFIG[DEVICE_ID], data=CONFIG ).add_to_hass(hass) diff --git a/tests/components/ws66i/test_config_flow.py b/tests/components/ws66i/test_config_flow.py index da5a16882e8..ec09419e7f8 100644 --- a/tests/components/ws66i/test_config_flow.py +++ b/tests/components/ws66i/test_config_flow.py @@ -36,7 +36,6 @@ async def test_form(hass): "homeassistant.components.ws66i.async_setup_entry", return_value=True, ) as mock_setup_entry: - ws66i_instance = mock_ws66i.return_value result2 = await hass.config_entries.flow.async_configure( diff --git a/tests/components/yeelight/test_config_flow.py b/tests/components/yeelight/test_config_flow.py index 391c969d893..44fa1263a6c 100644 --- a/tests/components/yeelight/test_config_flow.py +++ b/tests/components/yeelight/test_config_flow.py @@ -844,7 +844,6 @@ async def test_discovered_during_onboarding(hass, source, data): ) as mock_async_setup_entry, patch( "homeassistant.components.onboarding.async_is_onboarded", return_value=False ) as mock_is_onboarded: - result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": source}, data=data ) diff --git a/tests/components/zeroconf/test_init.py b/tests/components/zeroconf/test_init.py index 5e499c93fff..5175c9715da 100644 --- a/tests/components/zeroconf/test_init.py +++ b/tests/components/zeroconf/test_init.py @@ -157,7 +157,11 @@ async def test_setup(hass, mock_async_zeroconf): ], "_Volumio._tcp.local.": [{"domain": "volumio"}], } - with patch.dict(zc_gen.ZEROCONF, mock_zc, clear=True,), patch.object( + with patch.dict( + zc_gen.ZEROCONF, + mock_zc, + clear=True, + ), patch.object( hass.config_entries.flow, "async_init" ) as mock_config_flow, patch.object( zeroconf, "HaAsyncServiceBrowser", side_effect=service_update_mock @@ -530,7 +534,11 @@ async def test_homekit_match_partial_space(hass, mock_async_zeroconf): zc_gen.ZEROCONF, {"_hap._tcp.local.": [{"domain": "homekit_controller"}]}, clear=True, - ), patch.dict(zc_gen.HOMEKIT, {"LIFX": "lifx"}, clear=True,), patch.object( + ), patch.dict( + zc_gen.HOMEKIT, + {"LIFX": "lifx"}, + clear=True, + ), patch.object( hass.config_entries.flow, "async_init" ) as mock_config_flow, patch.object( zeroconf, @@ -620,7 +628,11 @@ async def test_homekit_match_full(hass, mock_async_zeroconf): zc_gen.ZEROCONF, {"_hap._udp.local.": [{"domain": "homekit_controller"}]}, clear=True, - ), patch.dict(zc_gen.HOMEKIT, {"BSB002": "hue"}, clear=True,), patch.object( + ), patch.dict( + zc_gen.HOMEKIT, + {"BSB002": "hue"}, + clear=True, + ), patch.object( hass.config_entries.flow, "async_init" ) as mock_config_flow, patch.object( zeroconf, @@ -743,7 +755,11 @@ async def test_homekit_controller_still_discovered_unpaired_for_cloud( zc_gen.ZEROCONF, {"_hap._udp.local.": [{"domain": "homekit_controller"}]}, clear=True, - ), patch.dict(zc_gen.HOMEKIT, {"Rachio": "rachio"}, clear=True,), patch.object( + ), patch.dict( + zc_gen.HOMEKIT, + {"Rachio": "rachio"}, + clear=True, + ), patch.object( hass.config_entries.flow, "async_init" ) as mock_config_flow, patch.object( zeroconf, diff --git a/tests/components/zha/test_channels.py b/tests/components/zha/test_channels.py index 0ab905692c2..b264213d5a0 100644 --- a/tests/components/zha/test_channels.py +++ b/tests/components/zha/test_channels.py @@ -321,7 +321,7 @@ async def test_out_channel_config( def test_channel_registry(): """Test ZIGBEE Channel Registry.""" - for (cluster_id, channel) in registries.ZIGBEE_CHANNEL_REGISTRY.items(): + for cluster_id, channel in registries.ZIGBEE_CHANNEL_REGISTRY.items(): assert isinstance(cluster_id, int) assert 0 <= cluster_id <= 0xFFFF assert issubclass(channel, base_channels.ZigbeeChannel) diff --git a/tests/components/zwave_me/test_config_flow.py b/tests/components/zwave_me/test_config_flow.py index 57ead9a9e60..e3be334c3d8 100644 --- a/tests/components/zwave_me/test_config_flow.py +++ b/tests/components/zwave_me/test_config_flow.py @@ -170,7 +170,6 @@ async def test_duplicate_zeroconf(hass: HomeAssistant): "homeassistant.components.zwave_me.helpers.get_uuid", return_value="test_uuid", ): - result: FlowResult = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, diff --git a/tests/components/zwave_me/test_remove_stale_devices.py b/tests/components/zwave_me/test_remove_stale_devices.py index af35f16c310..109c84269e2 100644 --- a/tests/components/zwave_me/test_remove_stale_devices.py +++ b/tests/components/zwave_me/test_remove_stale_devices.py @@ -55,7 +55,10 @@ async def test_remove_stale_devices( connections={("mac", "12:34:56:AB:CD:EF")}, identifiers={("zwave_me", f"{config_entry.unique_id}-{identifier}")}, ) - with patch("zwave_me_ws.ZWaveMe.get_connection", mock_connection,), patch( + with patch( + "zwave_me_ws.ZWaveMe.get_connection", + mock_connection, + ), patch( "homeassistant.components.zwave_me.async_setup_platforms", ): await hass.config_entries.async_setup(config_entry.entry_id) diff --git a/tests/conftest.py b/tests/conftest.py index f586faf5677..6ae89e93243 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -351,7 +351,6 @@ def aiohttp_client( server_kwargs: dict[str, Any] | None = None, **kwargs: Any, ) -> TestClient: - if isinstance(__param, Callable) and not isinstance( # type: ignore[arg-type] __param, (Application, BaseTestServer) ): diff --git a/tests/helpers/test_config_entry_flow.py b/tests/helpers/test_config_entry_flow.py index a4a3e2b27e7..bc545a647cf 100644 --- a/tests/helpers/test_config_entry_flow.py +++ b/tests/helpers/test_config_entry_flow.py @@ -370,7 +370,6 @@ async def test_webhook_create_cloudhook(hass, webhook_flow_conf): "hass_nabucasa.cloudhooks.Cloudhooks.async_delete", return_value={"cloudhook_url": "https://example.com"}, ) as mock_delete: - result = await hass.config_entries.async_remove(result["result"].entry_id) assert len(mock_delete.mock_calls) == 1 @@ -413,7 +412,6 @@ async def test_webhook_create_cloudhook_aborts_not_connected(hass, webhook_flow_ "hass_nabucasa.iot_base.BaseIoT.connected", new_callable=PropertyMock(return_value=False), ): - result = await hass.config_entries.flow.async_configure(result["flow_id"], {}) assert result["type"] == data_entry_flow.FlowResultType.ABORT diff --git a/tests/helpers/test_device_registry.py b/tests/helpers/test_device_registry.py index 2c9a7956874..9d5c95ccaa3 100644 --- a/tests/helpers/test_device_registry.py +++ b/tests/helpers/test_device_registry.py @@ -825,7 +825,7 @@ async def test_loading_saving_data(hass, registry, area_registry): assert orig_light4 == new_light4 # Ensure enums converted - for (old, new) in ( + for old, new in ( (orig_via, new_via), (orig_light, new_light), (orig_light4, new_light4), diff --git a/tests/helpers/test_entity.py b/tests/helpers/test_entity.py index 19f5ea242b6..ac337b11b50 100644 --- a/tests/helpers/test_entity.py +++ b/tests/helpers/test_entity.py @@ -484,7 +484,6 @@ async def test_async_parallel_updates_with_two(hass): await test_lock.acquire() try: - ent_1.async_schedule_update_ha_state(True) ent_2.async_schedule_update_ha_state(True) ent_3.async_schedule_update_ha_state(True) diff --git a/tests/helpers/test_translation.py b/tests/helpers/test_translation.py index f3a8e1d1bf2..90a5280f323 100644 --- a/tests/helpers/test_translation.py +++ b/tests/helpers/test_translation.py @@ -42,7 +42,11 @@ async def test_component_translation_path(hass, enable_custom_integrations): ) assert await async_setup_component(hass, "test_package", {"test_package"}) - (int_test, int_test_embedded, int_test_package,) = await asyncio.gather( + ( + int_test, + int_test_embedded, + int_test_package, + ) = await asyncio.gather( async_get_integration(hass, "test"), async_get_integration(hass, "test_embedded"), async_get_integration(hass, "test_package"), diff --git a/tests/scripts/test_check_config.py b/tests/scripts/test_check_config.py index c565c42132a..1fe9f8a2247 100644 --- a/tests/scripts/test_check_config.py +++ b/tests/scripts/test_check_config.py @@ -107,7 +107,6 @@ def test_secrets(mock_is_file, event_loop): } with patch_yaml_files(files): - res = check_config.check(get_test_config_dir(), True) assert res["except"] == {} diff --git a/tests/test_config_entries.py b/tests/test_config_entries.py index f7e3802e3c8..353bfa64ece 100644 --- a/tests/test_config_entries.py +++ b/tests/test_config_entries.py @@ -3555,7 +3555,6 @@ async def test_initializing_flows_canceled_on_shutdown(hass: HomeAssistant, mana with patch.dict( config_entries.HANDLERS, {"comp": MockFlowHandler, "test": MockFlowHandler} ): - task = asyncio.create_task( manager.flow.async_init("test", context={"source": "reauth"}) ) diff --git a/tests/test_requirements.py b/tests/test_requirements.py index 21e119fd631..daf2c0902df 100644 --- a/tests/test_requirements.py +++ b/tests/test_requirements.py @@ -138,7 +138,6 @@ async def test_get_integration_with_requirements(hass): ) as mock_is_installed, patch( "homeassistant.util.package.install_package", return_value=True ) as mock_inst: - integration = await async_get_integration_with_requirements( hass, "test_component" ) @@ -193,7 +192,6 @@ async def test_get_integration_with_requirements_pip_install_fails_two_passes(ha ) as mock_is_installed, patch( "homeassistant.util.package.install_package", side_effect=_mock_install_package ) as mock_inst: - integration = await async_get_integration_with_requirements( hass, "test_component" ) @@ -224,7 +222,6 @@ async def test_get_integration_with_requirements_pip_install_fails_two_passes(ha ) as mock_is_installed, patch( "homeassistant.util.package.install_package", side_effect=_mock_install_package ) as mock_inst: - integration = await async_get_integration_with_requirements( hass, "test_component" ) @@ -243,7 +240,6 @@ async def test_get_integration_with_requirements_pip_install_fails_two_passes(ha ) as mock_is_installed, patch( "homeassistant.util.package.install_package", side_effect=_mock_install_package ) as mock_inst: - integration = await async_get_integration_with_requirements( hass, "test_component" ) @@ -274,7 +270,6 @@ async def test_get_integration_with_requirements_pip_install_fails_two_passes(ha ) as mock_is_installed, patch( "homeassistant.util.package.install_package", return_value=True ) as mock_inst: - integration = await async_get_integration_with_requirements( hass, "test_component" )