From 1c2ebdf307c5925f34db8688888a188c876f670c Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 27 Aug 2020 13:56:20 +0200 Subject: [PATCH] Upgrade black to 20.8b1 (#39287) --- .pre-commit-config.yaml | 2 +- homeassistant/auth/__init__.py | 4 +- homeassistant/auth/models.py | 5 +- homeassistant/bootstrap.py | 15 ++- homeassistant/components/acmeda/helpers.py | 3 +- .../components/airvisual/__init__.py | 3 +- homeassistant/components/airvisual/sensor.py | 8 +- homeassistant/components/almond/__init__.py | 6 +- .../components/androidtv/media_player.py | 3 +- .../components/arcam_fmj/config_flow.py | 3 +- .../components/arcam_fmj/media_player.py | 5 +- .../components/august/config_flow.py | 8 +- homeassistant/components/august/gateway.py | 4 +- homeassistant/components/august/sensor.py | 6 +- homeassistant/components/avri/config_flow.py | 4 +- homeassistant/components/awair/__init__.py | 4 +- homeassistant/components/awair/sensor.py | 12 +- homeassistant/components/axis/light.py | 4 +- .../components/azure_devops/__init__.py | 12 +- homeassistant/components/blink/__init__.py | 3 +- homeassistant/components/blink/config_flow.py | 11 +- .../components/broadlink/config_flow.py | 4 +- homeassistant/components/brother/__init__.py | 5 +- homeassistant/components/bsblan/climate.py | 5 +- .../components/cert_expiry/__init__.py | 5 +- .../components/cert_expiry/config_flow.py | 3 +- .../components/channels/media_player.py | 12 +- homeassistant/components/cloud/http_api.py | 5 +- homeassistant/components/control4/light.py | 6 +- .../components/coolmaster/__init__.py | 5 +- homeassistant/components/cover/__init__.py | 3 +- .../components/daikin/config_flow.py | 12 +- homeassistant/components/decora/light.py | 3 +- homeassistant/components/demo/config_flow.py | 8 +- .../components/devolo_home_control/cover.py | 4 +- homeassistant/components/directv/__init__.py | 4 +- .../components/directv/config_flow.py | 3 +- .../components/directv/media_player.py | 8 +- homeassistant/components/directv/remote.py | 8 +- homeassistant/components/eafm/config_flow.py | 3 +- homeassistant/components/elgato/__init__.py | 6 +- .../components/elgato/config_flow.py | 6 +- homeassistant/components/elgato/light.py | 5 +- homeassistant/components/elkm1/__init__.py | 4 +- homeassistant/components/emulated_hue/upnp.py | 5 +- homeassistant/components/fibaro/climate.py | 4 +- homeassistant/components/flume/__init__.py | 6 +- .../components/flunearyou/__init__.py | 4 +- .../components/forked_daapd/config_flow.py | 3 +- homeassistant/components/freebox/__init__.py | 4 +- .../components/freebox/config_flow.py | 3 +- .../components/geniushub/__init__.py | 3 +- homeassistant/components/gios/config_flow.py | 3 +- homeassistant/components/glances/sensor.py | 3 +- .../components/google_assistant/helpers.py | 6 +- homeassistant/components/group/cover.py | 5 +- homeassistant/components/guardian/switch.py | 4 +- homeassistant/components/harmony/remote.py | 4 +- .../components/hisense_aehw4a1/__init__.py | 3 +- homeassistant/components/history/__init__.py | 3 +- .../components/home_connect/__init__.py | 6 +- .../components/home_connect/switch.py | 4 +- .../homeassistant/triggers/state.py | 6 +- homeassistant/components/homekit/__init__.py | 13 ++- .../components/homekit/config_flow.py | 3 +- homeassistant/components/homekit/img_util.py | 4 +- .../components/homekit/type_cameras.py | 17 ++- .../components/homekit/type_humidifiers.py | 24 ++-- .../components/homekit/type_media_players.py | 11 +- .../components/homekit/type_thermostats.py | 5 +- .../components/homekit_controller/climate.py | 3 +- .../homekit_controller/connection.py | 3 +- .../homekit_controller/media_player.py | 3 +- homeassistant/components/honeywell/climate.py | 7 +- homeassistant/components/http/ban.py | 5 +- homeassistant/components/http/view.py | 9 +- .../components/huawei_lte/__init__.py | 8 +- homeassistant/components/huawei_lte/sensor.py | 11 +- homeassistant/components/hue/__init__.py | 6 +- homeassistant/components/hue/sensor_base.py | 4 +- homeassistant/components/image/__init__.py | 8 +- homeassistant/components/influxdb/__init__.py | 5 +- homeassistant/components/influxdb/const.py | 3 +- homeassistant/components/insteon/__init__.py | 3 +- .../components/insteon/config_flow.py | 7 +- .../components/insteon/insteon_entity.py | 5 +- homeassistant/components/ipp/__init__.py | 5 +- homeassistant/components/ipp/config_flow.py | 3 +- homeassistant/components/iqvia/__init__.py | 4 +- homeassistant/components/knx/__init__.py | 5 +- homeassistant/components/knx/factory.py | 4 +- homeassistant/components/kodi/__init__.py | 4 +- homeassistant/components/kodi/config_flow.py | 3 +- .../components/konnected/config_flow.py | 3 +- homeassistant/components/konnected/panel.py | 15 ++- homeassistant/components/light/__init__.py | 3 +- homeassistant/components/lock/__init__.py | 3 +- homeassistant/components/lovelace/__init__.py | 3 +- .../components/meteo_france/__init__.py | 7 +- .../components/meteo_france/config_flow.py | 3 +- .../components/meteo_france/sensor.py | 3 +- .../components/meteo_france/weather.py | 3 +- homeassistant/components/metoffice/weather.py | 8 +- homeassistant/components/mikrotik/hub.py | 5 +- homeassistant/components/mill/config_flow.py | 15 ++- .../components/mobile_app/webhook.py | 11 +- .../components/monoprice/config_flow.py | 5 +- homeassistant/components/mqtt/__init__.py | 26 ++++- homeassistant/components/mqtt/climate.py | 3 +- homeassistant/components/mqtt/config_flow.py | 8 +- .../components/mqtt/device_trigger.py | 10 +- homeassistant/components/mysensors/gateway.py | 3 +- homeassistant/components/nad/media_player.py | 6 +- homeassistant/components/netatmo/__init__.py | 6 +- homeassistant/components/netatmo/api.py | 4 +- homeassistant/components/netatmo/camera.py | 17 ++- homeassistant/components/netatmo/climate.py | 11 +- .../components/netatmo/config_flow.py | 13 ++- .../components/netatmo/data_handler.py | 7 +- homeassistant/components/netatmo/light.py | 13 ++- homeassistant/components/netatmo/sensor.py | 8 +- .../components/netgear/device_tracker.py | 6 +- homeassistant/components/nexia/scene.py | 4 +- homeassistant/components/nexia/sensor.py | 7 +- homeassistant/components/nuki/lock.py | 11 +- .../components/numato/binary_sensor.py | 8 +- homeassistant/components/numato/switch.py | 8 +- homeassistant/components/nut/config_flow.py | 7 +- .../components/nx584/alarm_control_panel.py | 7 +- .../components/openuv/config_flow.py | 4 +- homeassistant/components/ovo_energy/sensor.py | 3 +- homeassistant/components/ozw/services.py | 4 +- homeassistant/components/ozw/websocket_api.py | 6 +- .../components/panasonic_viera/__init__.py | 8 +- .../components/panasonic_viera/config_flow.py | 6 +- .../components/panel_custom/__init__.py | 12 +- homeassistant/components/pi_hole/__init__.py | 7 +- homeassistant/components/plex/server.py | 11 +- .../components/plum_lightpad/config_flow.py | 4 +- .../components/powerwall/__init__.py | 4 +- .../components/prometheus/__init__.py | 5 +- homeassistant/components/rachio/entity.py | 12 +- homeassistant/components/rachio/switch.py | 4 +- .../components/radiotherm/climate.py | 3 +- homeassistant/components/rainbird/switch.py | 5 +- homeassistant/components/recorder/__init__.py | 3 +- homeassistant/components/recorder/purge.py | 6 +- homeassistant/components/recorder/util.py | 4 +- homeassistant/components/rfxtrx/__init__.py | 4 +- .../components/rfxtrx/binary_sensor.py | 4 +- homeassistant/components/rfxtrx/cover.py | 4 +- homeassistant/components/rfxtrx/light.py | 4 +- homeassistant/components/rfxtrx/sensor.py | 4 +- homeassistant/components/rfxtrx/switch.py | 4 +- homeassistant/components/ring/__init__.py | 7 +- homeassistant/components/ring/camera.py | 5 +- homeassistant/components/ring/config_flow.py | 8 +- homeassistant/components/risco/__init__.py | 5 +- homeassistant/components/roku/__init__.py | 14 ++- homeassistant/components/roku/config_flow.py | 7 +- homeassistant/components/roku/media_player.py | 4 +- homeassistant/components/roomba/__init__.py | 4 +- .../components/samsungtv/config_flow.py | 5 +- .../components/samsungtv/media_player.py | 14 ++- homeassistant/components/sense/sensor.py | 8 +- .../components/shelly/config_flow.py | 3 +- .../components/simplisafe/config_flow.py | 12 +- homeassistant/components/smappee/__init__.py | 6 +- .../components/smappee/binary_sensor.py | 8 +- homeassistant/components/smappee/sensor.py | 4 +- homeassistant/components/smappee/switch.py | 4 +- homeassistant/components/smarthab/__init__.py | 4 +- .../components/smartthings/__init__.py | 3 +- .../components/smartthings/config_flow.py | 3 +- homeassistant/components/sms/__init__.py | 4 +- homeassistant/components/sms/sensor.py | 13 ++- homeassistant/components/somfy/__init__.py | 6 +- homeassistant/components/somfy/api.py | 4 +- .../components/sonarr/config_flow.py | 4 +- homeassistant/components/songpal/__init__.py | 4 +- .../components/sonos/media_player.py | 5 +- .../components/speedtestdotnet/__init__.py | 5 +- .../components/spider/config_flow.py | 9 +- .../components/squeezebox/media_player.py | 4 +- homeassistant/components/stream/hls.py | 3 +- homeassistant/components/stream/worker.py | 6 +- .../components/surepetcare/binary_sensor.py | 5 +- .../components/syncthru/config_flow.py | 6 +- .../components/synology_dsm/__init__.py | 9 +- homeassistant/components/tado/__init__.py | 15 ++- homeassistant/components/tado/climate.py | 4 +- homeassistant/components/tado/water_heater.py | 4 +- homeassistant/components/template/cover.py | 3 +- homeassistant/components/template/fan.py | 3 +- homeassistant/components/template/vacuum.py | 5 +- .../components/tensorflow/image_processing.py | 7 +- homeassistant/components/tesla/__init__.py | 5 +- .../components/tesla/binary_sensor.py | 3 +- homeassistant/components/tesla/climate.py | 3 +- .../components/tesla/device_tracker.py | 3 +- homeassistant/components/tesla/lock.py | 3 +- .../components/tibber/config_flow.py | 13 ++- .../components/totalconnect/__init__.py | 4 +- homeassistant/components/tplink/light.py | 8 +- .../components/transmission/config_flow.py | 4 +- .../components/transmission/sensor.py | 4 +- homeassistant/components/tuya/__init__.py | 3 +- homeassistant/components/tuya/climate.py | 5 +- homeassistant/components/tuya/cover.py | 5 +- homeassistant/components/tuya/fan.py | 5 +- homeassistant/components/tuya/light.py | 5 +- homeassistant/components/tuya/scene.py | 5 +- homeassistant/components/tuya/switch.py | 5 +- homeassistant/components/unifi/controller.py | 4 +- homeassistant/components/upnp/__init__.py | 3 +- homeassistant/components/upnp/config_flow.py | 18 ++- homeassistant/components/vera/__init__.py | 4 +- homeassistant/components/vera/config_flow.py | 11 +- .../components/vizio/media_player.py | 10 +- homeassistant/components/waqi/sensor.py | 14 ++- homeassistant/components/wemo/__init__.py | 12 +- homeassistant/components/wemo/fan.py | 5 +- .../components/wilight/parent_device.py | 5 +- .../components/wirelesstag/__init__.py | 3 +- homeassistant/components/withings/common.py | 16 ++- homeassistant/components/withings/sensor.py | 5 +- homeassistant/components/wled/__init__.py | 10 +- homeassistant/components/worldclock/sensor.py | 9 +- .../components/xiaomi_aqara/binary_sensor.py | 14 ++- .../components/xiaomi_miio/remote.py | 8 +- homeassistant/components/xs1/__init__.py | 3 +- .../components/yamaha/media_player.py | 4 +- homeassistant/components/zha/config_flow.py | 12 +- .../components/zha/core/channels/hvac.py | 5 +- homeassistant/components/zone/__init__.py | 8 +- homeassistant/config.py | 4 +- homeassistant/config_entries.py | 20 ++-- homeassistant/core.py | 4 +- homeassistant/data_entry_flow.py | 5 +- homeassistant/helpers/aiohttp_client.py | 4 +- homeassistant/helpers/entity.py | 4 +- homeassistant/helpers/entity_component.py | 6 +- homeassistant/helpers/entity_platform.py | 4 +- homeassistant/helpers/instance_id.py | 4 +- homeassistant/helpers/reload.py | 3 +- homeassistant/helpers/script.py | 4 +- homeassistant/helpers/storage.py | 7 +- homeassistant/helpers/translation.py | 8 +- homeassistant/runner.py | 4 +- homeassistant/setup.py | 4 +- homeassistant/util/timeout.py | 5 +- homeassistant/util/unit_system.py | 4 +- homeassistant/util/yaml/loader.py | 4 +- requirements_test_pre_commit.txt | 2 +- .../config_flow/tests/test_config_flow.py | 3 +- .../integration/__init__.py | 6 +- script/translations/clean.py | 5 +- .../abode/test_alarm_control_panel.py | 3 +- .../accuweather/test_config_flow.py | 28 +++-- tests/components/adguard/test_config_flow.py | 12 +- tests/components/agent_dvr/__init__.py | 4 +- .../components/agent_dvr/test_config_flow.py | 6 +- .../components/airvisual/test_config_flow.py | 6 +- tests/components/alexa/test_smart_home.py | 11 +- tests/components/almond/test_config_flow.py | 8 +- tests/components/almond/test_init.py | 3 +- .../components/androidtv/test_media_player.py | 5 +- .../components/arcam_fmj/test_config_flow.py | 28 +++-- .../arcam_fmj/test_device_trigger.py | 8 +- tests/components/atag/test_climate.py | 3 +- tests/components/atag/test_config_flow.py | 21 +++- tests/components/august/test_config_flow.py | 9 +- tests/components/august/test_init.py | 7 +- tests/components/august/test_lock.py | 3 +- tests/components/auth/test_indieauth.py | 3 +- tests/components/automation/test_init.py | 6 +- tests/components/avri/test_config_flow.py | 3 +- tests/components/awair/test_config_flow.py | 27 +++-- tests/components/axis/test_config_flow.py | 15 ++- tests/components/axis/test_device.py | 6 +- .../azure_devops/test_config_flow.py | 27 +++-- tests/components/binary_sensor/test_init.py | 6 +- tests/components/blebox/test_cover.py | 5 +- tests/components/blebox/test_light.py | 30 ++++- tests/components/blebox/test_switch.py | 30 ++++- tests/components/blink/test_config_flow.py | 24 ++-- tests/components/bond/common.py | 3 +- tests/components/bond/test_config_flow.py | 8 +- tests/components/bond/test_fan.py | 10 +- tests/components/bond/test_init.py | 9 +- tests/components/bond/test_light.py | 5 +- .../components/broadlink/test_config_flow.py | 108 ++++++++++++------ tests/components/bsblan/__init__.py | 4 +- tests/components/bsblan/test_config_flow.py | 6 +- tests/components/camera/test_init.py | 6 +- .../cast/test_home_assistant_cast.py | 9 +- tests/components/cast/test_media_player.py | 6 +- tests/components/cloud/test_http_api.py | 3 +- tests/components/command_line/test_cover.py | 9 +- tests/components/command_line/test_sensor.py | 4 +- .../components/config/test_config_entries.py | 3 +- tests/components/config/test_core.py | 3 +- tests/components/config/test_customize.py | 3 +- tests/components/conftest.py | 3 +- tests/components/control4/test_config_flow.py | 6 +- .../components/coolmaster/test_config_flow.py | 3 +- .../coronavirus/test_config_flow.py | 3 +- tests/components/daikin/test_config_flow.py | 31 +++-- tests/components/datadog/test_init.py | 5 +- tests/components/debugpy/test_init.py | 4 +- tests/components/deconz/test_config_flow.py | 24 ++-- tests/components/deconz/test_gateway.py | 9 +- tests/components/denonavr/test_config_flow.py | 53 ++++++--- .../components/denonavr/test_media_player.py | 7 +- .../device_sun_light_trigger/test_init.py | 4 +- .../devolo_home_control/test_config_flow.py | 6 +- tests/components/dexcom/test_config_flow.py | 40 +++++-- tests/components/dexcom/test_init.py | 6 +- tests/components/dexcom/test_sensor.py | 3 +- tests/components/dialogflow/test_init.py | 3 +- tests/components/directv/test_config_flow.py | 41 +++++-- tests/components/doorbird/test_config_flow.py | 21 ++-- tests/components/dunehd/test_config_flow.py | 8 +- tests/components/dynalite/test_init.py | 31 +++-- tests/components/efergy/test_sensor.py | 6 +- tests/components/elgato/__init__.py | 4 +- tests/components/elgato/test_config_flow.py | 6 +- tests/components/elgato/test_light.py | 9 +- tests/components/elkm1/test_config_flow.py | 30 +++-- tests/components/enocean/test_config_flow.py | 6 +- tests/components/esphome/test_config_flow.py | 4 +- tests/components/filter/test_sensor.py | 9 +- .../flick_electric/test_config_flow.py | 10 +- tests/components/flume/test_config_flow.py | 18 ++- .../components/flunearyou/test_config_flow.py | 3 +- .../forked_daapd/test_config_flow.py | 4 +- .../forked_daapd/test_media_player.py | 4 +- .../garmin_connect/test_config_flow.py | 4 +- tests/components/gdacs/test_sensor.py | 20 +++- tests/components/geofency/test_init.py | 3 +- tests/components/gogogate2/common.py | 3 +- .../components/gogogate2/test_config_flow.py | 3 +- tests/components/gogogate2/test_cover.py | 12 +- .../google_assistant/test_helpers.py | 6 +- .../components/google_assistant/test_init.py | 4 +- .../google_assistant/test_smart_home.py | 3 +- .../components/google_assistant/test_trait.py | 98 ++++++++++++---- tests/components/gpslogger/test_init.py | 3 +- tests/components/griddy/test_config_flow.py | 9 +- tests/components/group/common.py | 22 +++- tests/components/group/test_light.py | 9 +- tests/components/guardian/test_config_flow.py | 3 +- tests/components/harmony/test_config_flow.py | 46 +++++--- tests/components/hassio/conftest.py | 6 +- tests/components/hassio/test_discovery.py | 3 +- tests/components/hassio/test_init.py | 3 +- tests/components/hisense_aehw4a1/test_init.py | 3 +- tests/components/history/test_init.py | 3 +- tests/components/hlk_sw16/test_config_flow.py | 23 ++-- tests/components/homeassistant/test_init.py | 11 +- .../triggers/test_homeassistant.py | 3 +- tests/components/homekit/test_config_flow.py | 44 ++++--- .../homekit/test_get_accessories.py | 3 +- tests/components/homekit/test_homekit.py | 3 +- tests/components/homekit/test_type_cameras.py | 45 +++++++- tests/components/homekit/test_type_covers.py | 10 +- tests/components/homekit/test_type_fans.py | 5 +- .../homekit/test_type_humidifiers.py | 26 +++-- .../test_homeassistant_bridge.py | 6 +- .../test_simpleconnect_fan.py | 6 +- .../components/homekit_controller/test_fan.py | 10 +- .../homematicip_cloud/test_binary_sensor.py | 9 +- .../homematicip_cloud/test_climate.py | 3 +- .../components/homematicip_cloud/test_init.py | 4 +- tests/components/http/test_forwarded.py | 6 +- tests/components/hue/test_config_flow.py | 32 ++++-- tests/components/hue/test_init.py | 12 +- .../test_config_flow.py | 15 ++- .../hvv_departures/test_config_flow.py | 51 ++++++--- .../components/image_processing/test_init.py | 3 +- tests/components/influxdb/test_init.py | 9 +- tests/components/influxdb/test_sensor.py | 14 ++- tests/components/insteon/test_config_flow.py | 12 +- tests/components/ipma/test_config_flow.py | 4 +- tests/components/ipp/test_config_flow.py | 78 +++++++++---- .../islamic_prayer_times/test_config_flow.py | 6 +- .../islamic_prayer_times/test_init.py | 15 ++- tests/components/isy994/test_config_flow.py | 48 +++++--- tests/components/izone/test_config_flow.py | 3 +- tests/components/kodi/test_config_flow.py | 102 ++++++++++++----- tests/components/kodi/test_device_trigger.py | 13 ++- .../components/konnected/test_config_flow.py | 6 +- tests/components/konnected/test_init.py | 15 ++- tests/components/light/test_device_action.py | 5 +- tests/components/light/test_init.py | 20 +++- tests/components/local_ip/test_config_flow.py | 5 +- tests/components/locative/test_init.py | 3 +- .../lutron_caseta/test_config_flow.py | 6 +- tests/components/mailgun/test_init.py | 6 +- tests/components/melissa/test_init.py | 3 +- .../meteo_france/test_config_flow.py | 36 ++++-- .../components/metoffice/test_config_flow.py | 12 +- tests/components/metoffice/test_sensor.py | 24 +++- tests/components/metoffice/test_weather.py | 40 +++++-- tests/components/mikrotik/test_init.py | 18 ++- tests/components/mill/test_config_flow.py | 8 +- .../minecraft_server/test_config_flow.py | 24 ++-- tests/components/mobile_app/test_webhook.py | 10 +- .../components/monoprice/test_config_flow.py | 3 +- .../components/monoprice/test_media_player.py | 12 +- tests/components/moon/test_sensor.py | 5 +- .../mqtt/test_alarm_control_panel.py | 70 +++++++++--- tests/components/mqtt/test_common.py | 54 +++++++-- tests/components/mqtt/test_config_flow.py | 6 +- tests/components/mqtt/test_init.py | 9 +- tests/components/mqtt/test_light_json.py | 8 +- .../components/mqtt_eventstream/test_init.py | 3 +- tests/components/myq/test_config_flow.py | 15 ++- tests/components/myq/util.py | 3 +- tests/components/netatmo/test_config_flow.py | 10 +- tests/components/nexia/test_config_flow.py | 15 ++- tests/components/nexia/util.py | 3 +- tests/components/nightscout/__init__.py | 15 ++- .../components/nightscout/test_config_flow.py | 16 ++- tests/components/nightscout/test_init.py | 3 +- tests/components/nuheat/test_climate.py | 12 +- tests/components/nuheat/test_init.py | 3 +- tests/components/nut/test_config_flow.py | 51 ++++++--- tests/components/nut/util.py | 3 +- tests/components/nws/test_config_flow.py | 21 ++-- tests/components/nws/test_init.py | 5 +- tests/components/nws/test_weather.py | 40 +++++-- tests/components/onvif/test_config_flow.py | 10 +- .../opentherm_gw/test_config_flow.py | 27 +++-- tests/components/openuv/test_config_flow.py | 9 +- .../components/ovo_energy/test_config_flow.py | 9 +- .../components/owntracks/test_config_flow.py | 9 +- tests/components/ozw/test_config_flow.py | 3 +- .../panasonic_viera/test_config_flow.py | 56 ++++++--- tests/components/panasonic_viera/test_init.py | 19 ++- tests/components/pi_hole/test_config_flow.py | 13 ++- tests/components/plant/test_init.py | 3 +- tests/components/plex/test_config_flow.py | 42 ++++--- tests/components/plex/test_init.py | 5 +- tests/components/plugwise/test_config_flow.py | 19 ++- .../plum_lightpad/test_config_flow.py | 6 +- tests/components/plum_lightpad/test_init.py | 3 +- .../components/poolsense/test_config_flow.py | 3 +- .../powerwall/test_binary_sensor.py | 3 +- .../components/powerwall/test_config_flow.py | 15 ++- tests/components/powerwall/test_sensor.py | 3 +- tests/components/ps4/test_config_flow.py | 7 +- tests/components/push/test_camera.py | 6 +- tests/components/qwikswitch/test_init.py | 4 +- tests/components/rachio/test_config_flow.py | 9 +- .../rainmachine/test_config_flow.py | 9 +- tests/components/rest/test_sensor.py | 12 +- tests/components/rfxtrx/conftest.py | 7 +- tests/components/ring/test_config_flow.py | 3 +- .../risco/test_alarm_control_panel.py | 12 +- tests/components/risco/test_binary_sensor.py | 21 +++- tests/components/risco/test_config_flow.py | 17 ++- tests/components/rmvtransport/test_sensor.py | 12 +- tests/components/roku/__init__.py | 6 +- tests/components/roku/test_config_flow.py | 23 ++-- tests/components/roku/test_init.py | 3 +- tests/components/roomba/test_config_flow.py | 12 +- tests/components/roon/test_config_flow.py | 18 ++- .../components/samsungtv/test_config_flow.py | 27 +++-- .../components/samsungtv/test_media_player.py | 4 +- tests/components/sense/test_config_flow.py | 3 +- tests/components/sentry/test_config_flow.py | 21 ++-- tests/components/shelly/test_config_flow.py | 40 +++++-- .../signal_messenger/test_notify.py | 12 +- .../components/simplisafe/test_config_flow.py | 11 +- tests/components/smappee/test_config_flow.py | 42 ++++--- .../components/smart_meter_texas/conftest.py | 9 +- .../smart_meter_texas/test_config_flow.py | 18 ++- tests/components/smarthab/test_config_flow.py | 3 +- tests/components/smartthings/conftest.py | 3 +- .../smartthings/test_config_flow.py | 21 +++- tests/components/smartthings/test_init.py | 3 +- tests/components/smhi/test_weather.py | 4 +- tests/components/solarlog/test_config_flow.py | 3 +- tests/components/sonarr/__init__.py | 18 ++- tests/components/sonarr/test_config_flow.py | 28 +++-- tests/components/sonarr/test_init.py | 3 +- tests/components/songpal/test_config_flow.py | 29 +++-- tests/components/sonos/test_media_player.py | 3 +- .../soundtouch/test_media_player.py | 42 +++++-- .../speedtestdotnet/test_config_flow.py | 16 ++- tests/components/speedtestdotnet/test_init.py | 20 +++- tests/components/spider/test_config_flow.py | 6 +- .../components/squeezebox/test_config_flow.py | 24 ++-- tests/components/statistics/test_sensor.py | 9 +- tests/components/syncthru/test_config_flow.py | 4 +- .../synology_dsm/test_config_flow.py | 6 +- tests/components/tado/test_config_flow.py | 21 ++-- tests/components/tado/util.py | 6 +- .../template/test_alarm_control_panel.py | 4 +- tests/components/template/test_init.py | 45 ++++++-- tests/components/template/test_sensor.py | 3 +- tests/components/template/test_switch.py | 6 +- tests/components/tibber/test_config_flow.py | 4 +- tests/components/tile/test_config_flow.py | 3 +- tests/components/toon/test_config_flow.py | 3 +- tests/components/tplink/test_init.py | 3 +- tests/components/tplink/test_light.py | 30 ++++- tests/components/traccar/test_init.py | 3 +- tests/components/tradfri/test_config_flow.py | 5 +- tests/components/tts/test_init.py | 3 +- tests/components/tuya/test_config_flow.py | 6 +- tests/components/twitch/test_twitch.py | 15 ++- tests/components/unifi/test_controller.py | 3 +- tests/components/unifi/test_device_tracker.py | 52 ++++++--- tests/components/unifi/test_sensor.py | 13 ++- tests/components/unifi/test_switch.py | 16 ++- .../components/universal/test_media_player.py | 9 +- tests/components/upnp/test_config_flow.py | 13 ++- tests/components/vera/test_climate.py | 16 ++- tests/components/vera/test_cover.py | 16 ++- tests/components/vera/test_light.py | 16 ++- tests/components/vera/test_lock.py | 8 +- tests/components/vera/test_scene.py | 7 +- tests/components/vera/test_switch.py | 8 +- tests/components/vilfo/test_config_flow.py | 6 +- tests/components/vizio/conftest.py | 3 +- tests/components/vizio/test_media_player.py | 21 +++- tests/components/volumio/test_config_flow.py | 36 ++++-- tests/components/webhook/test_init.py | 3 +- tests/components/webostv/test_media_player.py | 4 +- tests/components/wiffi/test_config_flow.py | 9 +- tests/components/wilight/__init__.py | 4 +- tests/components/wilight/test_config_flow.py | 7 +- tests/components/wilight/test_init.py | 3 +- tests/components/wilight/test_light.py | 15 ++- tests/components/withings/common.py | 3 +- .../components/withings/test_binary_sensor.py | 4 +- tests/components/withings/test_common.py | 12 +- tests/components/withings/test_config_flow.py | 5 +- tests/components/withings/test_sensor.py | 8 +- tests/components/wled/test_config_flow.py | 6 +- tests/components/wled/test_light.py | 78 +++++++++---- tests/components/wolflink/test_config_flow.py | 6 +- .../xiaomi_aqara/test_config_flow.py | 42 ++++--- .../xiaomi_miio/test_config_flow.py | 14 ++- tests/components/zeroconf/test_usage.py | 6 +- tests/components/zerproc/test_config_flow.py | 24 +++- tests/components/zha/test_climate.py | 12 +- tests/components/zha/test_config_flow.py | 12 +- tests/components/zha/test_cover.py | 5 +- tests/components/zha/test_device.py | 30 ++++- tests/components/zha/test_discover.py | 5 +- tests/components/zha/test_sensor.py | 4 +- tests/components/zwave/test_init.py | 15 ++- tests/helpers/test_condition.py | 91 ++++++++------- tests/helpers/test_config_entry_flow.py | 3 +- .../helpers/test_config_entry_oauth2_flow.py | 17 ++- tests/helpers/test_entity_component.py | 4 +- tests/helpers/test_entity_registry.py | 5 +- tests/helpers/test_frame.py | 6 +- tests/helpers/test_location.py | 10 +- tests/helpers/test_network.py | 60 ++++++---- tests/helpers/test_reload.py | 13 ++- tests/helpers/test_service.py | 21 +++- tests/helpers/test_state.py | 4 +- tests/helpers/test_template.py | 75 ++++++++---- tests/ignore_uncaught_exceptions.py | 5 +- tests/test_bootstrap.py | 3 +- tests/test_config.py | 58 ++++++---- tests/test_config_entries.py | 26 +++-- tests/test_requirements.py | 3 +- tests/test_setup.py | 6 +- tests/util/test_json.py | 22 ++-- 574 files changed, 4389 insertions(+), 1725 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2aec5453923..29365969725 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: - id: pyupgrade args: [--py37-plus] - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 20.8b1 hooks: - id: black args: diff --git a/homeassistant/auth/__init__.py b/homeassistant/auth/__init__.py index 26bd10535d0..5a39090ae44 100644 --- a/homeassistant/auth/__init__.py +++ b/homeassistant/auth/__init__.py @@ -312,9 +312,7 @@ class AuthManager: if provider is not None and hasattr(provider, "async_will_remove_credentials"): # https://github.com/python/mypy/issues/1424 - await provider.async_will_remove_credentials( # type: ignore - credentials - ) + await provider.async_will_remove_credentials(credentials) # type: ignore await self._store.async_remove_credentials(credentials) diff --git a/homeassistant/auth/models.py b/homeassistant/auth/models.py index e4f31eea330..5a838cfc805 100644 --- a/homeassistant/auth/models.py +++ b/homeassistant/auth/models.py @@ -48,7 +48,10 @@ class User: ) _permissions: Optional[perm_mdl.PolicyPermissions] = attr.ib( - init=False, eq=False, order=False, default=None, + init=False, + eq=False, + order=False, + default=None, ) @property diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index a7953cbec6c..1a8c1d554e3 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -112,7 +112,8 @@ async def async_setup_hass( config_dict = await conf_util.async_hass_config_yaml(hass) except HomeAssistantError as err: _LOGGER.error( - "Failed to parse configuration.yaml: %s. Activating safe mode", err, + "Failed to parse configuration.yaml: %s. Activating safe mode", + err, ) else: if not is_virtual_env(): @@ -160,7 +161,8 @@ async def async_setup_hass( http_conf = (await http.async_get_last_config(hass)) or {} await async_from_config_dict( - {"safe_mode": {}, "http": http_conf}, hass, + {"safe_mode": {}, "http": http_conf}, + hass, ) if runtime_config.open_ui: @@ -331,8 +333,10 @@ def async_enable_logging( ): if log_rotate_days: - err_handler: logging.FileHandler = logging.handlers.TimedRotatingFileHandler( - err_log_path, when="midnight", backupCount=log_rotate_days + err_handler: logging.FileHandler = ( + logging.handlers.TimedRotatingFileHandler( + err_log_path, when="midnight", backupCount=log_rotate_days + ) ) else: err_handler = logging.FileHandler(err_log_path, mode="w", delay=True) @@ -391,7 +395,8 @@ async def _async_log_pending_setups( if remaining: _LOGGER.warning( - "Waiting on integrations to complete setup: %s", ", ".join(remaining), + "Waiting on integrations to complete setup: %s", + ", ".join(remaining), ) diff --git a/homeassistant/components/acmeda/helpers.py b/homeassistant/components/acmeda/helpers.py index f8ea744be77..cec971e5fdd 100644 --- a/homeassistant/components/acmeda/helpers.py +++ b/homeassistant/components/acmeda/helpers.py @@ -37,5 +37,6 @@ async def update_devices(hass, config_entry, api): ) if device is not None: dev_registry.async_update_device( - device.id, name=api_item.name, + device.id, + name=api_item.name, ) diff --git a/homeassistant/components/airvisual/__init__.py b/homeassistant/components/airvisual/__init__.py index 8d41bd359b8..3449d5e865f 100644 --- a/homeassistant/components/airvisual/__init__.py +++ b/homeassistant/components/airvisual/__init__.py @@ -220,7 +220,8 @@ async def async_setup_entry(hass, config_entry): ) else: api_coro = client.api.nearest_city( - config_entry.data[CONF_LATITUDE], config_entry.data[CONF_LONGITUDE], + config_entry.data[CONF_LATITUDE], + config_entry.data[CONF_LONGITUDE], ) try: diff --git a/homeassistant/components/airvisual/sensor.py b/homeassistant/components/airvisual/sensor.py index b122f3c27b4..0fbb9ec9b38 100644 --- a/homeassistant/components/airvisual/sensor.py +++ b/homeassistant/components/airvisual/sensor.py @@ -98,7 +98,13 @@ async def async_setup_entry(hass, config_entry, async_add_entities): if config_entry.data[CONF_INTEGRATION_TYPE] == INTEGRATION_TYPE_GEOGRAPHY: sensors = [ AirVisualGeographySensor( - coordinator, config_entry, kind, name, icon, unit, locale, + coordinator, + config_entry, + kind, + name, + icon, + unit, + locale, ) for locale in GEOGRAPHY_SENSOR_LOCALES for kind, name, icon, unit in GEOGRAPHY_SENSORS diff --git a/homeassistant/components/almond/__init__.py b/homeassistant/components/almond/__init__.py index 3710ff14b1a..2117f809b04 100644 --- a/homeassistant/components/almond/__init__.py +++ b/homeassistant/components/almond/__init__.py @@ -108,8 +108,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: config_entries.ConfigEnt auth = AlmondLocalAuth(entry.data["host"], websession) else: # OAuth2 - implementation = await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry + implementation = ( + await config_entry_oauth2_flow.async_get_config_entry_implementation( + hass, entry + ) ) oauth_session = config_entry_oauth2_flow.OAuth2Session( hass, entry, implementation diff --git a/homeassistant/components/androidtv/media_player.py b/homeassistant/components/androidtv/media_player.py index e2468247a72..0d39d528cca 100644 --- a/homeassistant/components/androidtv/media_player.py +++ b/homeassistant/components/androidtv/media_player.py @@ -597,7 +597,8 @@ class ADBDevice(MediaPlayerEntity): msg = f"Output from service '{SERVICE_LEARN_SENDEVENT}' from {self.entity_id}: '{output}'" self.hass.components.persistent_notification.async_create( - msg, title="Android TV", + msg, + title="Android TV", ) _LOGGER.info("%s", msg) diff --git a/homeassistant/components/arcam_fmj/config_flow.py b/homeassistant/components/arcam_fmj/config_flow.py index d6cf1c02d3b..2a9f1946cb4 100644 --- a/homeassistant/components/arcam_fmj/config_flow.py +++ b/homeassistant/components/arcam_fmj/config_flow.py @@ -42,7 +42,8 @@ class ArcamFmjFlowHandler(config_entries.ConfigFlow): await client.stop() return self.async_create_entry( - title=f"{DEFAULT_NAME} ({host})", data={CONF_HOST: host, CONF_PORT: port}, + title=f"{DEFAULT_NAME} ({host})", + data={CONF_HOST: host, CONF_PORT: port}, ) async def async_step_user(self, user_input=None): diff --git a/homeassistant/components/arcam_fmj/media_player.py b/homeassistant/components/arcam_fmj/media_player.py index 0ead1f16b94..6b5b5856190 100644 --- a/homeassistant/components/arcam_fmj/media_player.py +++ b/homeassistant/components/arcam_fmj/media_player.py @@ -60,7 +60,10 @@ class ArcamFmj(MediaPlayerEntity): """Representation of a media device.""" def __init__( - self, device_name, state: State, uuid: str, + self, + device_name, + state: State, + uuid: str, ): """Initialize device.""" self._state = state diff --git a/homeassistant/components/august/config_flow.py b/homeassistant/components/august/config_flow.py index acdfb1d4b63..bf6f1d9cd81 100644 --- a/homeassistant/components/august/config_flow.py +++ b/homeassistant/components/august/config_flow.py @@ -30,7 +30,9 @@ DATA_SCHEMA = vol.Schema( async def async_validate_input( - hass: core.HomeAssistant, data, august_gateway, + hass: core.HomeAssistant, + data, + august_gateway, ): """Validate the user input allows us to connect. @@ -89,7 +91,9 @@ class AugustConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): try: info = await async_validate_input( - self.hass, user_input, self._august_gateway, + self.hass, + user_input, + self._august_gateway, ) await self.async_set_unique_id(user_input[CONF_USERNAME]) return self.async_create_entry(title=info["title"], data=info["data"]) diff --git a/homeassistant/components/august/gateway.py b/homeassistant/components/august/gateway.py index bb39523a984..272c50ac02a 100644 --- a/homeassistant/components/august/gateway.py +++ b/homeassistant/components/august/gateway.py @@ -122,8 +122,8 @@ class AugustGateway: """Refresh the august access token if needed.""" if self.authenticator.should_refresh(): async with self._token_refresh_lock: - refreshed_authentication = await self.authenticator.async_refresh_access_token( - force=False + refreshed_authentication = ( + await self.authenticator.async_refresh_access_token(force=False) ) _LOGGER.info( "Refreshed august access token. The old token expired at %s, and the new token expires at %s", diff --git a/homeassistant/components/august/sensor.py b/homeassistant/components/august/sensor.py index 3276f8b073b..c8f2704da8d 100644 --- a/homeassistant/components/august/sensor.py +++ b/homeassistant/components/august/sensor.py @@ -70,7 +70,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities): ) continue _LOGGER.debug( - "Adding battery sensor for %s", device.device_name, + "Adding battery sensor for %s", + device.device_name, ) devices.append(AugustBatterySensor(data, "device_battery", device, device)) @@ -84,7 +85,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities): ) continue _LOGGER.debug( - "Adding keypad battery sensor for %s", device.device_name, + "Adding keypad battery sensor for %s", + device.device_name, ) keypad_battery_sensor = AugustBatterySensor( data, "linked_keypad_battery", detail.keypad, device diff --git a/homeassistant/components/avri/config_flow.py b/homeassistant/components/avri/config_flow.py index d6f9dbf7b62..987b3679b3c 100644 --- a/homeassistant/components/avri/config_flow.py +++ b/homeassistant/components/avri/config_flow.py @@ -32,7 +32,9 @@ class AvriConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def _show_setup_form(self, errors=None): """Show the setup form to the user.""" return self.async_show_form( - step_id="user", data_schema=DATA_SCHEMA, errors=errors or {}, + step_id="user", + data_schema=DATA_SCHEMA, + errors=errors or {}, ) async def async_step_user(self, user_input=None): diff --git a/homeassistant/components/awair/__init__.py b/homeassistant/components/awair/__init__.py index c002693d6e9..2ae436bebba 100644 --- a/homeassistant/components/awair/__init__.py +++ b/homeassistant/components/awair/__init__.py @@ -96,7 +96,9 @@ class AwairDataUpdateCoordinator(DataUpdateCoordinator): if not matching_flows: self.hass.async_create_task( self.hass.config_entries.flow.async_init( - DOMAIN, context=flow_context, data=self._config_entry.data, + DOMAIN, + context=flow_context, + data=self._config_entry.data, ) ) diff --git a/homeassistant/components/awair/sensor.py b/homeassistant/components/awair/sensor.py index e4e2f3fbbd6..28802454aa2 100644 --- a/homeassistant/components/awair/sensor.py +++ b/homeassistant/components/awair/sensor.py @@ -32,7 +32,8 @@ from .const import ( ) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( - {vol.Required(CONF_ACCESS_TOKEN): cv.string}, extra=vol.ALLOW_EXTRA, + {vol.Required(CONF_ACCESS_TOKEN): cv.string}, + extra=vol.ALLOW_EXTRA, ) @@ -43,7 +44,9 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= ) hass.async_create_task( hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=config, + DOMAIN, + context={"source": SOURCE_IMPORT}, + data=config, ) ) @@ -83,7 +86,10 @@ class AwairSensor(Entity): """Defines an Awair sensor entity.""" def __init__( - self, kind: str, device: AwairDevice, coordinator: AwairDataUpdateCoordinator, + self, + kind: str, + device: AwairDevice, + coordinator: AwairDataUpdateCoordinator, ) -> None: """Set up an individual AwairSensor.""" self._kind = kind diff --git a/homeassistant/components/axis/light.py b/homeassistant/components/axis/light.py index 75b2d59e5f5..3ae15a46244 100644 --- a/homeassistant/components/axis/light.py +++ b/homeassistant/components/axis/light.py @@ -54,8 +54,8 @@ class AxisLight(AxisEventBase, LightEntity): def get_light_capabilities(): """Get light capabilities.""" - current_intensity = self.device.api.vapix.light_control.get_current_intensity( - self.light_id + current_intensity = ( + self.device.api.vapix.light_control.get_current_intensity(self.light_id) ) self.current_intensity = current_intensity["data"]["intensity"] diff --git a/homeassistant/components/azure_devops/__init__.py b/homeassistant/components/azure_devops/__init__.py index 00f08496dd3..e08dd4d8559 100644 --- a/homeassistant/components/azure_devops/__init__.py +++ b/homeassistant/components/azure_devops/__init__.py @@ -38,7 +38,9 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool ) hass.async_create_task( hass.config_entries.flow.async_init( - DOMAIN, context={"source": "reauth"}, data=entry.data, + DOMAIN, + context={"source": "reauth"}, + data=entry.data, ) ) return False @@ -115,7 +117,13 @@ class AzureDevOpsDeviceEntity(AzureDevOpsEntity): def device_info(self) -> Dict[str, Any]: """Return device information about this Azure DevOps instance.""" return { - "identifiers": {(DOMAIN, self.organization, self.project,)}, + "identifiers": { + ( + DOMAIN, + self.organization, + self.project, + ) + }, "manufacturer": self.organization, "name": self.project, } diff --git a/homeassistant/components/blink/__init__.py b/homeassistant/components/blink/__init__.py index e2c43a27547..0809018522e 100644 --- a/homeassistant/components/blink/__init__.py +++ b/homeassistant/components/blink/__init__.py @@ -103,7 +103,8 @@ async def async_setup_entry(hass, entry): """Call blink to send new pin.""" pin = call.data[CONF_PIN] hass.data[DOMAIN][entry.entry_id].auth.send_auth_key( - hass.data[DOMAIN][entry.entry_id], pin, + hass.data[DOMAIN][entry.entry_id], + pin, ) hass.services.async_register(DOMAIN, SERVICE_REFRESH, blink_refresh) diff --git a/homeassistant/components/blink/config_flow.py b/homeassistant/components/blink/config_flow.py index 3073a093261..63c822cfd1f 100644 --- a/homeassistant/components/blink/config_flow.py +++ b/homeassistant/components/blink/config_flow.py @@ -86,7 +86,9 @@ class BlinkConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): } return self.async_show_form( - step_id="user", data_schema=vol.Schema(data_schema), errors=errors, + step_id="user", + data_schema=vol.Schema(data_schema), + errors=errors, ) async def async_step_2fa(self, user_input=None): @@ -156,7 +158,12 @@ class BlinkOptionsFlowHandler(config_entries.OptionsFlow): return self.async_show_form( step_id="simple_options", data_schema=vol.Schema( - {vol.Optional(CONF_SCAN_INTERVAL, default=scan_interval,): int} + { + vol.Optional( + CONF_SCAN_INTERVAL, + default=scan_interval, + ): int + } ), ) diff --git a/homeassistant/components/broadlink/config_flow.py b/homeassistant/components/broadlink/config_flow.py index 899a277b1c3..284a9bffe19 100644 --- a/homeassistant/components/broadlink/config_flow.py +++ b/homeassistant/components/broadlink/config_flow.py @@ -107,7 +107,9 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): cv.positive_int, } return self.async_show_form( - step_id="user", data_schema=vol.Schema(data_schema), errors=errors, + step_id="user", + data_schema=vol.Schema(data_schema), + errors=errors, ) async def async_step_auth(self): diff --git a/homeassistant/components/brother/__init__.py b/homeassistant/components/brother/__init__.py index 5daf54a568c..4c69282a996 100644 --- a/homeassistant/components/brother/__init__.py +++ b/homeassistant/components/brother/__init__.py @@ -71,7 +71,10 @@ class BrotherDataUpdateCoordinator(DataUpdateCoordinator): self.brother = Brother(host, kind=kind) super().__init__( - hass, _LOGGER, name=DOMAIN, update_interval=SCAN_INTERVAL, + hass, + _LOGGER, + name=DOMAIN, + update_interval=SCAN_INTERVAL, ) async def _async_update_data(self): diff --git a/homeassistant/components/bsblan/climate.py b/homeassistant/components/bsblan/climate.py index aaeb1fbffdb..c84b3304c7b 100644 --- a/homeassistant/components/bsblan/climate.py +++ b/homeassistant/components/bsblan/climate.py @@ -86,7 +86,10 @@ class BSBLanClimate(ClimateEntity): """Defines a BSBLan climate device.""" def __init__( - self, entry_id: str, bsblan: BSBLan, info: Info, + self, + entry_id: str, + bsblan: BSBLan, + info: Info, ): """Initialize BSBLan climate device.""" self._current_temperature: Optional[float] = None diff --git a/homeassistant/components/cert_expiry/__init__.py b/homeassistant/components/cert_expiry/__init__.py index 19fa4927d05..84629353bce 100644 --- a/homeassistant/components/cert_expiry/__init__.py +++ b/homeassistant/components/cert_expiry/__init__.py @@ -65,7 +65,10 @@ class CertExpiryDataUpdateCoordinator(DataUpdateCoordinator[datetime]): name = f"{self.host}{display_port}" super().__init__( - hass, _LOGGER, name=name, update_interval=SCAN_INTERVAL, + hass, + _LOGGER, + name=name, + update_interval=SCAN_INTERVAL, ) async def _async_update_data(self) -> Optional[datetime]: diff --git a/homeassistant/components/cert_expiry/config_flow.py b/homeassistant/components/cert_expiry/config_flow.py index e23d832bb20..7953a7bb8cf 100644 --- a/homeassistant/components/cert_expiry/config_flow.py +++ b/homeassistant/components/cert_expiry/config_flow.py @@ -60,7 +60,8 @@ class CertexpiryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): title_port = f":{port}" if port != DEFAULT_PORT else "" title = f"{host}{title_port}" return self.async_create_entry( - title=title, data={CONF_HOST: host, CONF_PORT: port}, + title=title, + data={CONF_HOST: host, CONF_PORT: port}, ) if ( # pylint: disable=no-member self.context["source"] == config_entries.SOURCE_IMPORT diff --git a/homeassistant/components/channels/media_player.py b/homeassistant/components/channels/media_player.py index 78286b70145..54dc0f18374 100644 --- a/homeassistant/components/channels/media_player.py +++ b/homeassistant/components/channels/media_player.py @@ -69,13 +69,19 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= platform = entity_platform.current_platform.get() platform.async_register_entity_service( - SERVICE_SEEK_FORWARD, {}, "seek_forward", + SERVICE_SEEK_FORWARD, + {}, + "seek_forward", ) platform.async_register_entity_service( - SERVICE_SEEK_BACKWARD, {}, "seek_backward", + SERVICE_SEEK_BACKWARD, + {}, + "seek_backward", ) platform.async_register_entity_service( - SERVICE_SEEK_BY, {vol.Required(ATTR_SECONDS): vol.Coerce(int)}, "seek_by", + SERVICE_SEEK_BY, + {vol.Required(ATTR_SECONDS): vol.Coerce(int)}, + "seek_by", ) diff --git a/homeassistant/components/cloud/http_api.py b/homeassistant/components/cloud/http_api.py index 6710d8682e2..6589f2b43f5 100644 --- a/homeassistant/components/cloud/http_api.py +++ b/homeassistant/components/cloud/http_api.py @@ -72,7 +72,10 @@ _CLOUD_ERRORS = { "Remote UI not compatible with 127.0.0.1/::1 as trusted proxies.", ), asyncio.TimeoutError: (502, "Unable to reach the Home Assistant cloud."), - aiohttp.ClientError: (HTTP_INTERNAL_SERVER_ERROR, "Error making internal request",), + aiohttp.ClientError: ( + HTTP_INTERNAL_SERVER_ERROR, + "Error making internal request", + ), } diff --git a/homeassistant/components/control4/light.py b/homeassistant/components/control4/light.py index 36727b21ecf..2871da34f11 100644 --- a/homeassistant/components/control4/light.py +++ b/homeassistant/components/control4/light.py @@ -36,7 +36,8 @@ async def async_setup_entry( entry_data = hass.data[DOMAIN][entry.entry_id] scan_interval = entry_data[CONF_SCAN_INTERVAL] _LOGGER.debug( - "Scan interval = %s", scan_interval, + "Scan interval = %s", + scan_interval, ) async def async_update_data_non_dimmer(): @@ -95,7 +96,8 @@ async def async_setup_entry( continue except KeyError: _LOGGER.exception( - "Unknown device properties received from Control4: %s", item, + "Unknown device properties received from Control4: %s", + item, ) continue diff --git a/homeassistant/components/coolmaster/__init__.py b/homeassistant/components/coolmaster/__init__.py index 390b807f5cf..14165bd93b3 100644 --- a/homeassistant/components/coolmaster/__init__.py +++ b/homeassistant/components/coolmaster/__init__.py @@ -61,7 +61,10 @@ class CoolmasterDataUpdateCoordinator(DataUpdateCoordinator): self._coolmaster = coolmaster super().__init__( - hass, _LOGGER, name=DOMAIN, update_interval=SCAN_INTERVAL, + hass, + _LOGGER, + name=DOMAIN, + update_interval=SCAN_INTERVAL, ) async def _async_update_data(self): diff --git a/homeassistant/components/cover/__init__.py b/homeassistant/components/cover/__init__.py index ef17abc8a40..f1039505f82 100644 --- a/homeassistant/components/cover/__init__.py +++ b/homeassistant/components/cover/__init__.py @@ -338,5 +338,6 @@ class CoverDevice(CoverEntity): """Print deprecation warning.""" super().__init_subclass__(**kwargs) _LOGGER.warning( - "CoverDevice is deprecated, modify %s to extend CoverEntity", cls.__name__, + "CoverDevice is deprecated, modify %s to extend CoverEntity", + cls.__name__, ) diff --git a/homeassistant/components/daikin/config_flow.py b/homeassistant/components/daikin/config_flow.py index 65e48c7ee6f..7142771a7c3 100644 --- a/homeassistant/components/daikin/config_flow.py +++ b/homeassistant/components/daikin/config_flow.py @@ -85,17 +85,23 @@ class FlowHandler(config_entries.ConfigFlow): ) except web_exceptions.HTTPForbidden: return self.async_show_form( - step_id="user", data_schema=self.schema, errors={"base": "forbidden"}, + step_id="user", + data_schema=self.schema, + errors={"base": "forbidden"}, ) except ClientError: _LOGGER.exception("ClientError") return self.async_show_form( - step_id="user", data_schema=self.schema, errors={"base": "device_fail"}, + step_id="user", + data_schema=self.schema, + errors={"base": "device_fail"}, ) except Exception: # pylint: disable=broad-except _LOGGER.exception("Unexpected error creating device") return self.async_show_form( - step_id="user", data_schema=self.schema, errors={"base": "device_fail"}, + step_id="user", + data_schema=self.schema, + errors={"base": "device_fail"}, ) mac = device.mac diff --git a/homeassistant/components/decora/light.py b/homeassistant/components/decora/light.py index 5b6015b7c54..b9bf09f0c6d 100644 --- a/homeassistant/components/decora/light.py +++ b/homeassistant/components/decora/light.py @@ -62,7 +62,8 @@ def retry(method): return method(device, *args, **kwargs) except (decora.decoraException, AttributeError, BTLEException): _LOGGER.warning( - "Decora connect error for device %s. Reconnecting...", device.name, + "Decora connect error for device %s. Reconnecting...", + device.name, ) # pylint: disable=protected-access device._switch.connect() diff --git a/homeassistant/components/demo/config_flow.py b/homeassistant/components/demo/config_flow.py index 0899ca5dbb9..35f72e9e0cd 100644 --- a/homeassistant/components/demo/config_flow.py +++ b/homeassistant/components/demo/config_flow.py @@ -59,7 +59,8 @@ class OptionsFlowHandler(config_entries.OptionsFlow): default=self.config_entry.options.get(CONF_BOOLEAN, False), ): bool, vol.Optional( - CONF_INT, default=self.config_entry.options.get(CONF_INT, 10), + CONF_INT, + default=self.config_entry.options.get(CONF_INT, 10), ): int, } ), @@ -77,7 +78,10 @@ class OptionsFlowHandler(config_entries.OptionsFlow): { vol.Optional( CONF_STRING, - default=self.config_entry.options.get(CONF_STRING, "Default",), + default=self.config_entry.options.get( + CONF_STRING, + "Default", + ), ): str, vol.Optional( CONF_SELECT, diff --git a/homeassistant/components/devolo_home_control/cover.py b/homeassistant/components/devolo_home_control/cover.py index 3e05d4f20b4..b93713cc700 100644 --- a/homeassistant/components/devolo_home_control/cover.py +++ b/homeassistant/components/devolo_home_control/cover.py @@ -50,8 +50,8 @@ class DevoloCoverDeviceEntity(DevoloDeviceEntity, CoverEntity): sync=self._sync, ) - self._multi_level_switch_property = device_instance.multi_level_switch_property.get( - element_uid + self._multi_level_switch_property = ( + device_instance.multi_level_switch_property.get(element_uid) ) self._position = self._multi_level_switch_property.value diff --git a/homeassistant/components/directv/__init__.py b/homeassistant/components/directv/__init__.py index 677487945be..d01f8bd25c9 100644 --- a/homeassistant/components/directv/__init__.py +++ b/homeassistant/components/directv/__init__.py @@ -44,7 +44,9 @@ async def async_setup(hass: HomeAssistant, config: Dict) -> bool: for entry_config in config[DOMAIN]: hass.async_create_task( hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=entry_config, + DOMAIN, + context={"source": SOURCE_IMPORT}, + data=entry_config, ) ) diff --git a/homeassistant/components/directv/config_flow.py b/homeassistant/components/directv/config_flow.py index 406f2628ee4..d84c3925ac4 100644 --- a/homeassistant/components/directv/config_flow.py +++ b/homeassistant/components/directv/config_flow.py @@ -121,7 +121,8 @@ class DirecTVConfigFlow(ConfigFlow, domain=DOMAIN): ) return self.async_create_entry( - title=self.discovery_info[CONF_NAME], data=self.discovery_info, + title=self.discovery_info[CONF_NAME], + data=self.discovery_info, ) def _show_setup_form(self, errors: Optional[Dict] = None) -> Dict[str, Any]: diff --git a/homeassistant/components/directv/media_player.py b/homeassistant/components/directv/media_player.py index 205503fe17f..acf30cb103a 100644 --- a/homeassistant/components/directv/media_player.py +++ b/homeassistant/components/directv/media_player.py @@ -70,7 +70,9 @@ async def async_setup_entry( for location in dtv.device.locations: entities.append( DIRECTVMediaPlayer( - dtv=dtv, name=str.title(location.name), address=location.address, + dtv=dtv, + name=str.title(location.name), + address=location.address, ) ) @@ -83,7 +85,9 @@ class DIRECTVMediaPlayer(DIRECTVEntity, MediaPlayerEntity): def __init__(self, *, dtv: DIRECTV, name: str, address: str = "0") -> None: """Initialize DirecTV media player.""" super().__init__( - dtv=dtv, name=name, address=address, + dtv=dtv, + name=name, + address=address, ) self._assumed_state = None diff --git a/homeassistant/components/directv/remote.py b/homeassistant/components/directv/remote.py index 9665b0aea17..64695ae3813 100644 --- a/homeassistant/components/directv/remote.py +++ b/homeassistant/components/directv/remote.py @@ -29,7 +29,9 @@ async def async_setup_entry( for location in dtv.device.locations: entities.append( DIRECTVRemote( - dtv=dtv, name=str.title(location.name), address=location.address, + dtv=dtv, + name=str.title(location.name), + address=location.address, ) ) @@ -42,7 +44,9 @@ class DIRECTVRemote(DIRECTVEntity, RemoteEntity): def __init__(self, *, dtv: DIRECTV, name: str, address: str = "0") -> None: """Initialize DirecTV remote.""" super().__init__( - dtv=dtv, name=name, address=address, + dtv=dtv, + name=name, + address=address, ) self._available = False diff --git a/homeassistant/components/eafm/config_flow.py b/homeassistant/components/eafm/config_flow.py index 0f640951f9f..f1cf60bb97e 100644 --- a/homeassistant/components/eafm/config_flow.py +++ b/homeassistant/components/eafm/config_flow.py @@ -32,7 +32,8 @@ class UKFloodsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): await self.async_set_unique_id(station, raise_on_progress=False) self._abort_if_unique_id_configured() return self.async_create_entry( - title=user_input["station"], data={"station": station}, + title=user_input["station"], + data={"station": station}, ) session = async_get_clientsession(hass=self.hass) diff --git a/homeassistant/components/elgato/__init__.py b/homeassistant/components/elgato/__init__.py index 993748033b5..31f8c2b59cf 100644 --- a/homeassistant/components/elgato/__init__.py +++ b/homeassistant/components/elgato/__init__.py @@ -24,7 +24,11 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Elgato Key Light from a config entry.""" session = async_get_clientsession(hass) - elgato = Elgato(entry.data[CONF_HOST], port=entry.data[CONF_PORT], session=session,) + elgato = Elgato( + entry.data[CONF_HOST], + port=entry.data[CONF_PORT], + session=session, + ) # Ensure we can connect to it try: diff --git a/homeassistant/components/elgato/config_flow.py b/homeassistant/components/elgato/config_flow.py index 8411980ee44..687310c2c3e 100644 --- a/homeassistant/components/elgato/config_flow.py +++ b/homeassistant/components/elgato/config_flow.py @@ -132,5 +132,9 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN): async def _get_elgato_info(self, host: str, port: int) -> Info: """Get device information from an Elgato Key Light device.""" session = async_get_clientsession(self.hass) - elgato = Elgato(host, port=port, session=session,) + elgato = Elgato( + host, + port=port, + session=session, + ) return await elgato.info() diff --git a/homeassistant/components/elgato/light.py b/homeassistant/components/elgato/light.py index 9dae0cd1f40..313b5600248 100644 --- a/homeassistant/components/elgato/light.py +++ b/homeassistant/components/elgato/light.py @@ -49,7 +49,10 @@ class ElgatoLight(LightEntity): """Defines a Elgato Key Light.""" def __init__( - self, entry_id: str, elgato: Elgato, info: Info, + self, + entry_id: str, + elgato: Elgato, + info: Info, ): """Initialize Elgato Key Light.""" self._brightness: Optional[int] = None diff --git a/homeassistant/components/elkm1/__init__.py b/homeassistant/components/elkm1/__init__.py index 946e40b7e23..dbb45ec317f 100644 --- a/homeassistant/components/elkm1/__init__.py +++ b/homeassistant/components/elkm1/__init__.py @@ -173,7 +173,9 @@ async def async_setup(hass: HomeAssistant, hass_config: ConfigType) -> bool: hass.async_create_task( hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=conf, + DOMAIN, + context={"source": SOURCE_IMPORT}, + data=conf, ) ) diff --git a/homeassistant/components/emulated_hue/upnp.py b/homeassistant/components/emulated_hue/upnp.py index bc4def242c3..58f964d4984 100644 --- a/homeassistant/components/emulated_hue/upnp.py +++ b/homeassistant/components/emulated_hue/upnp.py @@ -57,7 +57,10 @@ class DescriptionXmlView(HomeAssistantView): @core.callback def create_upnp_datagram_endpoint( - host_ip_addr, upnp_bind_multicast, advertise_ip, advertise_port, + host_ip_addr, + upnp_bind_multicast, + advertise_ip, + advertise_port, ): """Create the UPNP socket and protocol.""" diff --git a/homeassistant/components/fibaro/climate.py b/homeassistant/components/fibaro/climate.py index 191185c4a2a..5776a293756 100644 --- a/homeassistant/components/fibaro/climate.py +++ b/homeassistant/components/fibaro/climate.py @@ -146,8 +146,8 @@ class FibaroThermostat(FibaroDevice, ClimateEntity): self._unit_of_temp = TEMP_CELSIUS if self._fan_mode_device: - fan_modes = self._fan_mode_device.fibaro_device.properties.supportedModes.split( - "," + fan_modes = ( + self._fan_mode_device.fibaro_device.properties.supportedModes.split(",") ) for mode in fan_modes: mode = int(mode) diff --git a/homeassistant/components/flume/__init__.py b/homeassistant/components/flume/__init__.py index cc618f64b4e..513f77edfb2 100644 --- a/homeassistant/components/flume/__init__.py +++ b/homeassistant/components/flume/__init__.py @@ -61,7 +61,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): ) ) flume_devices = await hass.async_add_executor_job( - partial(FlumeDeviceList, flume_auth, http_session=http_session,) + partial( + FlumeDeviceList, + flume_auth, + http_session=http_session, + ) ) except RequestException: raise ConfigEntryNotReady diff --git a/homeassistant/components/flunearyou/__init__.py b/homeassistant/components/flunearyou/__init__.py index 6e1c8ddb3d2..5e7ebd90cf1 100644 --- a/homeassistant/components/flunearyou/__init__.py +++ b/homeassistant/components/flunearyou/__init__.py @@ -184,7 +184,9 @@ class FluNearYouData: # If this is the first registration we have, start a time interval: if not self._async_cancel_time_interval_listener: self._async_cancel_time_interval_listener = async_track_time_interval( - self._hass, self._async_update_listener_action, DEFAULT_SCAN_INTERVAL, + self._hass, + self._async_update_listener_action, + DEFAULT_SCAN_INTERVAL, ) api_category = async_get_api_category(sensor_type) diff --git a/homeassistant/components/forked_daapd/config_flow.py b/homeassistant/components/forked_daapd/config_flow.py index 45ea8861d4a..faef33f8334 100644 --- a/homeassistant/components/forked_daapd/config_flow.py +++ b/homeassistant/components/forked_daapd/config_flow.py @@ -176,7 +176,8 @@ class ForkedDaapdFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): if entry.data.get(CONF_HOST) != discovery_info["host"]: continue self.hass.config_entries.async_update_entry( - entry, title=discovery_info["properties"]["Machine Name"], + entry, + title=discovery_info["properties"]["Machine Name"], ) return self.async_abort(reason="already_configured") diff --git a/homeassistant/components/freebox/__init__.py b/homeassistant/components/freebox/__init__.py index 9e303c75e7a..9120c7d0866 100644 --- a/homeassistant/components/freebox/__init__.py +++ b/homeassistant/components/freebox/__init__.py @@ -50,7 +50,9 @@ async def async_setup(hass, config): for freebox_conf in conf: hass.async_create_task( hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=freebox_conf, + DOMAIN, + context={"source": SOURCE_IMPORT}, + data=freebox_conf, ) ) diff --git a/homeassistant/components/freebox/config_flow.py b/homeassistant/components/freebox/config_flow.py index 9cef6aa0c38..0589dfb2ef1 100644 --- a/homeassistant/components/freebox/config_flow.py +++ b/homeassistant/components/freebox/config_flow.py @@ -82,7 +82,8 @@ class FreeboxFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): await fbx.close() return self.async_create_entry( - title=self._host, data={CONF_HOST: self._host, CONF_PORT: self._port}, + title=self._host, + data={CONF_HOST: self._host, CONF_PORT: self._port}, ) except AuthorizationError as error: diff --git a/homeassistant/components/geniushub/__init__.py b/homeassistant/components/geniushub/__init__.py index 0e779ebdcba..909de81521c 100644 --- a/homeassistant/components/geniushub/__init__.py +++ b/homeassistant/components/geniushub/__init__.py @@ -87,7 +87,8 @@ SET_ZONE_OVERRIDE_SCHEMA = vol.Schema( vol.Coerce(float), vol.Range(min=4, max=28) ), vol.Optional(ATTR_DURATION): vol.All( - cv.time_period, vol.Range(min=timedelta(minutes=5), max=timedelta(days=1)), + cv.time_period, + vol.Range(min=timedelta(minutes=5), max=timedelta(days=1)), ), } ) diff --git a/homeassistant/components/gios/config_flow.py b/homeassistant/components/gios/config_flow.py index 5741af47a07..dfef829c479 100644 --- a/homeassistant/components/gios/config_flow.py +++ b/homeassistant/components/gios/config_flow.py @@ -44,7 +44,8 @@ class GiosFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): await gios.update() return self.async_create_entry( - title=user_input[CONF_STATION_ID], data=user_input, + title=user_input[CONF_STATION_ID], + data=user_input, ) except (ApiError, ClientConnectorError, asyncio.TimeoutError): errors["base"] = "cannot_connect" diff --git a/homeassistant/components/glances/sensor.py b/homeassistant/components/glances/sensor.py index f701dfdb741..deb8650cd4f 100644 --- a/homeassistant/components/glances/sensor.py +++ b/homeassistant/components/glances/sensor.py @@ -157,7 +157,8 @@ class GlancesSensor(Entity): self._state = round(disk["free"] / 1024 ** 3, 1) except KeyError: self._state = round( - (disk["size"] - disk["used"]) / 1024 ** 3, 1, + (disk["size"] - disk["used"]) / 1024 ** 3, + 1, ) elif self.type == "sensor_temp": for sensor in value["sensors"]: diff --git a/homeassistant/components/google_assistant/helpers.py b/homeassistant/components/google_assistant/helpers.py index 49e08e90e4b..8ec2bce4602 100644 --- a/homeassistant/components/google_assistant/helpers.py +++ b/homeassistant/components/google_assistant/helpers.py @@ -208,7 +208,11 @@ class AbstractConfig(ABC): return webhook.async_register( - self.hass, DOMAIN, "Local Support", webhook_id, self._handle_local_webhook, + self.hass, + DOMAIN, + "Local Support", + webhook_id, + self._handle_local_webhook, ) self._local_sdk_active = True diff --git a/homeassistant/components/group/cover.py b/homeassistant/components/group/cover.py index 6a2111747d6..b0d0b8b7bd2 100644 --- a/homeassistant/components/group/cover.py +++ b/homeassistant/components/group/cover.py @@ -103,7 +103,10 @@ class CoverGroup(GroupEntity, CoverEntity): ) async def async_update_supported_features( - self, entity_id: str, new_state: Optional[State], update_state: bool = True, + self, + entity_id: str, + new_state: Optional[State], + update_state: bool = True, ) -> None: """Update dictionaries with supported features.""" if not new_state: diff --git a/homeassistant/components/guardian/switch.py b/homeassistant/components/guardian/switch.py index 6822fea6de2..8aebd078e04 100644 --- a/homeassistant/components/guardian/switch.py +++ b/homeassistant/components/guardian/switch.py @@ -156,7 +156,9 @@ class GuardianSwitch(GuardianEntity, SwitchEntity): try: async with self._client: await self._client.system.upgrade_firmware( - url=url, port=port, filename=filename, + url=url, + port=port, + filename=filename, ) except GuardianError as err: LOGGER.error("Error during service call: %s", err) diff --git a/homeassistant/components/harmony/remote.py b/homeassistant/components/harmony/remote.py index fe2f0535308..ff7825013e8 100644 --- a/homeassistant/components/harmony/remote.py +++ b/homeassistant/components/harmony/remote.py @@ -122,7 +122,9 @@ async def async_setup_entry( platform = entity_platform.current_platform.get() platform.async_register_entity_service( - SERVICE_SYNC, HARMONY_SYNC_SCHEMA, "sync", + SERVICE_SYNC, + HARMONY_SYNC_SCHEMA, + "sync", ) platform.async_register_entity_service( SERVICE_CHANGE_CHANNEL, HARMONY_CHANGE_CHANNEL_SCHEMA, "change_channel" diff --git a/homeassistant/components/hisense_aehw4a1/__init__.py b/homeassistant/components/hisense_aehw4a1/__init__.py index 721039d0e1c..a2412a2fed4 100644 --- a/homeassistant/components/hisense_aehw4a1/__init__.py +++ b/homeassistant/components/hisense_aehw4a1/__init__.py @@ -60,7 +60,8 @@ async def async_setup(hass, config): hass.data[DOMAIN] = conf hass.async_create_task( hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, + DOMAIN, + context={"source": config_entries.SOURCE_IMPORT}, ) ) diff --git a/homeassistant/components/history/__init__.py b/homeassistant/components/history/__init__.py index 9354800b843..0e6fabb66aa 100644 --- a/homeassistant/components/history/__init__.py +++ b/homeassistant/components/history/__init__.py @@ -297,7 +297,8 @@ def _get_states_with_session( most_recent_state_ids = most_recent_state_ids.subquery() query = query.join( - most_recent_state_ids, States.state_id == most_recent_state_ids.c.max_state_id, + most_recent_state_ids, + States.state_id == most_recent_state_ids.c.max_state_id, ).filter(~States.domain.in_(IGNORE_DOMAINS)) if filters: diff --git a/homeassistant/components/home_connect/__init__.py b/homeassistant/components/home_connect/__init__.py index 4e575963577..38f487a98a1 100644 --- a/homeassistant/components/home_connect/__init__.py +++ b/homeassistant/components/home_connect/__init__.py @@ -59,8 +59,10 @@ async def async_setup(hass: HomeAssistant, config: dict) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Home Connect from a config entry.""" - implementation = await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry + implementation = ( + await config_entry_oauth2_flow.async_get_config_entry_implementation( + hass, entry + ) ) hc_api = api.ConfigEntryAuth(hass, entry, implementation) diff --git a/homeassistant/components/home_connect/switch.py b/homeassistant/components/home_connect/switch.py index c5fcdef25b7..346e739e5ff 100644 --- a/homeassistant/components/home_connect/switch.py +++ b/homeassistant/components/home_connect/switch.py @@ -103,7 +103,9 @@ class HomeConnectPowerSwitch(HomeConnectEntity, SwitchEntity): _LOGGER.debug("Tried to switch on %s", self.name) try: await self.hass.async_add_executor_job( - self.device.appliance.set_setting, BSH_POWER_STATE, BSH_POWER_ON, + self.device.appliance.set_setting, + BSH_POWER_STATE, + BSH_POWER_ON, ) except HomeConnectError as err: _LOGGER.error("Error while trying to turn on device: %s", err) diff --git a/homeassistant/components/homeassistant/triggers/state.py b/homeassistant/components/homeassistant/triggers/state.py index 7ccba9aade8..d51e63964e9 100644 --- a/homeassistant/components/homeassistant/triggers/state.py +++ b/homeassistant/components/homeassistant/triggers/state.py @@ -143,7 +143,11 @@ async def async_attach_trigger( return cur_value == new_value unsub_track_same[entity] = async_track_same_state( - hass, period[entity], call_action, _check_same_state, entity_ids=entity, + hass, + period[entity], + call_action, + _check_same_state, + entity_ids=entity, ) unsub = async_track_state_change_event(hass, entity_id, state_automation_listener) diff --git a/homeassistant/components/homekit/__init__.py b/homeassistant/components/homekit/__init__.py index 2b6db6af528..d1c909cf2b0 100644 --- a/homeassistant/components/homekit/__init__.py +++ b/homeassistant/components/homekit/__init__.py @@ -172,7 +172,9 @@ async def async_setup(hass: HomeAssistant, config: dict): conf[CONF_ENTRY_INDEX] = index hass.async_create_task( hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=conf, + DOMAIN, + context={"source": SOURCE_IMPORT}, + data=conf, ) ) @@ -632,14 +634,16 @@ class HomeKit: ) if motion_binary_sensor_entity_id: self._config.setdefault(state.entity_id, {}).setdefault( - CONF_LINKED_MOTION_SENSOR, motion_binary_sensor_entity_id, + CONF_LINKED_MOTION_SENSOR, + motion_binary_sensor_entity_id, ) doorbell_binary_sensor_entity_id = device_lookup[ent_reg_ent.device_id].get( (BINARY_SENSOR_DOMAIN, DEVICE_CLASS_OCCUPANCY) ) if doorbell_binary_sensor_entity_id: self._config.setdefault(state.entity_id, {}).setdefault( - CONF_LINKED_DOORBELL_SENSOR, doorbell_binary_sensor_entity_id, + CONF_LINKED_DOORBELL_SENSOR, + doorbell_binary_sensor_entity_id, ) if state.entity_id.startswith(f"{HUMIDIFIER_DOMAIN}."): @@ -648,7 +652,8 @@ class HomeKit: ].get((SENSOR_DOMAIN, DEVICE_CLASS_HUMIDITY)) if current_humidity_sensor_entity_id: self._config.setdefault(state.entity_id, {}).setdefault( - CONF_LINKED_HUMIDITY_SENSOR, current_humidity_sensor_entity_id, + CONF_LINKED_HUMIDITY_SENSOR, + current_humidity_sensor_entity_id, ) async def _async_set_device_info_attributes(self, ent_reg_ent, dev_reg, entity_id): diff --git a/homeassistant/components/homekit/config_flow.py b/homeassistant/components/homekit/config_flow.py index 2d0d2df40b7..6a3206ac41b 100644 --- a/homeassistant/components/homekit/config_flow.py +++ b/homeassistant/components/homekit/config_flow.py @@ -261,7 +261,8 @@ class OptionsFlowHandler(config_entries.OptionsFlow): data_schema = vol.Schema( { vol.Optional( - CONF_CAMERA_COPY, default=cameras_with_copy, + CONF_CAMERA_COPY, + default=cameras_with_copy, ): cv.multi_select(self.included_cameras), } ) diff --git a/homeassistant/components/homekit/img_util.py b/homeassistant/components/homekit/img_util.py index 235cfe60df5..2baede8d957 100644 --- a/homeassistant/components/homekit/img_util.py +++ b/homeassistant/components/homekit/img_util.py @@ -27,7 +27,9 @@ def scale_jpeg_camera_image(cam_image, width, height): break return turbo_jpeg.scale_with_quality( - cam_image.content, scaling_factor=scaling_factor, quality=75, + cam_image.content, + scaling_factor=scaling_factor, + quality=75, ) diff --git a/homeassistant/components/homekit/type_cameras.py b/homeassistant/components/homekit/type_cameras.py index 91b13a93eca..0febd7461e5 100644 --- a/homeassistant/components/homekit/type_cameras.py +++ b/homeassistant/components/homekit/type_cameras.py @@ -220,15 +220,18 @@ class Camera(HomeAccessory, PyhapCamera): serv_doorbell = self.add_preload_service(SERV_DOORBELL) self.set_primary_service(serv_doorbell) self._char_doorbell_detected = serv_doorbell.configure_char( - CHAR_PROGRAMMABLE_SWITCH_EVENT, value=0, + CHAR_PROGRAMMABLE_SWITCH_EVENT, + value=0, ) serv_stateless_switch = self.add_preload_service( SERV_STATELESS_PROGRAMMABLE_SWITCH ) - self._char_doorbell_detected_switch = serv_stateless_switch.configure_char( - CHAR_PROGRAMMABLE_SWITCH_EVENT, - value=0, - valid_values={"SinglePress": DOORBELL_SINGLE_PRESS}, + self._char_doorbell_detected_switch = ( + serv_stateless_switch.configure_char( + CHAR_PROGRAMMABLE_SWITCH_EVENT, + value=0, + valid_values={"SinglePress": DOORBELL_SINGLE_PRESS}, + ) ) serv_speaker = self.add_preload_service(SERV_SPEAKER) serv_speaker.configure_char(CHAR_MUTE, value=0) @@ -387,7 +390,9 @@ class Camera(HomeAccessory, PyhapCamera): await self._async_ffmpeg_watch(session_info["id"]) session_info[FFMPEG_WATCHER] = async_track_time_interval( - self.hass, watch_session, FFMPEG_WATCH_INTERVAL, + self.hass, + watch_session, + FFMPEG_WATCH_INTERVAL, ) return await self._async_ffmpeg_watch(session_info["id"]) diff --git a/homeassistant/components/homekit/type_humidifiers.py b/homeassistant/components/homekit/type_humidifiers.py index f59015a392d..7175198c4b5 100644 --- a/homeassistant/components/homekit/type_humidifiers.py +++ b/homeassistant/components/homekit/type_humidifiers.py @@ -88,17 +88,21 @@ class HumidifierDehumidifier(HomeAccessory): ) # Current and target mode characteristics - self.char_current_humidifier_dehumidifier = serv_humidifier_dehumidifier.configure_char( - CHAR_CURRENT_HUMIDIFIER_DEHUMIDIFIER, value=0 + self.char_current_humidifier_dehumidifier = ( + serv_humidifier_dehumidifier.configure_char( + CHAR_CURRENT_HUMIDIFIER_DEHUMIDIFIER, value=0 + ) ) - self.char_target_humidifier_dehumidifier = serv_humidifier_dehumidifier.configure_char( - CHAR_TARGET_HUMIDIFIER_DEHUMIDIFIER, - value=self._hk_device_class, - valid_values={ - HC_HASS_TO_HOMEKIT_DEVICE_CLASS_NAME[ - device_class - ]: self._hk_device_class - }, + self.char_target_humidifier_dehumidifier = ( + serv_humidifier_dehumidifier.configure_char( + CHAR_TARGET_HUMIDIFIER_DEHUMIDIFIER, + value=self._hk_device_class, + valid_values={ + HC_HASS_TO_HOMEKIT_DEVICE_CLASS_NAME[ + device_class + ]: self._hk_device_class + }, + ) ) # Current and target humidity characteristics diff --git a/homeassistant/components/homekit/type_media_players.py b/homeassistant/components/homekit/type_media_players.py index 91cdd25ee42..c278322f77e 100644 --- a/homeassistant/components/homekit/type_media_players.py +++ b/homeassistant/components/homekit/type_media_players.py @@ -231,7 +231,9 @@ class MediaPlayer(HomeAccessory): if self.chars[FEATURE_PLAY_STOP]: hk_state = current_state == STATE_PLAYING _LOGGER.debug( - '%s: Set current state for "play_stop" to %s', self.entity_id, hk_state, + '%s: Set current state for "play_stop" to %s', + self.entity_id, + hk_state, ) if self.chars[FEATURE_PLAY_STOP].value != hk_state: self.chars[FEATURE_PLAY_STOP].set_value(hk_state) @@ -414,7 +416,9 @@ class TelevisionMediaPlayer(HomeAccessory): if CHAR_VOLUME_SELECTOR in self.chars_speaker: current_mute_state = bool(new_state.attributes.get(ATTR_MEDIA_VOLUME_MUTED)) _LOGGER.debug( - "%s: Set current mute state to %s", self.entity_id, current_mute_state, + "%s: Set current mute state to %s", + self.entity_id, + current_mute_state, ) if self.char_mute.value != current_mute_state: self.char_mute.set_value(current_mute_state) @@ -429,7 +433,8 @@ class TelevisionMediaPlayer(HomeAccessory): self.char_input_source.set_value(index) elif hk_state: _LOGGER.warning( - "%s: Sources out of sync. Restart Home Assistant", self.entity_id, + "%s: Sources out of sync. Restart Home Assistant", + self.entity_id, ) if self.char_input_source.value != 0: self.char_input_source.set_value(0) diff --git a/homeassistant/components/homekit/type_thermostats.py b/homeassistant/components/homekit/type_thermostats.py index 1d0d760b963..7f588af77fe 100644 --- a/homeassistant/components/homekit/type_thermostats.py +++ b/homeassistant/components/homekit/type_thermostats.py @@ -325,7 +325,10 @@ class Thermostat(HomeAccessory): if service: params[ATTR_ENTITY_ID] = self.entity_id self.call_service( - DOMAIN_CLIMATE, service, params, ", ".join(events), + DOMAIN_CLIMATE, + service, + params, + ", ".join(events), ) if CHAR_TARGET_HUMIDITY in char_values: diff --git a/homeassistant/components/homekit_controller/climate.py b/homeassistant/components/homekit_controller/climate.py index 8551f4dddd5..546e46d67cb 100644 --- a/homeassistant/components/homekit_controller/climate.py +++ b/homeassistant/components/homekit_controller/climate.py @@ -287,7 +287,8 @@ class HomeKitHeaterCoolerEntity(HomeKitEntity, ClimateEntity): Requires SUPPORT_SWING_MODE. """ valid_values = clamp_enum_to_char( - SwingModeValues, self.service[CharacteristicsTypes.SWING_MODE], + SwingModeValues, + self.service[CharacteristicsTypes.SWING_MODE], ) return [SWING_MODE_HOMEKIT_TO_HASS[mode] for mode in valid_values] diff --git a/homeassistant/components/homekit_controller/connection.py b/homeassistant/components/homekit_controller/connection.py index a5deb8aa9bc..6a59f98f3dc 100644 --- a/homeassistant/components/homekit_controller/connection.py +++ b/homeassistant/components/homekit_controller/connection.py @@ -212,7 +212,8 @@ class HKDevice: ) device = device_registry.async_get_or_create( - config_entry_id=self.config_entry.entry_id, **device_info, + config_entry_id=self.config_entry.entry_id, + **device_info, ) devices[accessory.aid] = device.id diff --git a/homeassistant/components/homekit_controller/media_player.py b/homeassistant/components/homekit_controller/media_player.py index 249b8c9c3e0..2ffc794409b 100644 --- a/homeassistant/components/homekit_controller/media_player.py +++ b/homeassistant/components/homekit_controller/media_player.py @@ -129,7 +129,8 @@ class HomeKitTelevision(HomeKitEntity, MediaPlayerEntity): this_tv = this_accessory.services.iid(self._iid) input_sources = this_accessory.services.filter( - service_type=ServicesTypes.INPUT_SOURCE, parent_service=this_tv, + service_type=ServicesTypes.INPUT_SOURCE, + parent_service=this_tv, ) for input_source in input_sources: diff --git a/homeassistant/components/honeywell/climate.py b/homeassistant/components/honeywell/climate.py index 07ac6c9b217..0e7958a3ea1 100644 --- a/homeassistant/components/honeywell/climate.py +++ b/homeassistant/components/honeywell/climate.py @@ -130,7 +130,12 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities( [ HoneywellUSThermostat( - client, device, cool_away_temp, heat_away_temp, username, password, + client, + device, + cool_away_temp, + heat_away_temp, + username, + password, ) for location in client.locations_by_id.values() for device in location.devices_by_id.values() diff --git a/homeassistant/components/http/ban.py b/homeassistant/components/http/ban.py index d17c57cbc08..979fe7981f4 100644 --- a/homeassistant/components/http/ban.py +++ b/homeassistant/components/http/ban.py @@ -124,8 +124,9 @@ async def process_wrong_login(request): request.app[KEY_FAILED_LOGIN_ATTEMPTS][remote_addr] += 1 # Supervisor IP should never be banned - if "hassio" in hass.config.components and hass.components.hassio.get_supervisor_ip() == str( - remote_addr + if ( + "hassio" in hass.config.components + and hass.components.hassio.get_supervisor_ip() == str(remote_addr) ): return diff --git a/homeassistant/components/http/view.py b/homeassistant/components/http/view.py index 376465f375b..7766d5a0cb9 100644 --- a/homeassistant/components/http/view.py +++ b/homeassistant/components/http/view.py @@ -43,7 +43,9 @@ class HomeAssistantView: @staticmethod def json( - result: Any, status_code: int = HTTP_OK, headers: Optional[LooseHeaders] = None, + result: Any, + status_code: int = HTTP_OK, + headers: Optional[LooseHeaders] = None, ) -> web.Response: """Return a JSON response.""" try: @@ -114,7 +116,10 @@ def request_handler_factory(view: HomeAssistantView, handler: Callable) -> Calla raise HTTPUnauthorized() _LOGGER.debug( - "Serving %s to %s (auth: %s)", request.path, request.remote, authenticated, + "Serving %s to %s (auth: %s)", + request.path, + request.remote, + authenticated, ) try: diff --git a/homeassistant/components/huawei_lte/__init__.py b/homeassistant/components/huawei_lte/__init__.py index 8b12cd0975e..8241655d2fa 100644 --- a/homeassistant/components/huawei_lte/__init__.py +++ b/homeassistant/components/huawei_lte/__init__.py @@ -195,7 +195,8 @@ class Router: _LOGGER.debug("Trying to authorize again...") if self.connection.enforce_authorized_connection(): _LOGGER.debug( - "...success, %s will be updated by a future periodic run", key, + "...success, %s will be updated by a future periodic run", + key, ) else: _LOGGER.debug("...failed") @@ -523,7 +524,10 @@ async def async_setup(hass: HomeAssistantType, config) -> bool: for service in ADMIN_SERVICES: hass.helpers.service.async_register_admin_service( - DOMAIN, service, service_handler, schema=SERVICE_SCHEMA, + DOMAIN, + service, + service_handler, + schema=SERVICE_SCHEMA, ) for url, router_config in domain_config.items(): diff --git a/homeassistant/components/huawei_lte/sensor.py b/homeassistant/components/huawei_lte/sensor.py index 247fb3b6bdc..f547dbd2eb6 100644 --- a/homeassistant/components/huawei_lte/sensor.py +++ b/homeassistant/components/huawei_lte/sensor.py @@ -178,8 +178,12 @@ SENSOR_META = { name="Operator search mode", formatter=lambda x: ({"0": "Auto", "1": "Manual"}.get(x, "Unknown"), None), ), - (KEY_NET_CURRENT_PLMN, "FullName"): dict(name="Operator name",), - (KEY_NET_CURRENT_PLMN, "Numeric"): dict(name="Operator code",), + (KEY_NET_CURRENT_PLMN, "FullName"): dict( + name="Operator name", + ), + (KEY_NET_CURRENT_PLMN, "Numeric"): dict( + name="Operator code", + ), KEY_NET_NET_MODE: dict(include=re.compile(r"^NetworkMode$", re.IGNORECASE)), (KEY_NET_NET_MODE, "NetworkMode"): dict( name="Preferred mode", @@ -197,7 +201,8 @@ SENSOR_META = { ), ), (KEY_SMS_SMS_COUNT, "LocalUnread"): dict( - name="SMS unread", icon="mdi:email-receive", + name="SMS unread", + icon="mdi:email-receive", ), } diff --git a/homeassistant/components/hue/__init__.py b/homeassistant/components/hue/__init__.py index 1131d68baec..a99f9dd8a2a 100644 --- a/homeassistant/components/hue/__init__.py +++ b/homeassistant/components/hue/__init__.py @@ -44,7 +44,8 @@ CONFIG_SCHEMA = vol.Schema( DOMAIN: vol.Schema( { vol.Optional(CONF_BRIDGES): vol.All( - cv.ensure_list, [BRIDGE_CONFIG_SCHEMA], + cv.ensure_list, + [BRIDGE_CONFIG_SCHEMA], ) } ) @@ -149,7 +150,8 @@ async def async_setup_entry( if options: hass.config_entries.async_update_entry( - entry, options={**entry.options, **options}, + entry, + options={**entry.options, **options}, ) bridge = HueBridge(hass, entry) diff --git a/homeassistant/components/hue/sensor_base.py b/homeassistant/components/hue/sensor_base.py index 93b98a7c9ce..af8986e0212 100644 --- a/homeassistant/components/hue/sensor_base.py +++ b/homeassistant/components/hue/sensor_base.py @@ -150,7 +150,9 @@ class SensorManager: self.bridge.hass.async_create_task( remove_devices( - self.bridge, [value.uniqueid for value in api.values()], current, + self.bridge, + [value.uniqueid for value in api.values()], + current, ) ) diff --git a/homeassistant/components/image/__init__.py b/homeassistant/components/image/__init__.py index a8110decd0a..91085ce4e64 100644 --- a/homeassistant/components/image/__init__.py +++ b/homeassistant/components/image/__init__.py @@ -41,7 +41,11 @@ async def async_setup(hass: HomeAssistant, config: dict): hass.data[DOMAIN] = storage_collection = ImageStorageCollection(hass, image_dir) await storage_collection.async_load() collection.StorageCollectionWebsocket( - storage_collection, DOMAIN, DOMAIN, CREATE_FIELDS, UPDATE_FIELDS, + storage_collection, + DOMAIN, + DOMAIN, + CREATE_FIELDS, + UPDATE_FIELDS, ).async_setup(hass, create_create=False) hass.http.register_view(ImageUploadView) @@ -94,7 +98,7 @@ class ImageStorageCollection(collection.StorageCollection): # Reset content uploaded_file.file.seek(0) - media_folder: pathlib.Path = (self.image_dir / data[CONF_ID]) + media_folder: pathlib.Path = self.image_dir / data[CONF_ID] media_folder.mkdir(parents=True) media_file = media_folder / "original" diff --git a/homeassistant/components/influxdb/__init__.py b/homeassistant/components/influxdb/__init__.py index 555a268b62a..60939741894 100644 --- a/homeassistant/components/influxdb/__init__.py +++ b/homeassistant/components/influxdb/__init__.py @@ -179,7 +179,10 @@ INFLUX_SCHEMA = vol.All( create_influx_url, ) -CONFIG_SCHEMA = vol.Schema({DOMAIN: INFLUX_SCHEMA}, extra=vol.ALLOW_EXTRA,) +CONFIG_SCHEMA = vol.Schema( + {DOMAIN: INFLUX_SCHEMA}, + extra=vol.ALLOW_EXTRA, +) def _generate_event_to_json(conf: Dict) -> Callable[[Dict], str]: diff --git a/homeassistant/components/influxdb/const.py b/homeassistant/components/influxdb/const.py index a9115c3fc68..c1b5ce3a591 100644 --- a/homeassistant/components/influxdb/const.py +++ b/homeassistant/components/influxdb/const.py @@ -129,7 +129,8 @@ RENDERING_WHERE_ERROR_MESSAGE = "Could not render where template: %s." COMPONENT_CONFIG_SCHEMA_CONNECTION = { # Connection config for V1 and V2 APIs. vol.Optional(CONF_API_VERSION, default=DEFAULT_API_VERSION): vol.All( - vol.Coerce(str), vol.In([DEFAULT_API_VERSION, API_VERSION_2]), + vol.Coerce(str), + vol.In([DEFAULT_API_VERSION, API_VERSION_2]), ), vol.Optional(CONF_HOST): cv.string, vol.Optional(CONF_PATH): cv.string, diff --git a/homeassistant/components/insteon/__init__.py b/homeassistant/components/insteon/__init__.py index 62032b681b8..b567179fa4f 100644 --- a/homeassistant/components/insteon/__init__.py +++ b/homeassistant/components/insteon/__init__.py @@ -109,7 +109,8 @@ async def async_import_config(hass, conf): if result["type"] == RESULT_TYPE_CREATE_ENTRY and options: entry = result["result"] hass.config_entries.async_update_entry( - entry=entry, options=options, + entry=entry, + options=options, ) return result diff --git a/homeassistant/components/insteon/config_flow.py b/homeassistant/components/insteon/config_flow.py index 40e8b81f440..c6045893365 100644 --- a/homeassistant/components/insteon/config_flow.py +++ b/homeassistant/components/insteon/config_flow.py @@ -248,7 +248,8 @@ class InsteonOptionsFlowHandler(config_entries.OptionsFlow): data[CONF_PASSWORD] = user_input[CONF_PASSWORD] self.hass.config_entries.async_update_entry(self.config_entry, data=data) return self.async_create_entry( - title="", data={**self.config_entry.options}, + title="", + data={**self.config_entry.options}, ) data_schema = build_hub_schema(**self.config_entry.data) return self.async_show_form( @@ -291,7 +292,9 @@ class InsteonOptionsFlowHandler(config_entries.OptionsFlow): if user_input is not None: options = _remove_override(user_input[CONF_ADDRESS], options) async_dispatcher_send( - self.hass, SIGNAL_REMOVE_DEVICE_OVERRIDE, user_input[CONF_ADDRESS], + self.hass, + SIGNAL_REMOVE_DEVICE_OVERRIDE, + user_input[CONF_ADDRESS], ) return self.async_create_entry(title="", data=options) diff --git a/homeassistant/components/insteon/insteon_entity.py b/homeassistant/components/insteon/insteon_entity.py index 851675513da..3bef7dd0247 100644 --- a/homeassistant/components/insteon/insteon_entity.py +++ b/homeassistant/components/insteon/insteon_entity.py @@ -94,7 +94,10 @@ class InsteonEntity(Entity): def async_entity_update(self, name, address, value, group): """Receive notification from transport that new data exists.""" _LOGGER.debug( - "Received update for device %s group %d value %s", address, group, value, + "Received update for device %s group %d value %s", + address, + group, + value, ) self.async_write_ha_state() diff --git a/homeassistant/components/ipp/__init__.py b/homeassistant/components/ipp/__init__.py index 0e2b559d5e4..07d1258d735 100644 --- a/homeassistant/components/ipp/__init__.py +++ b/homeassistant/components/ipp/__init__.py @@ -110,7 +110,10 @@ class IPPDataUpdateCoordinator(DataUpdateCoordinator[IPPPrinter]): ) super().__init__( - hass, _LOGGER, name=DOMAIN, update_interval=SCAN_INTERVAL, + hass, + _LOGGER, + name=DOMAIN, + update_interval=SCAN_INTERVAL, ) async def _async_update_data(self) -> IPPPrinter: diff --git a/homeassistant/components/ipp/config_flow.py b/homeassistant/components/ipp/config_flow.py index 671bb2dd4cd..476756ddc61 100644 --- a/homeassistant/components/ipp/config_flow.py +++ b/homeassistant/components/ipp/config_flow.py @@ -177,7 +177,8 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN): ) return self.async_create_entry( - title=self.discovery_info[CONF_NAME], data=self.discovery_info, + title=self.discovery_info[CONF_NAME], + data=self.discovery_info, ) def _show_setup_form(self, errors: Optional[Dict] = None) -> Dict[str, Any]: diff --git a/homeassistant/components/iqvia/__init__.py b/homeassistant/components/iqvia/__init__.py index 3e67e2639e2..171e7977e95 100644 --- a/homeassistant/components/iqvia/__init__.py +++ b/homeassistant/components/iqvia/__init__.py @@ -180,7 +180,9 @@ class IQVIAData: # If this is the first registration we have, start a time interval: if not self._async_cancel_time_interval_listener: self._async_cancel_time_interval_listener = async_track_time_interval( - self._hass, self._async_update_listener_action, DEFAULT_SCAN_INTERVAL, + self._hass, + self._async_update_listener_action, + DEFAULT_SCAN_INTERVAL, ) api_category = async_get_api_category(sensor_type) diff --git a/homeassistant/components/knx/__init__.py b/homeassistant/components/knx/__init__.py index 4de801a19d1..989efc9b376 100644 --- a/homeassistant/components/knx/__init__.py +++ b/homeassistant/components/knx/__init__.py @@ -400,7 +400,10 @@ class KNXExposeSensor: else: _name = self.entity_id self.device = ExposeSensor( - self.xknx, name=_name, group_address=self.address, value_type=self.type, + self.xknx, + name=_name, + group_address=self.address, + value_type=self.type, ) self.xknx.devices.add(self.device) async_track_state_change_event( diff --git a/homeassistant/components/knx/factory.py b/homeassistant/components/knx/factory.py index f53a7436122..64245d61a08 100644 --- a/homeassistant/components/knx/factory.py +++ b/homeassistant/components/knx/factory.py @@ -218,7 +218,9 @@ def _create_sensor(knx_module: XKNX, config: ConfigType) -> XknxSensor: def _create_notify(knx_module: XKNX, config: ConfigType) -> XknxNotification: """Return a KNX notification to be used within XKNX.""" return XknxNotification( - knx_module, name=config[CONF_NAME], group_address=config[CONF_ADDRESS], + knx_module, + name=config[CONF_NAME], + group_address=config[CONF_ADDRESS], ) diff --git a/homeassistant/components/kodi/__init__.py b/homeassistant/components/kodi/__init__.py index dedb0ab09c4..f3cb15a17eb 100644 --- a/homeassistant/components/kodi/__init__.py +++ b/homeassistant/components/kodi/__init__.py @@ -57,7 +57,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): raise ConfigEntryNotReady from error except InvalidAuthError as error: _LOGGER.error( - "Login to %s failed: [%s]", entry.data[CONF_HOST], error, + "Login to %s failed: [%s]", + entry.data[CONF_HOST], + error, ) return False diff --git a/homeassistant/components/kodi/config_flow.py b/homeassistant/components/kodi/config_flow.py index 34e08ff56e4..f10dcbb2d28 100644 --- a/homeassistant/components/kodi/config_flow.py +++ b/homeassistant/components/kodi/config_flow.py @@ -284,7 +284,8 @@ class KodiConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @callback def _create_entry(self): return self.async_create_entry( - title=self._name or self._host, data=self._get_data(), + title=self._name or self._host, + data=self._get_data(), ) @callback diff --git a/homeassistant/components/konnected/config_flow.py b/homeassistant/components/konnected/config_flow.py index 420d517234b..88888da44f8 100644 --- a/homeassistant/components/konnected/config_flow.py +++ b/homeassistant/components/konnected/config_flow.py @@ -349,7 +349,8 @@ class KonnectedFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): ) or "".join(random.choices(f"{string.ascii_uppercase}{string.digits}", k=20)) return self.async_create_entry( - title=KONN_PANEL_MODEL_NAMES[self.data[CONF_MODEL]], data=self.data, + title=KONN_PANEL_MODEL_NAMES[self.data[CONF_MODEL]], + data=self.data, ) @staticmethod diff --git a/homeassistant/components/konnected/panel.py b/homeassistant/components/konnected/panel.py index 3fcb51929ed..bd91bf3adbc 100644 --- a/homeassistant/components/konnected/panel.py +++ b/homeassistant/components/konnected/panel.py @@ -168,12 +168,20 @@ class AlarmPanel: if self.client: if self.api_version == CONF_ZONE: return await self.client.put_zone( - zone, state, momentary, times, pause, + zone, + state, + momentary, + times, + pause, ) # device endpoint uses pin number instead of zone return await self.client.put_device( - ZONE_TO_PIN[zone], state, momentary, times, pause, + ZONE_TO_PIN[zone], + state, + momentary, + times, + pause, ) except self.client.ClientError as err: @@ -208,7 +216,8 @@ class AlarmPanel: act = { CONF_ZONE: zone, CONF_NAME: entity.get( - CONF_NAME, f"Konnected {self.device_id[6:]} Actuator {zone}", + CONF_NAME, + f"Konnected {self.device_id[6:]} Actuator {zone}", ), ATTR_STATE: None, CONF_ACTIVATION: entity[CONF_ACTIVATION], diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index 14a870696ce..b97e9e90248 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -469,5 +469,6 @@ class Light(LightEntity): """Print deprecation warning.""" super().__init_subclass__(**kwargs) _LOGGER.warning( - "Light is deprecated, modify %s to extend LightEntity", cls.__name__, + "Light is deprecated, modify %s to extend LightEntity", + cls.__name__, ) diff --git a/homeassistant/components/lock/__init__.py b/homeassistant/components/lock/__init__.py index fb10580a1cc..addd5d9a257 100644 --- a/homeassistant/components/lock/__init__.py +++ b/homeassistant/components/lock/__init__.py @@ -145,5 +145,6 @@ class LockDevice(LockEntity): """Print deprecation warning.""" super().__init_subclass__(**kwargs) _LOGGER.warning( - "LockDevice is deprecated, modify %s to extend LockEntity", cls.__name__, + "LockDevice is deprecated, modify %s to extend LockEntity", + cls.__name__, ) diff --git a/homeassistant/components/lovelace/__init__.py b/homeassistant/components/lovelace/__init__.py index b9ddef67768..2a8c97f3d4e 100644 --- a/homeassistant/components/lovelace/__init__.py +++ b/homeassistant/components/lovelace/__init__.py @@ -58,7 +58,8 @@ CONFIG_SCHEMA = vol.Schema( vol.Lower, vol.In([MODE_YAML, MODE_STORAGE]) ), vol.Optional(CONF_DASHBOARDS): cv.schema_with_slug_keys( - YAML_DASHBOARD_SCHEMA, slug_validator=url_slug, + YAML_DASHBOARD_SCHEMA, + slug_validator=url_slug, ), vol.Optional(CONF_RESOURCES): [RESOURCE_SCHEMA], } diff --git a/homeassistant/components/meteo_france/__init__.py b/homeassistant/components/meteo_france/__init__.py index e2049543ef3..152999b5574 100644 --- a/homeassistant/components/meteo_france/__init__.py +++ b/homeassistant/components/meteo_france/__init__.py @@ -33,7 +33,8 @@ SCAN_INTERVAL = timedelta(minutes=15) CITY_SCHEMA = vol.Schema({vol.Required(CONF_CITY): cv.string}) CONFIG_SCHEMA = vol.Schema( - {DOMAIN: vol.Schema(vol.All(cv.ensure_list, [CITY_SCHEMA]))}, extra=vol.ALLOW_EXTRA, + {DOMAIN: vol.Schema(vol.All(cv.ensure_list, [CITY_SCHEMA]))}, + extra=vol.ALLOW_EXTRA, ) @@ -130,7 +131,9 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool department = coordinator_forecast.data.position.get("dept") _LOGGER.debug( - "Department corresponding to %s is %s", entry.title, department, + "Department corresponding to %s is %s", + entry.title, + department, ) if is_valid_warning_department(department): if not hass.data[DOMAIN].get(department): diff --git a/homeassistant/components/meteo_france/config_flow.py b/homeassistant/components/meteo_france/config_flow.py index 0854c280c16..4593a392ee3 100644 --- a/homeassistant/components/meteo_france/config_flow.py +++ b/homeassistant/components/meteo_france/config_flow.py @@ -74,7 +74,8 @@ class MeteoFranceFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): self._abort_if_unique_id_configured() return self.async_create_entry( - title=city, data={CONF_LATITUDE: latitude, CONF_LONGITUDE: longitude}, + title=city, + data={CONF_LATITUDE: latitude, CONF_LONGITUDE: longitude}, ) async def async_step_import(self, user_input): diff --git a/homeassistant/components/meteo_france/sensor.py b/homeassistant/components/meteo_france/sensor.py index 927250c6af6..178df5c992f 100644 --- a/homeassistant/components/meteo_france/sensor.py +++ b/homeassistant/components/meteo_france/sensor.py @@ -64,7 +64,8 @@ async def async_setup_entry( entities.append(MeteoFranceSensor(sensor_type, coordinator_forecast)) async_add_entities( - entities, False, + entities, + False, ) diff --git a/homeassistant/components/meteo_france/weather.py b/homeassistant/components/meteo_france/weather.py index e8afcea9702..6f110dbcdeb 100644 --- a/homeassistant/components/meteo_france/weather.py +++ b/homeassistant/components/meteo_france/weather.py @@ -47,7 +47,8 @@ async def async_setup_entry( async_add_entities( [ MeteoFranceWeather( - coordinator, entry.options.get(CONF_MODE, FORECAST_MODE_DAILY), + coordinator, + entry.options.get(CONF_MODE, FORECAST_MODE_DAILY), ) ], True, diff --git a/homeassistant/components/metoffice/weather.py b/homeassistant/components/metoffice/weather.py index f94c2a4ad7a..809943c616f 100644 --- a/homeassistant/components/metoffice/weather.py +++ b/homeassistant/components/metoffice/weather.py @@ -29,7 +29,13 @@ async def async_setup_entry( hass_data = hass.data[DOMAIN][entry.entry_id] async_add_entities( - [MetOfficeWeather(entry.data, hass_data,)], False, + [ + MetOfficeWeather( + entry.data, + hass_data, + ) + ], + False, ) diff --git a/homeassistant/components/mikrotik/hub.py b/homeassistant/components/mikrotik/hub.py index 0b4ea0c5ea3..1dc6041b535 100644 --- a/homeassistant/components/mikrotik/hub.py +++ b/homeassistant/components/mikrotik/hub.py @@ -401,7 +401,10 @@ def get_api(hass, entry): try: api = librouteros.connect( - entry[CONF_HOST], entry[CONF_USERNAME], entry[CONF_PASSWORD], **kwargs, + entry[CONF_HOST], + entry[CONF_USERNAME], + entry[CONF_PASSWORD], + **kwargs, ) _LOGGER.debug("Connected to %s successfully", entry[CONF_HOST]) return api diff --git a/homeassistant/components/mill/config_flow.py b/homeassistant/components/mill/config_flow.py index 08eb0f5c536..230849cc78d 100644 --- a/homeassistant/components/mill/config_flow.py +++ b/homeassistant/components/mill/config_flow.py @@ -27,14 +27,18 @@ class MillConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): """Handle the initial step.""" if user_input is None: return self.async_show_form( - step_id="user", data_schema=DATA_SCHEMA, errors={}, + step_id="user", + data_schema=DATA_SCHEMA, + errors={}, ) username = user_input[CONF_USERNAME].replace(" ", "") password = user_input[CONF_PASSWORD].replace(" ", "") mill_data_connection = Mill( - username, password, websession=async_get_clientsession(self.hass), + username, + password, + websession=async_get_clientsession(self.hass), ) errors = {} @@ -42,7 +46,9 @@ class MillConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): if not await mill_data_connection.connect(): errors["connection_error"] = "connection_error" return self.async_show_form( - step_id="user", data_schema=DATA_SCHEMA, errors=errors, + step_id="user", + data_schema=DATA_SCHEMA, + errors=errors, ) unique_id = username @@ -51,5 +57,6 @@ class MillConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self._abort_if_unique_id_configured() return self.async_create_entry( - title=unique_id, data={CONF_USERNAME: username, CONF_PASSWORD: password}, + title=unique_id, + data={CONF_USERNAME: username, CONF_PASSWORD: password}, ) diff --git a/homeassistant/components/mobile_app/webhook.py b/homeassistant/components/mobile_app/webhook.py index e7ff49f71f2..8820d08a518 100644 --- a/homeassistant/components/mobile_app/webhook.py +++ b/homeassistant/components/mobile_app/webhook.py @@ -251,7 +251,9 @@ async def webhook_stream_camera(hass, config_entry, data): if camera is None: return webhook_response( - {"success": False}, registration=config_entry.data, status=HTTP_BAD_REQUEST, + {"success": False}, + registration=config_entry.data, + status=HTTP_BAD_REQUEST, ) resp = {"mjpeg_path": "/api/camera_proxy_stream/%s" % (camera.entity_id)} @@ -342,7 +344,8 @@ async def webhook_update_registration(hass, config_entry, data): hass.config_entries.async_update_entry(config_entry, data=new_registration) return webhook_response( - safe_registration(new_registration), registration=new_registration, + safe_registration(new_registration), + registration=new_registration, ) @@ -420,7 +423,9 @@ async def webhook_register_sensor(hass, config_entry, data): async_dispatcher_send(hass, register_signal, data) return webhook_response( - {"success": True}, registration=config_entry.data, status=HTTP_CREATED, + {"success": True}, + registration=config_entry.data, + status=HTTP_CREATED, ) diff --git a/homeassistant/components/monoprice/config_flow.py b/homeassistant/components/monoprice/config_flow.py index 6c6bc87bf28..ddaafd01d8c 100644 --- a/homeassistant/components/monoprice/config_flow.py +++ b/homeassistant/components/monoprice/config_flow.py @@ -138,7 +138,10 @@ class MonopriceOptionsFlowHandler(config_entries.OptionsFlow): for idx, source in enumerate(SOURCES) } - return self.async_show_form(step_id="init", data_schema=vol.Schema(options),) + return self.async_show_form( + step_id="init", + data_schema=vol.Schema(options), + ) class CannotConnect(exceptions.HomeAssistantError): diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index 865f21b9d38..869dc27cfd6 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -531,7 +531,11 @@ async def async_setup_entry(hass, entry): conf = _merge_config(entry, conf) - hass.data[DATA_MQTT] = MQTT(hass, entry, conf,) + hass.data[DATA_MQTT] = MQTT( + hass, + entry, + conf, + ) await hass.data[DATA_MQTT].async_connect() @@ -620,7 +624,12 @@ class Subscription: class MQTT: """Home Assistant MQTT client.""" - def __init__(self, hass: HomeAssistantType, config_entry, conf,) -> None: + def __init__( + self, + hass: HomeAssistantType, + config_entry, + conf, + ) -> None: """Initialize Home Assistant MQTT client.""" # We don't import on the top because some integrations # should be able to optionally rely on MQTT. @@ -1177,7 +1186,9 @@ class MqttAvailability(Entity): } self._availability_sub_state = await async_subscribe_topics( - self.hass, self._availability_sub_state, topics, + self.hass, + self._availability_sub_state, + topics, ) @callback @@ -1256,7 +1267,9 @@ class MqttDiscoveryUpdate(Entity): async def discovery_callback(payload): """Handle discovery update.""" _LOGGER.info( - "Got update for entity with hash: %s '%s'", discovery_hash, payload, + "Got update for entity with hash: %s '%s'", + discovery_hash, + payload, ) old_payload = self._discovery_data[ATTR_DISCOVERY_PAYLOAD] debug_info.update_entity_discovery_data(self.hass, payload, self.entity_id) @@ -1291,7 +1304,10 @@ class MqttDiscoveryUpdate(Entity): if not self._removed_from_hass: discovery_topic = self._discovery_data[ATTR_DISCOVERY_TOPIC] publish( - self.hass, discovery_topic, "", retain=True, + self.hass, + discovery_topic, + "", + retain=True, ) async def async_will_remove_from_hass(self) -> None: diff --git a/homeassistant/components/mqtt/climate.py b/homeassistant/components/mqtt/climate.py index 3bd8aae9239..20ee183d693 100644 --- a/homeassistant/components/mqtt/climate.py +++ b/homeassistant/components/mqtt/climate.py @@ -170,7 +170,8 @@ PLATFORM_SCHEMA = ( vol.Optional(CONF_DEVICE): mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA, vol.Optional(CONF_FAN_MODE_COMMAND_TOPIC): mqtt.valid_publish_topic, vol.Optional( - CONF_FAN_MODE_LIST, default=[FAN_AUTO, FAN_LOW, FAN_MEDIUM, FAN_HIGH], + CONF_FAN_MODE_LIST, + default=[FAN_AUTO, FAN_LOW, FAN_MEDIUM, FAN_HIGH], ): cv.ensure_list, vol.Optional(CONF_FAN_MODE_STATE_TEMPLATE): cv.template, vol.Optional(CONF_FAN_MODE_STATE_TOPIC): mqtt.valid_subscribe_topic, diff --git a/homeassistant/components/mqtt/config_flow.py b/homeassistant/components/mqtt/config_flow.py index 4a5847366f7..8b1c350323c 100644 --- a/homeassistant/components/mqtt/config_flow.py +++ b/homeassistant/components/mqtt/config_flow.py @@ -196,7 +196,9 @@ class MQTTOptionsFlowHandler(config_entries.OptionsFlow): ] = str return self.async_show_form( - step_id="broker", data_schema=vol.Schema(fields), errors=errors, + step_id="broker", + data_schema=vol.Schema(fields), + errors=errors, ) async def async_step_options(self, user_input=None): @@ -305,7 +307,9 @@ class MQTTOptionsFlowHandler(config_entries.OptionsFlow): fields[vol.Optional("will_retain", default=will[ATTR_RETAIN])] = bool return self.async_show_form( - step_id="options", data_schema=vol.Schema(fields), errors=errors, + step_id="options", + data_schema=vol.Schema(fields), + errors=errors, ) diff --git a/homeassistant/components/mqtt/device_trigger.py b/homeassistant/components/mqtt/device_trigger.py index 01eb84e66e7..676252c3134 100644 --- a/homeassistant/components/mqtt/device_trigger.py +++ b/homeassistant/components/mqtt/device_trigger.py @@ -93,7 +93,10 @@ class TriggerInstance: if self.remove: self.remove() self.remove = await mqtt_trigger.async_attach_trigger( - self.trigger.hass, mqtt_config, self.action, self.automation_info, + self.trigger.hass, + mqtt_config, + self.action, + self.automation_info, ) @@ -256,7 +259,10 @@ async def async_device_removed(hass: HomeAssistant, device_id: str): clear_discovery_hash(hass, discovery_hash) device_trigger.remove_signal() mqtt.publish( - hass, discovery_topic, "", retain=True, + hass, + discovery_topic, + "", + retain=True, ) diff --git a/homeassistant/components/mysensors/gateway.py b/homeassistant/components/mysensors/gateway.py index d906c306dfc..56c1562eea0 100644 --- a/homeassistant/components/mysensors/gateway.py +++ b/homeassistant/components/mysensors/gateway.py @@ -73,7 +73,8 @@ async def setup_gateways(hass, config): for index, gateway_conf in enumerate(conf[CONF_GATEWAYS]): persistence_file = gateway_conf.get( - CONF_PERSISTENCE_FILE, hass.config.path(f"mysensors{index + 1}.pickle"), + CONF_PERSISTENCE_FILE, + hass.config.path(f"mysensors{index + 1}.pickle"), ) ready_gateway = await _get_gateway(hass, config, gateway_conf, persistence_file) if ready_gateway is not None: diff --git a/homeassistant/components/nad/media_player.py b/homeassistant/components/nad/media_player.py index 6145a89a594..a98e4eafe2d 100644 --- a/homeassistant/components/nad/media_player.py +++ b/homeassistant/components/nad/media_player.py @@ -66,11 +66,13 @@ def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the NAD platform.""" if config.get(CONF_TYPE) in ("RS232", "Telnet"): add_entities( - [NAD(config)], True, + [NAD(config)], + True, ) else: add_entities( - [NADtcp(config)], True, + [NADtcp(config)], + True, ) diff --git a/homeassistant/components/netatmo/__init__.py b/homeassistant/components/netatmo/__init__.py index 0995511abcc..f68683a152d 100644 --- a/homeassistant/components/netatmo/__init__.py +++ b/homeassistant/components/netatmo/__init__.py @@ -83,8 +83,10 @@ async def async_setup(hass: HomeAssistant, config: dict): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Netatmo from a config entry.""" - implementation = await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry + implementation = ( + await config_entry_oauth2_flow.async_get_config_entry_implementation( + hass, entry + ) ) # Set unique id if non was set (migration) diff --git a/homeassistant/components/netatmo/api.py b/homeassistant/components/netatmo/api.py index b8b259ed5c1..6c5aee818d5 100644 --- a/homeassistant/components/netatmo/api.py +++ b/homeassistant/components/netatmo/api.py @@ -26,7 +26,9 @@ class ConfigEntryNetatmoAuth(pyatmo.auth.NetatmoOAuth2): ) super().__init__(token=self.session.token) - def refresh_tokens(self,) -> dict: + def refresh_tokens( + self, + ) -> dict: """Refresh and return new Netatmo tokens using Home Assistant OAuth2 session.""" run_coroutine_threadsafe( self.session.async_ensure_token_valid(), self.hass.loop diff --git a/homeassistant/components/netatmo/camera.py b/homeassistant/components/netatmo/camera.py index 39f6839d331..bb46e25af3f 100644 --- a/homeassistant/components/netatmo/camera.py +++ b/homeassistant/components/netatmo/camera.py @@ -107,7 +107,12 @@ class NetatmoCamera(NetatmoBase, Camera): """Representation of a Netatmo camera.""" def __init__( - self, data_handler, camera_id, camera_type, home_id, quality, + self, + data_handler, + camera_id, + camera_type, + home_id, + quality, ): """Set up for access to the Netatmo camera images.""" Camera.__init__(self) @@ -172,7 +177,9 @@ class NetatmoCamera(NetatmoBase, Camera): ) elif self._vpnurl: response = requests.get( - f"{self._vpnurl}/live/snapshot_720.jpg", timeout=10, verify=True, + f"{self._vpnurl}/live/snapshot_720.jpg", + timeout=10, + verify=True, ) else: _LOGGER.error("Welcome/Presence VPN URL is None") @@ -283,12 +290,14 @@ class NetatmoCamera(NetatmoBase, Camera): if person_id is not None: self._data.set_persons_away( - person_id=person_id, home_id=self._home_id, + person_id=person_id, + home_id=self._home_id, ) _LOGGER.debug("Set %s as away", person) else: self._data.set_persons_away( - person_id=person_id, home_id=self._home_id, + person_id=person_id, + home_id=self._home_id, ) _LOGGER.debug("Set home as empty") diff --git a/homeassistant/components/netatmo/climate.py b/homeassistant/components/netatmo/climate.py index c23f8f47bef..f24591fe954 100644 --- a/homeassistant/components/netatmo/climate.py +++ b/homeassistant/components/netatmo/climate.py @@ -337,12 +337,15 @@ class NetatmoThermostat(NetatmoBase, ClimateEntity): """Set new preset mode.""" if self.target_temperature == 0: self._home_status.set_room_thermpoint( - self._id, STATE_NETATMO_HOME, + self._id, + STATE_NETATMO_HOME, ) if preset_mode in [PRESET_BOOST, STATE_NETATMO_MAX] and self._model == NA_VALVE: self._home_status.set_room_thermpoint( - self._id, STATE_NETATMO_MANUAL, DEFAULT_MAX_TEMP, + self._id, + STATE_NETATMO_MANUAL, + DEFAULT_MAX_TEMP, ) elif preset_mode in [PRESET_BOOST, STATE_NETATMO_MAX]: self._home_status.set_room_thermpoint( @@ -393,7 +396,9 @@ class NetatmoThermostat(NetatmoBase, ClimateEntity): """Turn the entity off.""" if self._model == NA_VALVE: self._home_status.set_room_thermpoint( - self._id, STATE_NETATMO_MANUAL, DEFAULT_MIN_TEMP, + self._id, + STATE_NETATMO_MANUAL, + DEFAULT_MIN_TEMP, ) elif self.hvac_mode != HVAC_MODE_OFF: self._home_status.set_room_thermpoint(self._id, STATE_NETATMO_OFF) diff --git a/homeassistant/components/netatmo/config_flow.py b/homeassistant/components/netatmo/config_flow.py index c78a5169d3b..6ae1fd864df 100644 --- a/homeassistant/components/netatmo/config_flow.py +++ b/homeassistant/components/netatmo/config_flow.py @@ -111,13 +111,16 @@ class NetatmoOptionsFlowHandler(config_entries.OptionsFlow): data_schema = vol.Schema( { vol.Optional( - CONF_WEATHER_AREAS, default=weather_areas, + CONF_WEATHER_AREAS, + default=weather_areas, ): cv.multi_select(weather_areas), vol.Optional(CONF_NEW_AREA): str, } ) return self.async_show_form( - step_id="public_weather_areas", data_schema=data_schema, errors=errors, + step_id="public_weather_areas", + data_schema=data_schema, + errors=errors, ) async def async_step_public_weather(self, user_input=None): @@ -169,10 +172,12 @@ class NetatmoOptionsFlowHandler(config_entries.OptionsFlow): ), ): cv.longitude, vol.Required( - CONF_PUBLIC_MODE, default=orig_options.get(CONF_PUBLIC_MODE, "avg"), + CONF_PUBLIC_MODE, + default=orig_options.get(CONF_PUBLIC_MODE, "avg"), ): vol.In(["avg", "max"]), vol.Required( - CONF_SHOW_ON_MAP, default=orig_options.get(CONF_SHOW_ON_MAP, False), + CONF_SHOW_ON_MAP, + default=orig_options.get(CONF_SHOW_ON_MAP, False), ): bool, } ) diff --git a/homeassistant/components/netatmo/data_handler.py b/homeassistant/components/netatmo/data_handler.py index 5354e7cec75..c9be4237229 100644 --- a/homeassistant/components/netatmo/data_handler.py +++ b/homeassistant/components/netatmo/data_handler.py @@ -70,7 +70,9 @@ class NetatmoDataHandler: self.listeners.append( async_dispatcher_connect( - self.hass, f"signal-{DOMAIN}-webhook-None", self.handle_event, + self.hass, + f"signal-{DOMAIN}-webhook-None", + self.handle_event, ) ) @@ -113,7 +115,8 @@ class NetatmoDataHandler: """Fetch data and notify.""" try: self.data[data_class_entry] = await self.hass.async_add_executor_job( - partial(data_class, **kwargs), self._auth, + partial(data_class, **kwargs), + self._auth, ) for update_callback in self._data_classes[data_class_entry][ "subscriptions" diff --git a/homeassistant/components/netatmo/light.py b/homeassistant/components/netatmo/light.py index dea56e54c09..a41dae33641 100644 --- a/homeassistant/components/netatmo/light.py +++ b/homeassistant/components/netatmo/light.py @@ -59,7 +59,10 @@ async def async_setup_entry(hass, entry, async_add_entities): _LOGGER.debug("Adding camera light %s %s", camera["id"], camera["name"]) entities.append( NetatmoLight( - data_handler, camera["id"], camera["type"], camera["home_id"], + data_handler, + camera["id"], + camera["type"], + camera["home_id"], ) ) @@ -132,14 +135,18 @@ class NetatmoLight(NetatmoBase, LightEntity): """Turn camera floodlight on.""" _LOGGER.debug("Turn camera '%s' on", self._name) self._data.set_state( - home_id=self._home_id, camera_id=self._id, floodlight="on", + home_id=self._home_id, + camera_id=self._id, + floodlight="on", ) def turn_off(self, **kwargs): """Turn camera floodlight into auto mode.""" _LOGGER.debug("Turn camera '%s' off", self._name) self._data.set_state( - home_id=self._home_id, camera_id=self._id, floodlight="auto", + home_id=self._home_id, + camera_id=self._id, + floodlight="auto", ) @callback diff --git a/homeassistant/components/netatmo/sensor.py b/homeassistant/components/netatmo/sensor.py index 3b704e00508..4dadd101e39 100644 --- a/homeassistant/components/netatmo/sensor.py +++ b/homeassistant/components/netatmo/sensor.py @@ -128,7 +128,9 @@ async def async_setup_entry(hass, entry, async_add_entities): continue _LOGGER.debug( - "Adding module %s %s", module.get("module_name"), module.get("_id"), + "Adding module %s %s", + module.get("module_name"), + module.get("_id"), ) conditions = [ c.lower() @@ -179,7 +181,9 @@ async def async_setup_entry(hass, entry, async_add_entities): if update: async_dispatcher_send( - hass, f"netatmo-config-{area.area_name}", area, + hass, + f"netatmo-config-{area.area_name}", + area, ) continue diff --git a/homeassistant/components/netgear/device_tracker.py b/homeassistant/components/netgear/device_tracker.py index 5f18553ba62..f30277086de 100644 --- a/homeassistant/components/netgear/device_tracker.py +++ b/homeassistant/components/netgear/device_tracker.py @@ -71,7 +71,11 @@ class NetgearDeviceScanner(DeviceScanner): """Queries a Netgear wireless router using the SOAP-API.""" def __init__( - self, api, devices, excluded_devices, accesspoints, + self, + api, + devices, + excluded_devices, + accesspoints, ): """Initialize the scanner.""" self.tracked_devices = devices diff --git a/homeassistant/components/nexia/scene.py b/homeassistant/components/nexia/scene.py index 12689f05538..1700de3f059 100644 --- a/homeassistant/components/nexia/scene.py +++ b/homeassistant/components/nexia/scene.py @@ -34,7 +34,9 @@ class NexiaAutomationScene(NexiaEntity, Scene): def __init__(self, coordinator, automation): """Initialize the automation scene.""" super().__init__( - coordinator, name=automation.name, unique_id=automation.automation_id, + coordinator, + name=automation.name, + unique_id=automation.automation_id, ) self._automation = automation diff --git a/homeassistant/components/nexia/sensor.py b/homeassistant/components/nexia/sensor.py index abbffa2b844..ea2fd2b5718 100644 --- a/homeassistant/components/nexia/sensor.py +++ b/homeassistant/components/nexia/sensor.py @@ -126,7 +126,12 @@ async def async_setup_entry(hass, config_entry, async_add_entities): # Zone Status entities.append( NexiaThermostatZoneSensor( - coordinator, zone, "get_status", "Zone Status", None, None, + coordinator, + zone, + "get_status", + "Zone Status", + None, + None, ) ) # Setpoint Status diff --git a/homeassistant/components/nuki/lock.py b/homeassistant/components/nuki/lock.py index f7414d54802..d8585ad7458 100644 --- a/homeassistant/components/nuki/lock.py +++ b/homeassistant/components/nuki/lock.py @@ -51,7 +51,11 @@ LOCK_N_GO_SERVICE_SCHEMA = vol.Schema( def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Nuki lock platform.""" bridge = NukiBridge( - config[CONF_HOST], config[CONF_TOKEN], config[CONF_PORT], True, DEFAULT_TIMEOUT, + config[CONF_HOST], + config[CONF_TOKEN], + config[CONF_PORT], + True, + DEFAULT_TIMEOUT, ) devices = [NukiLockEntity(lock) for lock in bridge.locks] @@ -67,7 +71,10 @@ def setup_platform(hass, config, add_entities, discovery_info=None): lock.lock_n_go(unlatch=unlatch) hass.services.register( - DOMAIN, SERVICE_LOCK_N_GO, service_handler, schema=LOCK_N_GO_SERVICE_SCHEMA, + DOMAIN, + SERVICE_LOCK_N_GO, + service_handler, + schema=LOCK_N_GO_SERVICE_SCHEMA, ) devices.extend([NukiOpenerEntity(opener) for opener in bridge.openers]) diff --git a/homeassistant/components/numato/binary_sensor.py b/homeassistant/components/numato/binary_sensor.py index be8d3f62afa..426f072aebd 100644 --- a/homeassistant/components/numato/binary_sensor.py +++ b/homeassistant/components/numato/binary_sensor.py @@ -58,7 +58,13 @@ def setup_platform(hass, config, add_entities, discovery_info=None): continue binary_sensors.append( - NumatoGpioBinarySensor(port_name, device_id, port, invert_logic, api,) + NumatoGpioBinarySensor( + port_name, + device_id, + port, + invert_logic, + api, + ) ) add_entities(binary_sensors, True) diff --git a/homeassistant/components/numato/switch.py b/homeassistant/components/numato/switch.py index 2f1be0cf311..505d28d0c40 100644 --- a/homeassistant/components/numato/switch.py +++ b/homeassistant/components/numato/switch.py @@ -43,7 +43,13 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) continue switches.append( - NumatoGpioSwitch(port_name, device_id, port, invert_logic, api,) + NumatoGpioSwitch( + port_name, + device_id, + port, + invert_logic, + api, + ) ) add_entities(switches, True) diff --git a/homeassistant/components/nut/config_flow.py b/homeassistant/components/nut/config_flow.py index 7cebf0c6759..33306e24acb 100644 --- a/homeassistant/components/nut/config_flow.py +++ b/homeassistant/components/nut/config_flow.py @@ -194,7 +194,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return await self.async_step_resources() return self.async_show_form( - step_id="ups", data_schema=_ups_schema(self.ups_list), errors=errors, + step_id="ups", + data_schema=_ups_schema(self.ups_list), + errors=errors, ) async def async_step_resources(self, user_input=None): @@ -264,7 +266,8 @@ class OptionsFlowHandler(config_entries.OptionsFlow): ] = cv.positive_int return self.async_show_form( - step_id="init", data_schema=vol.Schema(base_schema), + step_id="init", + data_schema=vol.Schema(base_schema), ) diff --git a/homeassistant/components/nx584/alarm_control_panel.py b/homeassistant/components/nx584/alarm_control_panel.py index 23dbfbb090c..7ce882e3c82 100644 --- a/homeassistant/components/nx584/alarm_control_panel.py +++ b/homeassistant/components/nx584/alarm_control_panel.py @@ -57,7 +57,8 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= await hass.async_add_executor_job(alarm_client.list_zones) except requests.exceptions.ConnectionError as ex: _LOGGER.error( - "Unable to connect to %(host)s: %(reason)s", dict(host=url, reason=ex), + "Unable to connect to %(host)s: %(reason)s", + dict(host=url, reason=ex), ) raise PlatformNotReady @@ -67,7 +68,9 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= platform = entity_platform.current_platform.get() platform.async_register_entity_service( - SERVICE_BYPASS_ZONE, {vol.Required(ATTR_ZONE): cv.positive_int}, "alarm_bypass", + SERVICE_BYPASS_ZONE, + {vol.Required(ATTR_ZONE): cv.positive_int}, + "alarm_bypass", ) platform.async_register_entity_service( diff --git a/homeassistant/components/openuv/config_flow.py b/homeassistant/components/openuv/config_flow.py index bf359ef1b30..9dfb053ff01 100644 --- a/homeassistant/components/openuv/config_flow.py +++ b/homeassistant/components/openuv/config_flow.py @@ -33,7 +33,9 @@ class OpenUvFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def _show_form(self, errors=None): """Show the form to the user.""" return self.async_show_form( - step_id="user", data_schema=CONFIG_SCHEMA, errors=errors if errors else {}, + step_id="user", + data_schema=CONFIG_SCHEMA, + errors=errors if errors else {}, ) async def async_step_import(self, import_config): diff --git a/homeassistant/components/ovo_energy/sensor.py b/homeassistant/components/ovo_energy/sensor.py index a0781836d6c..8b0cddd3752 100644 --- a/homeassistant/components/ovo_energy/sensor.py +++ b/homeassistant/components/ovo_energy/sensor.py @@ -54,7 +54,8 @@ async def async_setup_entry( ) async_add_entities( - entities, True, + entities, + True, ) diff --git a/homeassistant/components/ozw/services.py b/homeassistant/components/ozw/services.py index b9281953ac9..500289cec21 100644 --- a/homeassistant/components/ozw/services.py +++ b/homeassistant/components/ozw/services.py @@ -86,7 +86,9 @@ class ZWaveServices: if payload is None: _LOGGER.error( - "Invalid value %s for parameter %s", selection, param, + "Invalid value %s for parameter %s", + selection, + param, ) return diff --git a/homeassistant/components/ozw/websocket_api.py b/homeassistant/components/ozw/websocket_api.py index 8d17b6d8d45..6e1a725b7a7 100644 --- a/homeassistant/components/ozw/websocket_api.py +++ b/homeassistant/components/ozw/websocket_api.py @@ -40,7 +40,8 @@ def websocket_get_instances(hass, connection, msg): instances.append(dict(instance.get_status().data, ozw_instance=instance.id)) connection.send_result( - msg[ID], instances, + msg[ID], + instances, ) @@ -56,7 +57,8 @@ def websocket_network_status(hass, connection, msg): manager = hass.data[DOMAIN][MANAGER] status = manager.get_instance(msg[OZW_INSTANCE]).get_status().data connection.send_result( - msg[ID], dict(status, ozw_instance=msg[OZW_INSTANCE]), + msg[ID], + dict(status, ozw_instance=msg[OZW_INSTANCE]), ) diff --git a/homeassistant/components/panasonic_viera/__init__.py b/homeassistant/components/panasonic_viera/__init__.py index 30b9190d4d1..2095c5cc209 100644 --- a/homeassistant/components/panasonic_viera/__init__.py +++ b/homeassistant/components/panasonic_viera/__init__.py @@ -115,7 +115,13 @@ class Remote: """The Remote class. It stores the TV properties and the remote control connection itself.""" def __init__( - self, hass, host, port, on_action=None, app_id=None, encryption_key=None, + self, + hass, + host, + port, + on_action=None, + app_id=None, + encryption_key=None, ): """Initialize the Remote class.""" self._hass = hass diff --git a/homeassistant/components/panasonic_viera/config_flow.py b/homeassistant/components/panasonic_viera/config_flow.py index 2416f01baf3..d08e293eb45 100644 --- a/homeassistant/components/panasonic_viera/config_flow.py +++ b/homeassistant/components/panasonic_viera/config_flow.py @@ -64,7 +64,8 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return await self.async_step_pairing() return self.async_create_entry( - title=self._data[CONF_NAME], data=self._data, + title=self._data[CONF_NAME], + data=self._data, ) return self.async_show_form( @@ -117,7 +118,8 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self._data = {**self._data, **encryption_data} return self.async_create_entry( - title=self._data[CONF_NAME], data=self._data, + title=self._data[CONF_NAME], + data=self._data, ) try: diff --git a/homeassistant/components/panel_custom/__init__.py b/homeassistant/components/panel_custom/__init__.py index 2cdcb8d37c4..e663665675c 100644 --- a/homeassistant/components/panel_custom/__init__.py +++ b/homeassistant/components/panel_custom/__init__.py @@ -60,9 +60,15 @@ CONFIG_SCHEMA = vol.Schema( ): cv.icon, vol.Optional(CONF_URL_PATH): cv.string, vol.Optional(CONF_CONFIG): dict, - vol.Optional(CONF_WEBCOMPONENT_PATH,): cv.string, - vol.Optional(CONF_JS_URL,): cv.string, - vol.Optional(CONF_MODULE_URL,): cv.string, + vol.Optional( + CONF_WEBCOMPONENT_PATH, + ): cv.string, + vol.Optional( + CONF_JS_URL, + ): cv.string, + vol.Optional( + CONF_MODULE_URL, + ): cv.string, vol.Optional( CONF_EMBED_IFRAME, default=DEFAULT_EMBED_IFRAME ): cv.boolean, diff --git a/homeassistant/components/pi_hole/__init__.py b/homeassistant/components/pi_hole/__init__.py index 9b51cc09b35..5e7fc723cc4 100644 --- a/homeassistant/components/pi_hole/__init__.py +++ b/homeassistant/components/pi_hole/__init__.py @@ -85,7 +85,12 @@ async def async_setup_entry(hass, entry): try: session = async_get_clientsession(hass, verify_tls) api = Hole( - host, hass.loop, session, location=location, tls=use_tls, api_token=api_key, + host, + hass.loop, + session, + location=location, + tls=use_tls, + api_token=api_key, ) await api.get_data() except HoleError as ex: diff --git a/homeassistant/components/plex/server.py b/homeassistant/components/plex/server.py index a1bf56eb54f..2ddb5ef0a29 100644 --- a/homeassistant/components/plex/server.py +++ b/homeassistant/components/plex/server.py @@ -481,7 +481,8 @@ class PlexServer: return None except NotFound: _LOGGER.error( - "Playlist '%s' not found", playlist_name, + "Playlist '%s' not found", + playlist_name, ) return None @@ -581,7 +582,9 @@ class PlexServer: season = show.season(int(season_number)) except NotFound: _LOGGER.error( - "Season %d of '%s' not found", season_number, show_name, + "Season %d of '%s' not found", + season_number, + show_name, ) return None @@ -611,5 +614,7 @@ class PlexServer: _LOGGER.error("Must specify 'video_name' for this search") except NotFound: _LOGGER.error( - "Movie '%s' not found in '%s'", video_name, library_name, + "Movie '%s' not found in '%s'", + video_name, + library_name, ) diff --git a/homeassistant/components/plum_lightpad/config_flow.py b/homeassistant/components/plum_lightpad/config_flow.py index 6645aef02a2..c6261307d13 100644 --- a/homeassistant/components/plum_lightpad/config_flow.py +++ b/homeassistant/components/plum_lightpad/config_flow.py @@ -28,7 +28,9 @@ class PlumLightpadConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): } return self.async_show_form( - step_id="user", data_schema=vol.Schema(schema), errors=errors or {}, + step_id="user", + data_schema=vol.Schema(schema), + errors=errors or {}, ) async def async_step_user( diff --git a/homeassistant/components/powerwall/__init__.py b/homeassistant/components/powerwall/__init__.py index 0f25a14546d..9c1ea7afe53 100644 --- a/homeassistant/components/powerwall/__init__.py +++ b/homeassistant/components/powerwall/__init__.py @@ -52,7 +52,9 @@ async def async_setup(hass: HomeAssistant, config: dict): hass.async_create_task( hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=conf, + DOMAIN, + context={"source": SOURCE_IMPORT}, + data=conf, ) ) return True diff --git a/homeassistant/components/prometheus/__init__.py b/homeassistant/components/prometheus/__init__.py index 1a70e4cf78e..d9aa4bd6090 100644 --- a/homeassistant/components/prometheus/__init__.py +++ b/homeassistant/components/prometheus/__init__.py @@ -332,7 +332,10 @@ class PrometheusMetrics: current_action = state.attributes.get(ATTR_HVAC_ACTION) if current_action: metric = self._metric( - "climate_action", self.prometheus_cli.Gauge, "HVAC action", ["action"], + "climate_action", + self.prometheus_cli.Gauge, + "HVAC action", + ["action"], ) for action in CURRENT_HVAC_ACTIONS: metric.labels(**dict(self._labels(state), action=action)).set( diff --git a/homeassistant/components/rachio/entity.py b/homeassistant/components/rachio/entity.py index 379c4e785e5..ec1807b04c2 100644 --- a/homeassistant/components/rachio/entity.py +++ b/homeassistant/components/rachio/entity.py @@ -23,9 +23,17 @@ class RachioDevice(Entity): def device_info(self): """Return the device_info of the device.""" return { - "identifiers": {(DOMAIN, self._controller.serial_number,)}, + "identifiers": { + ( + DOMAIN, + self._controller.serial_number, + ) + }, "connections": { - (device_registry.CONNECTION_NETWORK_MAC, self._controller.mac_address,) + ( + device_registry.CONNECTION_NETWORK_MAC, + self._controller.mac_address, + ) }, "name": self._controller.name, "model": self._controller.model, diff --git a/homeassistant/components/rachio/switch.py b/homeassistant/components/rachio/switch.py index 6fa992adb81..32ec6267941 100644 --- a/homeassistant/components/rachio/switch.py +++ b/homeassistant/components/rachio/switch.py @@ -456,7 +456,9 @@ class RachioSchedule(RachioSwitch): """Start this schedule.""" self._controller.rachio.schedulerule.start(self._schedule_id) _LOGGER.debug( - "Schedule %s started on %s", self.name, self._controller.name, + "Schedule %s started on %s", + self.name, + self._controller.name, ) def turn_off(self, **kwargs) -> None: diff --git a/homeassistant/components/radiotherm/climate.py b/homeassistant/components/radiotherm/climate.py index c5e7f2f956e..4383cf97a2d 100644 --- a/homeassistant/components/radiotherm/climate.py +++ b/homeassistant/components/radiotherm/climate.py @@ -371,5 +371,6 @@ class RadioThermostat(ClimateEntity): self.device.program_mode = PRESET_MODE_TO_CODE[preset_mode] else: _LOGGER.error( - "preset_mode %s not in PRESET_MODES", preset_mode, + "preset_mode %s not in PRESET_MODES", + preset_mode, ) diff --git a/homeassistant/components/rainbird/switch.py b/homeassistant/components/rainbird/switch.py index 1fd162c07b7..9041128be60 100644 --- a/homeassistant/components/rainbird/switch.py +++ b/homeassistant/components/rainbird/switch.py @@ -45,7 +45,10 @@ def setup_platform(hass, config, add_entities, discovery_info=None): name = zone_config.get(CONF_FRIENDLY_NAME) devices.append( RainBirdSwitch( - controller, zone, time, name if name else f"Sprinkler {zone}", + controller, + zone, + time, + name if name else f"Sprinkler {zone}", ) ) diff --git a/homeassistant/components/recorder/__init__.py b/homeassistant/components/recorder/__init__.py index d2930988aee..f93f498987f 100644 --- a/homeassistant/components/recorder/__init__.py +++ b/homeassistant/components/recorder/__init__.py @@ -412,7 +412,8 @@ class Recorder(threading.Thread): except Exception as err: # pylint: disable=broad-except # Must catch the exception to prevent the loop from collapsing _LOGGER.error( - "Error in database connectivity during keepalive: %s", err, + "Error in database connectivity during keepalive: %s", + err, ) self._reopen_event_session() diff --git a/homeassistant/components/recorder/purge.py b/homeassistant/components/recorder/purge.py index b80f4670c36..fee4480e134 100644 --- a/homeassistant/components/recorder/purge.py +++ b/homeassistant/components/recorder/purge.py @@ -30,14 +30,16 @@ def purge_old_data(instance, purge_days: int, repack: bool) -> bool: states = execute(query, to_native=True, validate_entity_ids=False) if states: batch_purge_before = min( - batch_purge_before, states[0].last_updated + timedelta(hours=1), + batch_purge_before, + states[0].last_updated + timedelta(hours=1), ) query = session.query(Events).order_by(Events.time_fired.asc()).limit(1) events = execute(query, to_native=True) if events: batch_purge_before = min( - batch_purge_before, events[0].time_fired + timedelta(hours=1), + batch_purge_before, + events[0].time_fired + timedelta(hours=1), ) _LOGGER.debug("Purging states and events before %s", batch_purge_before) diff --git a/homeassistant/components/recorder/util.py b/homeassistant/components/recorder/util.py index 07516f2c22c..7503d0fe774 100644 --- a/homeassistant/components/recorder/util.py +++ b/homeassistant/components/recorder/util.py @@ -96,7 +96,9 @@ def execute(qry, to_native=False, validate_entity_ids=True): ) else: _LOGGER.debug( - "querying %d rows took %fs", len(result), elapsed, + "querying %d rows took %fs", + len(result), + elapsed, ) return result diff --git a/homeassistant/components/rfxtrx/__init__.py b/homeassistant/components/rfxtrx/__init__.py index 04d2078e182..8b0f4364e09 100644 --- a/homeassistant/components/rfxtrx/__init__.py +++ b/homeassistant/components/rfxtrx/__init__.py @@ -161,7 +161,9 @@ async def async_setup(hass, config): hass.async_create_task( hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=data, + DOMAIN, + context={"source": config_entries.SOURCE_IMPORT}, + data=data, ) ) return True diff --git a/homeassistant/components/rfxtrx/binary_sensor.py b/homeassistant/components/rfxtrx/binary_sensor.py index 8f7229299ee..21f3e0b74b3 100644 --- a/homeassistant/components/rfxtrx/binary_sensor.py +++ b/homeassistant/components/rfxtrx/binary_sensor.py @@ -62,7 +62,9 @@ DEVICE_TYPE_DEVICE_CLASS = { async def async_setup_entry( - hass, config_entry, async_add_entities, + hass, + config_entry, + async_add_entities, ): """Set up platform.""" sensors = [] diff --git a/homeassistant/components/rfxtrx/cover.py b/homeassistant/components/rfxtrx/cover.py index 8b5886191a5..fc6ab6cbf15 100644 --- a/homeassistant/components/rfxtrx/cover.py +++ b/homeassistant/components/rfxtrx/cover.py @@ -21,7 +21,9 @@ _LOGGER = logging.getLogger(__name__) async def async_setup_entry( - hass, config_entry, async_add_entities, + hass, + config_entry, + async_add_entities, ): """Set up config entry.""" discovery_info = config_entry.data diff --git a/homeassistant/components/rfxtrx/light.py b/homeassistant/components/rfxtrx/light.py index 44472b6c33c..791cc158693 100644 --- a/homeassistant/components/rfxtrx/light.py +++ b/homeassistant/components/rfxtrx/light.py @@ -29,7 +29,9 @@ SUPPORT_RFXTRX = SUPPORT_BRIGHTNESS async def async_setup_entry( - hass, config_entry, async_add_entities, + hass, + config_entry, + async_add_entities, ): """Set up config entry.""" discovery_info = config_entry.data diff --git a/homeassistant/components/rfxtrx/sensor.py b/homeassistant/components/rfxtrx/sensor.py index 8110e8d8c6c..4acde6b0450 100644 --- a/homeassistant/components/rfxtrx/sensor.py +++ b/homeassistant/components/rfxtrx/sensor.py @@ -55,7 +55,9 @@ CONVERT_FUNCTIONS = { async def async_setup_entry( - hass, config_entry, async_add_entities, + hass, + config_entry, + async_add_entities, ): """Set up platform.""" discovery_info = config_entry.data diff --git a/homeassistant/components/rfxtrx/switch.py b/homeassistant/components/rfxtrx/switch.py index 9b2c3c60539..bce5222b778 100644 --- a/homeassistant/components/rfxtrx/switch.py +++ b/homeassistant/components/rfxtrx/switch.py @@ -26,7 +26,9 @@ _LOGGER = logging.getLogger(__name__) async def async_setup_entry( - hass, config_entry, async_add_entities, + hass, + config_entry, + async_add_entities, ): """Set up config entry.""" discovery_info = config_entry.data diff --git a/homeassistant/components/ring/__init__.py b/homeassistant/components/ring/__init__.py index 7f097d48a5f..ed22575bccc 100644 --- a/homeassistant/components/ring/__init__.py +++ b/homeassistant/components/ring/__init__.py @@ -202,12 +202,15 @@ class GlobalDataUpdater: return except requests.Timeout: _LOGGER.warning( - "Time out fetching Ring %s data", self.data_type, + "Time out fetching Ring %s data", + self.data_type, ) return except requests.RequestException as err: _LOGGER.warning( - "Error fetching Ring %s data: %s", self.data_type, err, + "Error fetching Ring %s data: %s", + self.data_type, + err, ) return diff --git a/homeassistant/components/ring/camera.py b/homeassistant/components/ring/camera.py index 96b1a962a67..a313bcf03ba 100644 --- a/homeassistant/components/ring/camera.py +++ b/homeassistant/components/ring/camera.py @@ -109,7 +109,10 @@ class RingCam(RingEntityMixin, Camera): return image = await asyncio.shield( - ffmpeg.get_image(self._video_url, output_format=IMAGE_JPEG,) + ffmpeg.get_image( + self._video_url, + output_format=IMAGE_JPEG, + ) ) return image diff --git a/homeassistant/components/ring/config_flow.py b/homeassistant/components/ring/config_flow.py index fd9dbe0a17e..607e4f1937b 100644 --- a/homeassistant/components/ring/config_flow.py +++ b/homeassistant/components/ring/config_flow.py @@ -19,7 +19,10 @@ async def validate_input(hass: core.HomeAssistant, data): try: token = await hass.async_add_executor_job( - auth.fetch_token, data["username"], data["password"], data.get("2fa"), + auth.fetch_token, + data["username"], + data["password"], + data.get("2fa"), ) except MissingTokenError: raise Require2FA @@ -72,7 +75,8 @@ class RingConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return await self.async_step_user({**self.user_pass, **user_input}) return self.async_show_form( - step_id="2fa", data_schema=vol.Schema({"2fa": str}), + step_id="2fa", + data_schema=vol.Schema({"2fa": str}), ) diff --git a/homeassistant/components/risco/__init__.py b/homeassistant/components/risco/__init__.py index 6ee126145b3..bfdf322d4d5 100644 --- a/homeassistant/components/risco/__init__.py +++ b/homeassistant/components/risco/__init__.py @@ -93,7 +93,10 @@ class RiscoDataUpdateCoordinator(DataUpdateCoordinator): self.risco = risco interval = timedelta(seconds=scan_interval) super().__init__( - hass, _LOGGER, name=DOMAIN, update_interval=interval, + hass, + _LOGGER, + name=DOMAIN, + update_interval=interval, ) async def _async_update_data(self): diff --git a/homeassistant/components/roku/__init__.py b/homeassistant/components/roku/__init__.py index 2627d68e3c3..1baff67f580 100644 --- a/homeassistant/components/roku/__init__.py +++ b/homeassistant/components/roku/__init__.py @@ -50,7 +50,9 @@ async def async_setup(hass: HomeAssistantType, config: Dict) -> bool: for entry_config in config[DOMAIN]: hass.async_create_task( hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=entry_config, + DOMAIN, + context={"source": SOURCE_IMPORT}, + data=entry_config, ) ) @@ -112,7 +114,10 @@ class RokuDataUpdateCoordinator(DataUpdateCoordinator[Device]): """Class to manage fetching Roku data.""" def __init__( - self, hass: HomeAssistantType, *, host: str, + self, + hass: HomeAssistantType, + *, + host: str, ): """Initialize global Roku data updater.""" self.roku = Roku(host=host, session=async_get_clientsession(hass)) @@ -121,7 +126,10 @@ class RokuDataUpdateCoordinator(DataUpdateCoordinator[Device]): self.last_full_update = None super().__init__( - hass, _LOGGER, name=DOMAIN, update_interval=SCAN_INTERVAL, + hass, + _LOGGER, + name=DOMAIN, + update_interval=SCAN_INTERVAL, ) async def _async_update_data(self) -> Device: diff --git a/homeassistant/components/roku/config_flow.py b/homeassistant/components/roku/config_flow.py index 27ab63c728b..662e22605c8 100644 --- a/homeassistant/components/roku/config_flow.py +++ b/homeassistant/components/roku/config_flow.py @@ -56,7 +56,9 @@ class RokuConfigFlow(ConfigFlow, domain=DOMAIN): def _show_form(self, errors: Optional[Dict] = None) -> Dict[str, Any]: """Show the form to the user.""" return self.async_show_form( - step_id="user", data_schema=DATA_SCHEMA, errors=errors or {}, + step_id="user", + data_schema=DATA_SCHEMA, + errors=errors or {}, ) async def async_step_import( @@ -129,5 +131,6 @@ class RokuConfigFlow(ConfigFlow, domain=DOMAIN): ) return self.async_create_entry( - title=self.discovery_info[CONF_NAME], data=self.discovery_info, + title=self.discovery_info[CONF_NAME], + data=self.discovery_info, ) diff --git a/homeassistant/components/roku/media_player.py b/homeassistant/components/roku/media_player.py index 9a46d189486..30cb4ec7a3e 100644 --- a/homeassistant/components/roku/media_player.py +++ b/homeassistant/components/roku/media_player.py @@ -58,7 +58,9 @@ async def async_setup_entry(hass, entry, async_add_entities): platform = entity_platform.current_platform.get() platform.async_register_entity_service( - SERVICE_SEARCH, SEARCH_SCHEMA, "search", + SERVICE_SEARCH, + SEARCH_SCHEMA, + "search", ) diff --git a/homeassistant/components/roomba/__init__.py b/homeassistant/components/roomba/__init__.py index 5e7d47d2d57..f2daaa0fbf8 100644 --- a/homeassistant/components/roomba/__init__.py +++ b/homeassistant/components/roomba/__init__.py @@ -71,7 +71,9 @@ async def async_setup(hass, config): _LOGGER.debug("Importing Roomba #%d - %s", index, conf[CONF_HOST]) hass.async_create_task( hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=conf, + DOMAIN, + context={"source": config_entries.SOURCE_IMPORT}, + data=conf, ) ) diff --git a/homeassistant/components/samsungtv/config_flow.py b/homeassistant/components/samsungtv/config_flow.py index b939479a45a..9c18600670c 100644 --- a/homeassistant/components/samsungtv/config_flow.py +++ b/homeassistant/components/samsungtv/config_flow.py @@ -77,7 +77,10 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): } if self._bridge.token: data[CONF_TOKEN] = self._bridge.token - return self.async_create_entry(title=self._title, data=data,) + return self.async_create_entry( + title=self._title, + data=data, + ) def _try_connect(self): """Try to connect and check auth.""" diff --git a/homeassistant/components/samsungtv/media_player.py b/homeassistant/components/samsungtv/media_player.py index 4b504b5688a..6e406f60ec4 100644 --- a/homeassistant/components/samsungtv/media_player.py +++ b/homeassistant/components/samsungtv/media_player.py @@ -77,14 +77,20 @@ async def async_setup_entry(hass, config_entry, async_add_entities): # Initialize bridge data = config_entry.data.copy() bridge = SamsungTVBridge.get_bridge( - data[CONF_METHOD], data[CONF_HOST], data[CONF_PORT], data.get(CONF_TOKEN), + data[CONF_METHOD], + data[CONF_HOST], + data[CONF_PORT], + data.get(CONF_TOKEN), ) if bridge.port is None and bridge.default_port is not None: # For backward compat, set default port for websocket tv data[CONF_PORT] = bridge.default_port hass.config_entries.async_update_entry(config_entry, data=data) bridge = SamsungTVBridge.get_bridge( - data[CONF_METHOD], data[CONF_HOST], data[CONF_PORT], data.get(CONF_TOKEN), + data[CONF_METHOD], + data[CONF_HOST], + data[CONF_PORT], + data.get(CONF_TOKEN), ) async_add_entities([SamsungTVDevice(bridge, config_entry, on_script)]) @@ -117,7 +123,9 @@ class SamsungTVDevice(MediaPlayerEntity): LOGGER.debug("Access denied in getting remote object") self.hass.add_job( self.hass.config_entries.flow.async_init( - DOMAIN, context={"source": "reauth"}, data=self._config_entry.data, + DOMAIN, + context={"source": "reauth"}, + data=self._config_entry.data, ) ) diff --git a/homeassistant/components/sense/sensor.py b/homeassistant/components/sense/sensor.py index 8ccb2ad12ff..538267aa355 100644 --- a/homeassistant/components/sense/sensor.py +++ b/homeassistant/components/sense/sensor.py @@ -208,7 +208,13 @@ class SenseTrendsSensor(Entity): """Implementation of a Sense energy sensor.""" def __init__( - self, data, name, sensor_type, is_production, trends_coordinator, unique_id, + self, + data, + name, + sensor_type, + is_production, + trends_coordinator, + unique_id, ): """Initialize the Sense sensor.""" name_type = PRODUCTION_NAME if is_production else CONSUMPTION_NAME diff --git a/homeassistant/components/shelly/config_flow.py b/homeassistant/components/shelly/config_flow.py index da57a94e628..830cb81c74e 100644 --- a/homeassistant/components/shelly/config_flow.py +++ b/homeassistant/components/shelly/config_flow.py @@ -128,5 +128,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): """Get info from shelly device.""" async with async_timeout.timeout(5): return await aioshelly.get_info( - aiohttp_client.async_get_clientsession(self.hass), host, + aiohttp_client.async_get_clientsession(self.hass), + host, ) diff --git a/homeassistant/components/simplisafe/config_flow.py b/homeassistant/components/simplisafe/config_flow.py index d4a076860a1..ef980c25421 100644 --- a/homeassistant/components/simplisafe/config_flow.py +++ b/homeassistant/components/simplisafe/config_flow.py @@ -49,7 +49,10 @@ class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): websession = aiohttp_client.async_get_clientsession(self.hass) return await API.login_via_credentials( - self._username, self._password, client_id=client_id, session=websession, + self._username, + self._password, + client_id=client_id, + session=websession, ) async def _async_login_during_step(self, *, step_id, form_schema): @@ -69,7 +72,9 @@ class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): if errors: return self.async_show_form( - step_id=step_id, data_schema=form_schema, errors=errors, + step_id=step_id, + data_schema=form_schema, + errors=errors, ) return await self.async_step_finish( @@ -169,7 +174,8 @@ class SimpliSafeOptionsFlowHandler(config_entries.OptionsFlow): data_schema=vol.Schema( { vol.Optional( - CONF_CODE, default=self.config_entry.options.get(CONF_CODE), + CONF_CODE, + default=self.config_entry.options.get(CONF_CODE), ): str } ), diff --git a/homeassistant/components/smappee/__init__.py b/homeassistant/components/smappee/__init__.py index 3820863de93..aed67c5c167 100644 --- a/homeassistant/components/smappee/__init__.py +++ b/homeassistant/components/smappee/__init__.py @@ -79,8 +79,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): smappee = Smappee(api=smappee_api, serialnumber=entry.data[CONF_SERIALNUMBER]) await hass.async_add_executor_job(smappee.load_local_service_location) else: - implementation = await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry + implementation = ( + await config_entry_oauth2_flow.async_get_config_entry_implementation( + hass, entry + ) ) smappee_api = api.ConfigEntrySmappeeApi(hass, entry, implementation) diff --git a/homeassistant/components/smappee/binary_sensor.py b/homeassistant/components/smappee/binary_sensor.py index fbd0c89f4b6..ecc00f12370 100644 --- a/homeassistant/components/smappee/binary_sensor.py +++ b/homeassistant/components/smappee/binary_sensor.py @@ -61,7 +61,9 @@ class SmappeePresence(BinarySensorEntity): return "presence" @property - def unique_id(self,): + def unique_id( + self, + ): """Return the unique ID for this binary sensor.""" return ( f"{self._service_location.device_serial_number}-" @@ -142,7 +144,9 @@ class SmappeeAppliance(BinarySensorEntity): return icon_mapping.get(self._appliance_type) @property - def unique_id(self,): + def unique_id( + self, + ): """Return the unique ID for this binary sensor.""" return ( f"{self._service_location.device_serial_number}-" diff --git a/homeassistant/components/smappee/sensor.py b/homeassistant/components/smappee/sensor.py index cffdb7c5024..dd145c4cdce 100644 --- a/homeassistant/components/smappee/sensor.py +++ b/homeassistant/components/smappee/sensor.py @@ -291,7 +291,9 @@ class SmappeeSensor(Entity): return self._unit_of_measurement @property - def unique_id(self,): + def unique_id( + self, + ): """Return the unique ID for this sensor.""" if self._sensor in ["load", "sensor"]: return ( diff --git a/homeassistant/components/smappee/switch.py b/homeassistant/components/smappee/switch.py index 4d158df852a..bbcacc7d541 100644 --- a/homeassistant/components/smappee/switch.py +++ b/homeassistant/components/smappee/switch.py @@ -144,7 +144,9 @@ class SmappeeActuator(SwitchEntity): return None @property - def unique_id(self,): + def unique_id( + self, + ): """Return the unique ID for this switch.""" if self._actuator_type == "INFINITY_OUTPUT_MODULE": return ( diff --git a/homeassistant/components/smarthab/__init__.py b/homeassistant/components/smarthab/__init__.py index 82c550e0060..cc6499f9c8d 100644 --- a/homeassistant/components/smarthab/__init__.py +++ b/homeassistant/components/smarthab/__init__.py @@ -38,7 +38,9 @@ async def async_setup(hass, config) -> bool: hass.async_create_task( hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=sh_conf, + DOMAIN, + context={"source": SOURCE_IMPORT}, + data=sh_conf, ) ) diff --git a/homeassistant/components/smartthings/__init__.py b/homeassistant/components/smartthings/__init__.py index 479df05fbb4..48e56e74f70 100644 --- a/homeassistant/components/smartthings/__init__.py +++ b/homeassistant/components/smartthings/__init__.py @@ -315,7 +315,8 @@ class DeviceBroker: async def regenerate_refresh_token(now): """Generate a new refresh token and update the config entry.""" await self._token.refresh( - self._entry.data[CONF_CLIENT_ID], self._entry.data[CONF_CLIENT_SECRET], + self._entry.data[CONF_CLIENT_ID], + self._entry.data[CONF_CLIENT_SECRET], ) self._hass.config_entries.async_update_entry( self._entry, diff --git a/homeassistant/components/smartthings/config_flow.py b/homeassistant/components/smartthings/config_flow.py index f8746b597de..e320c335a08 100644 --- a/homeassistant/components/smartthings/config_flow.py +++ b/homeassistant/components/smartthings/config_flow.py @@ -80,7 +80,8 @@ class SmartThingsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): # Show the confirmation if user_input is None: return self.async_show_form( - step_id="user", description_placeholders={"webhook_url": webhook_url}, + step_id="user", + description_placeholders={"webhook_url": webhook_url}, ) # Show the next screen diff --git a/homeassistant/components/sms/__init__.py b/homeassistant/components/sms/__init__.py index 0b8f9d986e3..b1af205fc10 100644 --- a/homeassistant/components/sms/__init__.py +++ b/homeassistant/components/sms/__init__.py @@ -31,7 +31,9 @@ async def async_setup(hass, config): hass.async_create_task( hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=sms_config, + DOMAIN, + context={"source": SOURCE_IMPORT}, + data=sms_config, ) ) diff --git a/homeassistant/components/sms/sensor.py b/homeassistant/components/sms/sensor.py index 08168994b07..64d2bf9bd98 100644 --- a/homeassistant/components/sms/sensor.py +++ b/homeassistant/components/sms/sensor.py @@ -17,7 +17,13 @@ async def async_setup_entry(hass, config_entry, async_add_entities): entities = [] imei = await gateway.get_imei_async() name = f"gsm_signal_imei_{imei}" - entities.append(GSMSignalSensor(hass, gateway, name,)) + entities.append( + GSMSignalSensor( + hass, + gateway, + name, + ) + ) async_add_entities(entities, True) @@ -25,7 +31,10 @@ class GSMSignalSensor(Entity): """Implementation of a GSM Signal sensor.""" def __init__( - self, hass, gateway, name, + self, + hass, + gateway, + name, ): """Initialize the GSM Signal sensor.""" self._hass = hass diff --git a/homeassistant/components/somfy/__init__.py b/homeassistant/components/somfy/__init__.py index fb20fcd6683..fbc76e7c938 100644 --- a/homeassistant/components/somfy/__init__.py +++ b/homeassistant/components/somfy/__init__.py @@ -82,8 +82,10 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry): entry, data={**entry.data, "auth_implementation": DOMAIN} ) - implementation = await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry + implementation = ( + await config_entry_oauth2_flow.async_get_config_entry_implementation( + hass, entry + ) ) hass.data[DOMAIN][API] = api.ConfigEntrySomfyApi(hass, entry, implementation) diff --git a/homeassistant/components/somfy/api.py b/homeassistant/components/somfy/api.py index 761ee19f8cb..a679af06d73 100644 --- a/homeassistant/components/somfy/api.py +++ b/homeassistant/components/somfy/api.py @@ -25,7 +25,9 @@ class ConfigEntrySomfyApi(somfy_api.SomfyApi): ) super().__init__(None, None, token=self.session.token) - def refresh_tokens(self,) -> Dict[str, Union[str, int]]: + def refresh_tokens( + self, + ) -> Dict[str, Union[str, int]]: """Refresh and return new Somfy tokens using Home Assistant OAuth2 session.""" run_coroutine_threadsafe( self.session.async_ensure_token_valid(), self.hass.loop diff --git a/homeassistant/components/sonarr/config_flow.py b/homeassistant/components/sonarr/config_flow.py index e82ecb49fda..ec1a29c660b 100644 --- a/homeassistant/components/sonarr/config_flow.py +++ b/homeassistant/components/sonarr/config_flow.py @@ -111,7 +111,9 @@ class SonarrConfigFlow(ConfigFlow, domain=DOMAIN): ] = bool return self.async_show_form( - step_id="user", data_schema=vol.Schema(data_schema), errors=errors or {}, + step_id="user", + data_schema=vol.Schema(data_schema), + errors=errors or {}, ) diff --git a/homeassistant/components/songpal/__init__.py b/homeassistant/components/songpal/__init__.py index 4a4332cb0a5..493a3ef4913 100644 --- a/homeassistant/components/songpal/__init__.py +++ b/homeassistant/components/songpal/__init__.py @@ -31,7 +31,9 @@ async def async_setup(hass: HomeAssistantType, config: OrderedDict) -> bool: for config_entry in conf: hass.async_create_task( hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=config_entry, + DOMAIN, + context={"source": SOURCE_IMPORT}, + data=config_entry, ), ) return True diff --git a/homeassistant/components/sonos/media_player.py b/homeassistant/components/sonos/media_player.py index 4e4f7338a10..a2440802139 100644 --- a/homeassistant/components/sonos/media_player.py +++ b/homeassistant/components/sonos/media_player.py @@ -450,7 +450,10 @@ class SonosEntity(MediaPlayerEntity): @soco_coordinator def state(self): """Return the state of the entity.""" - if self._status in ("PAUSED_PLAYBACK", "STOPPED",): + if self._status in ( + "PAUSED_PLAYBACK", + "STOPPED", + ): # Sonos can consider itself "paused" but without having media loaded # (happens if playing Spotify and via Spotify app you pick another device to play on) if self.media_title is None: diff --git a/homeassistant/components/speedtestdotnet/__init__.py b/homeassistant/components/speedtestdotnet/__init__.py index 876518f25ed..3d257174328 100644 --- a/homeassistant/components/speedtestdotnet/__init__.py +++ b/homeassistant/components/speedtestdotnet/__init__.py @@ -128,7 +128,10 @@ class SpeedTestDataCoordinator(DataUpdateCoordinator): self.servers = {} self._unsub_update_listener = None super().__init__( - self.hass, _LOGGER, name=DOMAIN, update_method=self.async_update, + self.hass, + _LOGGER, + name=DOMAIN, + update_method=self.async_update, ) def update_servers(self): diff --git a/homeassistant/components/spider/config_flow.py b/homeassistant/components/spider/config_flow.py index e1026f344b0..c8c31221a50 100644 --- a/homeassistant/components/spider/config_flow.py +++ b/homeassistant/components/spider/config_flow.py @@ -62,7 +62,10 @@ class SpiderConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): result = await self.hass.async_add_executor_job(self._try_connect) if result == RESULT_SUCCESS: - return self.async_create_entry(title=DOMAIN, data=self.data,) + return self.async_create_entry( + title=DOMAIN, + data=self.data, + ) if result != RESULT_AUTH_FAILED: _LOGGER.exception("Unexpected exception") errors["base"] = "unknown" @@ -71,7 +74,9 @@ class SpiderConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): errors["base"] = "invalid_auth" return self.async_show_form( - step_id="user", data_schema=DATA_SCHEMA_USER, errors=errors, + step_id="user", + data_schema=DATA_SCHEMA_USER, + errors=errors, ) async def async_step_import(self, import_data): diff --git a/homeassistant/components/squeezebox/media_player.py b/homeassistant/components/squeezebox/media_player.py index 88fba2f6ccf..2dbad960227 100644 --- a/homeassistant/components/squeezebox/media_player.py +++ b/homeassistant/components/squeezebox/media_player.py @@ -224,7 +224,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities): "async_call_query", ) platform.async_register_entity_service( - SERVICE_SYNC, {vol.Required(ATTR_OTHER_PLAYER): cv.string}, "async_sync", + SERVICE_SYNC, + {vol.Required(ATTR_OTHER_PLAYER): cv.string}, + "async_sync", ) platform.async_register_entity_service(SERVICE_UNSYNC, None, "async_unsync") diff --git a/homeassistant/components/stream/hls.py b/homeassistant/components/stream/hls.py index bd7a6966c9d..1e97ac222ec 100644 --- a/homeassistant/components/stream/hls.py +++ b/homeassistant/components/stream/hls.py @@ -72,7 +72,8 @@ class HlsSegmentView(StreamView): return web.HTTPNotFound() headers = {"Content-Type": "video/iso.segment"} return web.Response( - body=get_m4s(segment.segment, int(sequence)), headers=headers, + body=get_m4s(segment.segment, int(sequence)), + headers=headers, ) diff --git a/homeassistant/components/stream/worker.py b/homeassistant/components/stream/worker.py index bed8b25dbd1..ea4359e2a0c 100644 --- a/homeassistant/components/stream/worker.py +++ b/homeassistant/components/stream/worker.py @@ -199,7 +199,11 @@ def stream_worker(hass, stream, quit_event): if stream.outputs.get(fmt): hass.loop.call_soon_threadsafe( stream.outputs[fmt].put, - Segment(sequence, buffer.segment, segment_duration,), + Segment( + sequence, + buffer.segment, + segment_duration, + ), ) # Reinitialize diff --git a/homeassistant/components/surepetcare/binary_sensor.py b/homeassistant/components/surepetcare/binary_sensor.py index efd5048053f..0cb96731058 100644 --- a/homeassistant/components/surepetcare/binary_sensor.py +++ b/homeassistant/components/surepetcare/binary_sensor.py @@ -203,7 +203,10 @@ class DeviceConnectivity(SurePetcareBinarySensor): """Sure Petcare Pet.""" def __init__( - self, _id: int, sure_type: SureProductID, spc: SurePetcareAPI, + self, + _id: int, + sure_type: SureProductID, + spc: SurePetcareAPI, ) -> None: """Initialize a Sure Petcare Device.""" super().__init__(_id, spc, DEVICE_CLASS_CONNECTIVITY, sure_type) diff --git a/homeassistant/components/syncthru/config_flow.py b/homeassistant/components/syncthru/config_flow.py index ef3b6903358..cbdd46b4a6a 100644 --- a/homeassistant/components/syncthru/config_flow.py +++ b/homeassistant/components/syncthru/config_flow.py @@ -74,7 +74,8 @@ class SyncThruConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return await self._async_check_and_create("confirm", user_input) return await self._async_show_form( - step_id="confirm", user_input={CONF_URL: self.url, CONF_NAME: self.name}, + step_id="confirm", + user_input={CONF_URL: self.url, CONF_NAME: self.name}, ) async def _async_show_form(self, step_id, user_input=None, errors=None): @@ -133,5 +134,6 @@ class SyncThruConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): ) return self.async_create_entry( - title=user_input.get(CONF_NAME), data=user_input, + title=user_input.get(CONF_NAME), + data=user_input, ) diff --git a/homeassistant/components/synology_dsm/__init__.py b/homeassistant/components/synology_dsm/__init__.py index 89dc39e427c..2e4b550337b 100644 --- a/homeassistant/components/synology_dsm/__init__.py +++ b/homeassistant/components/synology_dsm/__init__.py @@ -88,7 +88,9 @@ async def async_setup(hass, config): for dsm_conf in conf: hass.async_create_task( hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=dsm_conf, + DOMAIN, + context={"source": SOURCE_IMPORT}, + data=dsm_conf, ) ) @@ -335,7 +337,10 @@ class SynologyDSMEntity(Entity): """Representation of a Synology NAS entry.""" def __init__( - self, api: SynoApi, entity_type: str, entity_info: Dict[str, str], + self, + api: SynoApi, + entity_type: str, + entity_info: Dict[str, str], ): """Initialize the Synology DSM entity.""" self._api = api diff --git a/homeassistant/components/tado/__init__.py b/homeassistant/components/tado/__init__.py index f2273bcae10..37e92ff5b4f 100644 --- a/homeassistant/components/tado/__init__.py +++ b/homeassistant/components/tado/__init__.py @@ -63,7 +63,9 @@ async def async_setup(hass: HomeAssistant, config: dict): for conf in config[DOMAIN]: hass.async_create_task( hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=conf, + DOMAIN, + context={"source": SOURCE_IMPORT}, + data=conf, ) ) @@ -100,7 +102,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): # Poll for updates in the background update_track = async_track_time_interval( - hass, lambda now: tadoconnector.update(), SCAN_INTERVAL, + hass, + lambda now: tadoconnector.update(), + SCAN_INTERVAL, ) update_listener = entry.add_update_listener(_async_update_listener) @@ -211,7 +215,9 @@ class TadoConnector: return except RuntimeError: _LOGGER.error( - "Unable to connect to Tado while updating %s %s", sensor_type, sensor, + "Unable to connect to Tado while updating %s %s", + sensor_type, + sensor, ) return @@ -239,7 +245,8 @@ class TadoConnector: self.update_sensor("zone", zone_id) def set_presence( - self, presence=PRESET_HOME, + self, + presence=PRESET_HOME, ): """Set the presence to home or away.""" if presence == PRESET_AWAY: diff --git a/homeassistant/components/tado/climate.py b/homeassistant/components/tado/climate.py index 6d45552abd2..3e0c79ad65e 100644 --- a/homeassistant/components/tado/climate.py +++ b/homeassistant/components/tado/climate.py @@ -75,7 +75,9 @@ async def async_setup_entry( platform = entity_platform.current_platform.get() platform.async_register_entity_service( - SERVICE_CLIMATE_TIMER, CLIMATE_TIMER_SCHEMA, "set_timer", + SERVICE_CLIMATE_TIMER, + CLIMATE_TIMER_SCHEMA, + "set_timer", ) if entities: diff --git a/homeassistant/components/tado/water_heater.py b/homeassistant/components/tado/water_heater.py index be3be0f545a..1a99db5c24c 100644 --- a/homeassistant/components/tado/water_heater.py +++ b/homeassistant/components/tado/water_heater.py @@ -71,7 +71,9 @@ async def async_setup_entry( platform = entity_platform.current_platform.get() platform.async_register_entity_service( - SERVICE_WATER_HEATER_TIMER, WATER_HEATER_TIMER_SCHEMA, "set_timer", + SERVICE_WATER_HEATER_TIMER, + WATER_HEATER_TIMER_SCHEMA, + "set_timer", ) if entities: diff --git a/homeassistant/components/template/cover.py b/homeassistant/components/template/cover.py index e26c0fca8f4..1f9988bcafa 100644 --- a/homeassistant/components/template/cover.py +++ b/homeassistant/components/template/cover.py @@ -291,7 +291,8 @@ class CoverTemplate(TemplateEntity, CoverEntity): if state < 0 or state > 100: self._tilt_value = None _LOGGER.error( - "Tilt value must be between 0 and 100. Value was: %.2f", state, + "Tilt value must be between 0 and 100. Value was: %.2f", + state, ) else: self._tilt_value = state diff --git a/homeassistant/components/template/fan.py b/homeassistant/components/template/fan.py index 01cf22c4aab..8017bef163b 100644 --- a/homeassistant/components/template/fan.py +++ b/homeassistant/components/template/fan.py @@ -385,7 +385,8 @@ class TemplateFan(TemplateEntity, FanEntity): self._oscillating = None else: _LOGGER.error( - "Received invalid oscillating: %s. Expected: True/False", oscillating, + "Received invalid oscillating: %s. Expected: True/False", + oscillating, ) self._oscillating = None diff --git a/homeassistant/components/template/vacuum.py b/homeassistant/components/template/vacuum.py index 6375995ed7d..615995758a1 100644 --- a/homeassistant/components/template/vacuum.py +++ b/homeassistant/components/template/vacuum.py @@ -341,7 +341,10 @@ class TemplateVacuum(TemplateEntity, StateVacuumEntity): ) if self._fan_speed_template is not None: self.add_template_attribute( - "_fan_speed", self._fan_speed_template, None, self._update_fan_speed, + "_fan_speed", + self._fan_speed_template, + None, + self._update_fan_speed, ) if self._battery_level_template is not None: self.add_template_attribute( diff --git a/homeassistant/components/tensorflow/image_processing.py b/homeassistant/components/tensorflow/image_processing.py index 420c3403a11..d293a19d8d6 100644 --- a/homeassistant/components/tensorflow/image_processing.py +++ b/homeassistant/components/tensorflow/image_processing.py @@ -204,7 +204,12 @@ class TensorFlowImageProcessor(ImageProcessingEntity): """Representation of an TensorFlow image processor.""" def __init__( - self, hass, camera_entity, name, category_index, config, + self, + hass, + camera_entity, + name, + category_index, + config, ): """Initialize the TensorFlow entity.""" model_config = config.get(CONF_MODEL) diff --git a/homeassistant/components/tesla/__init__.py b/homeassistant/components/tesla/__init__.py index fefe980fbd1..bc2a09788e5 100644 --- a/homeassistant/components/tesla/__init__.py +++ b/homeassistant/components/tesla/__init__.py @@ -223,7 +223,10 @@ class TeslaDataUpdateCoordinator(DataUpdateCoordinator): update_interval = timedelta(seconds=MIN_SCAN_INTERVAL) super().__init__( - hass, _LOGGER, name=DOMAIN, update_interval=update_interval, + hass, + _LOGGER, + name=DOMAIN, + update_interval=update_interval, ) async def _async_update_data(self): diff --git a/homeassistant/components/tesla/binary_sensor.py b/homeassistant/components/tesla/binary_sensor.py index 01dc1aa44f0..3c3777afc1f 100644 --- a/homeassistant/components/tesla/binary_sensor.py +++ b/homeassistant/components/tesla/binary_sensor.py @@ -13,7 +13,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities( [ TeslaBinarySensor( - device, hass.data[TESLA_DOMAIN][config_entry.entry_id]["coordinator"], + device, + hass.data[TESLA_DOMAIN][config_entry.entry_id]["coordinator"], ) for device in hass.data[TESLA_DOMAIN][config_entry.entry_id]["devices"][ "binary_sensor" diff --git a/homeassistant/components/tesla/climate.py b/homeassistant/components/tesla/climate.py index bfc2f721a4b..4c7ed850749 100644 --- a/homeassistant/components/tesla/climate.py +++ b/homeassistant/components/tesla/climate.py @@ -25,7 +25,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities( [ TeslaThermostat( - device, hass.data[TESLA_DOMAIN][config_entry.entry_id]["coordinator"], + device, + hass.data[TESLA_DOMAIN][config_entry.entry_id]["coordinator"], ) for device in hass.data[TESLA_DOMAIN][config_entry.entry_id]["devices"][ "climate" diff --git a/homeassistant/components/tesla/device_tracker.py b/homeassistant/components/tesla/device_tracker.py index c3c82a708bf..46265a96ae4 100644 --- a/homeassistant/components/tesla/device_tracker.py +++ b/homeassistant/components/tesla/device_tracker.py @@ -14,7 +14,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Tesla binary_sensors by config_entry.""" entities = [ TeslaDeviceEntity( - device, hass.data[TESLA_DOMAIN][config_entry.entry_id]["coordinator"], + device, + hass.data[TESLA_DOMAIN][config_entry.entry_id]["coordinator"], ) for device in hass.data[TESLA_DOMAIN][config_entry.entry_id]["devices"][ "devices_tracker" diff --git a/homeassistant/components/tesla/lock.py b/homeassistant/components/tesla/lock.py index 9f6db402422..7a74d2ececb 100644 --- a/homeassistant/components/tesla/lock.py +++ b/homeassistant/components/tesla/lock.py @@ -12,7 +12,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Tesla binary_sensors by config_entry.""" entities = [ TeslaLock( - device, hass.data[TESLA_DOMAIN][config_entry.entry_id]["coordinator"], + device, + hass.data[TESLA_DOMAIN][config_entry.entry_id]["coordinator"], ) for device in hass.data[TESLA_DOMAIN][config_entry.entry_id]["devices"]["lock"] ] diff --git a/homeassistant/components/tibber/config_flow.py b/homeassistant/components/tibber/config_flow.py index b0115d84e2c..2e09ea22777 100644 --- a/homeassistant/components/tibber/config_flow.py +++ b/homeassistant/components/tibber/config_flow.py @@ -54,7 +54,9 @@ class TibberConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): if errors: return self.async_show_form( - step_id="user", data_schema=DATA_SCHEMA, errors=errors, + step_id="user", + data_schema=DATA_SCHEMA, + errors=errors, ) unique_id = tibber_connection.user_id @@ -62,7 +64,12 @@ class TibberConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self._abort_if_unique_id_configured() return self.async_create_entry( - title=tibber_connection.name, data={CONF_ACCESS_TOKEN: access_token}, + title=tibber_connection.name, + data={CONF_ACCESS_TOKEN: access_token}, ) - return self.async_show_form(step_id="user", data_schema=DATA_SCHEMA, errors={},) + return self.async_show_form( + step_id="user", + data_schema=DATA_SCHEMA, + errors={}, + ) diff --git a/homeassistant/components/totalconnect/__init__.py b/homeassistant/components/totalconnect/__init__.py index 25b1141bd9b..cf3f059cfb9 100644 --- a/homeassistant/components/totalconnect/__init__.py +++ b/homeassistant/components/totalconnect/__init__.py @@ -36,7 +36,9 @@ async def async_setup(hass: HomeAssistant, config: dict): hass.async_create_task( hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=config[DOMAIN], + DOMAIN, + context={"source": SOURCE_IMPORT}, + data=config[DOMAIN], ) ) diff --git a/homeassistant/components/tplink/light.py b/homeassistant/components/tplink/light.py index 9c3d73b43b5..a5135704dad 100644 --- a/homeassistant/components/tplink/light.py +++ b/homeassistant/components/tplink/light.py @@ -191,14 +191,18 @@ class TPLinkSmartBulb(LightEntity): await self._async_set_light_state_retry( self._light_state, self._light_state._replace( - state=True, brightness=brightness, color_temp=color_tmp, hs=hue_sat, + state=True, + brightness=brightness, + color_temp=color_tmp, + hs=hue_sat, ), ) async def async_turn_off(self, **kwargs): """Turn the light off.""" await self._async_set_light_state_retry( - self._light_state, self._light_state._replace(state=False), + self._light_state, + self._light_state._replace(state=False), ) @property diff --git a/homeassistant/components/transmission/config_flow.py b/homeassistant/components/transmission/config_flow.py index 8b43850623a..56ed3081b63 100644 --- a/homeassistant/components/transmission/config_flow.py +++ b/homeassistant/components/transmission/config_flow.py @@ -80,7 +80,9 @@ class TransmissionFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): ) return self.async_show_form( - step_id="user", data_schema=DATA_SCHEMA, errors=errors, + step_id="user", + data_schema=DATA_SCHEMA, + errors=errors, ) async def async_step_import(self, import_config): diff --git a/homeassistant/components/transmission/sensor.py b/homeassistant/components/transmission/sensor.py index baa70bf0b19..69388de1145 100644 --- a/homeassistant/components/transmission/sensor.py +++ b/homeassistant/components/transmission/sensor.py @@ -153,7 +153,9 @@ class TransmissionTorrentsSensor(TransmissionSensor): order = self._tm_client.config_entry.options[CONF_ORDER] torrents = self._tm_client.api.torrents[0:limit] info = _torrents_info( - torrents, order=order, statuses=self.SUBTYPE_MODES[self._sub_type], + torrents, + order=order, + statuses=self.SUBTYPE_MODES[self._sub_type], ) return { STATE_ATTR_TORRENT_INFO: info, diff --git a/homeassistant/components/tuya/__init__.py b/homeassistant/components/tuya/__init__.py index e2304fc7f63..6524c026fcf 100644 --- a/homeassistant/components/tuya/__init__.py +++ b/homeassistant/components/tuya/__init__.py @@ -100,7 +100,8 @@ async def async_setup_entry(hass, entry): except TuyaAPIException as exc: _LOGGER.error( - "Connection error during integration setup. Error: %s", exc, + "Connection error during integration setup. Error: %s", + exc, ) return False diff --git a/homeassistant/components/tuya/climate.py b/homeassistant/components/tuya/climate.py index 15cecefdb21..99939c4b9c0 100644 --- a/homeassistant/components/tuya/climate.py +++ b/homeassistant/components/tuya/climate.py @@ -54,7 +54,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities): if not dev_ids: return entities = await hass.async_add_executor_job( - _setup_entities, hass, dev_ids, platform, + _setup_entities, + hass, + dev_ids, + platform, ) async_add_entities(entities) diff --git a/homeassistant/components/tuya/cover.py b/homeassistant/components/tuya/cover.py index 538b819cb05..3c94ed6a53d 100644 --- a/homeassistant/components/tuya/cover.py +++ b/homeassistant/components/tuya/cover.py @@ -26,7 +26,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities): if not dev_ids: return entities = await hass.async_add_executor_job( - _setup_entities, hass, dev_ids, platform, + _setup_entities, + hass, + dev_ids, + platform, ) async_add_entities(entities) diff --git a/homeassistant/components/tuya/fan.py b/homeassistant/components/tuya/fan.py index 6144bd4ab96..cc8272fabba 100644 --- a/homeassistant/components/tuya/fan.py +++ b/homeassistant/components/tuya/fan.py @@ -25,7 +25,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities): if not dev_ids: return entities = await hass.async_add_executor_job( - _setup_entities, hass, dev_ids, platform, + _setup_entities, + hass, + dev_ids, + platform, ) async_add_entities(entities) diff --git a/homeassistant/components/tuya/light.py b/homeassistant/components/tuya/light.py index 9416089f898..ee9c92221df 100644 --- a/homeassistant/components/tuya/light.py +++ b/homeassistant/components/tuya/light.py @@ -30,7 +30,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities): if not dev_ids: return entities = await hass.async_add_executor_job( - _setup_entities, hass, dev_ids, platform, + _setup_entities, + hass, + dev_ids, + platform, ) async_add_entities(entities) diff --git a/homeassistant/components/tuya/scene.py b/homeassistant/components/tuya/scene.py index 39613318379..40f9fca11ee 100644 --- a/homeassistant/components/tuya/scene.py +++ b/homeassistant/components/tuya/scene.py @@ -23,7 +23,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities): if not dev_ids: return entities = await hass.async_add_executor_job( - _setup_entities, hass, dev_ids, platform, + _setup_entities, + hass, + dev_ids, + platform, ) async_add_entities(entities) diff --git a/homeassistant/components/tuya/switch.py b/homeassistant/components/tuya/switch.py index 13b4af94a48..e4d0778cab0 100644 --- a/homeassistant/components/tuya/switch.py +++ b/homeassistant/components/tuya/switch.py @@ -23,7 +23,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities): if not dev_ids: return entities = await hass.async_add_executor_job( - _setup_entities, hass, dev_ids, platform, + _setup_entities, + hass, + dev_ids, + platform, ) async_add_entities(entities) diff --git a/homeassistant/components/unifi/controller.py b/homeassistant/components/unifi/controller.py index 82314adb771..3a3229415ab 100644 --- a/homeassistant/components/unifi/controller.py +++ b/homeassistant/components/unifi/controller.py @@ -323,7 +323,9 @@ class UniFiController: client = self.api.clients_all[mac] self.api.clients.process_raw([client.raw]) LOGGER.debug( - "Restore disconnected client %s (%s)", entity.entity_id, client.mac, + "Restore disconnected client %s (%s)", + entity.entity_id, + client.mac, ) wireless_clients = self.hass.data[UNIFI_WIRELESS_CLIENTS] diff --git a/homeassistant/components/upnp/__init__.py b/homeassistant/components/upnp/__init__.py index 3a34cb26604..8479bd06518 100644 --- a/homeassistant/components/upnp/__init__.py +++ b/homeassistant/components/upnp/__init__.py @@ -122,7 +122,8 @@ async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry) # Ensure entry has proper unique_id. if config_entry.unique_id != device.unique_id: hass.config_entries.async_update_entry( - entry=config_entry, unique_id=device.unique_id, + entry=config_entry, + unique_id=device.unique_id, ) # Create device registry entry. diff --git a/homeassistant/components/upnp/config_flow.py b/homeassistant/components/upnp/config_flow.py index 0c57a2c243e..016a5a25017 100644 --- a/homeassistant/components/upnp/config_flow.py +++ b/homeassistant/components/upnp/config_flow.py @@ -90,7 +90,10 @@ class UpnpFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): ), } ) - return self.async_show_form(step_id="user", data_schema=data_schema,) + return self.async_show_form( + step_id="user", + data_schema=data_schema, + ) async def async_step_import(self, import_info: Optional[Mapping]): """Import a new UPnP/IGD device as a config entry. @@ -183,11 +186,13 @@ class UpnpFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return UpnpOptionsFlowHandler(config_entry) async def _async_create_entry_from_discovery( - self, discovery: Mapping, + self, + discovery: Mapping, ): """Create an entry from discovery.""" _LOGGER.debug( - "_async_create_entry_from_data: discovery: %s", discovery, + "_async_create_entry_from_data: discovery: %s", + discovery, ) # Get name from device, if not found already. if DISCOVERY_NAME not in discovery and DISCOVERY_LOCATION in discovery: @@ -238,9 +243,10 @@ class UpnpOptionsFlowHandler(config_entries.OptionsFlow): step_id="init", data_schema=vol.Schema( { - vol.Optional(CONF_SCAN_INTERVAL, default=scan_interval,): vol.All( - vol.Coerce(int), vol.Range(min=30) - ), + vol.Optional( + CONF_SCAN_INTERVAL, + default=scan_interval, + ): vol.All(vol.Coerce(int), vol.Range(min=30)), } ), ) diff --git a/homeassistant/components/vera/__init__.py b/homeassistant/components/vera/__init__.py index 263f5f0025b..b45716b33d6 100644 --- a/homeassistant/components/vera/__init__.py +++ b/homeassistant/components/vera/__init__.py @@ -61,7 +61,9 @@ async def async_setup(hass: HomeAssistant, base_config: dict) -> bool: hass.async_create_task( hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=config, + DOMAIN, + context={"source": config_entries.SOURCE_IMPORT}, + data=config, ) ) diff --git a/homeassistant/components/vera/config_flow.py b/homeassistant/components/vera/config_flow.py index cac17951cc1..a040e4b96b5 100644 --- a/homeassistant/components/vera/config_flow.py +++ b/homeassistant/components/vera/config_flow.py @@ -42,10 +42,12 @@ def options_schema(options: dict = None) -> dict: options = options or {} return { vol.Optional( - CONF_LIGHTS, default=list_to_str(options.get(CONF_LIGHTS, [])), + CONF_LIGHTS, + default=list_to_str(options.get(CONF_LIGHTS, [])), ): str, vol.Optional( - CONF_EXCLUDE, default=list_to_str(options.get(CONF_EXCLUDE, [])), + CONF_EXCLUDE, + default=list_to_str(options.get(CONF_EXCLUDE, [])), ): str, } @@ -68,7 +70,10 @@ class OptionsFlowHandler(config_entries.OptionsFlow): async def async_step_init(self, user_input=None): """Manage the options.""" if user_input is not None: - return self.async_create_entry(title="", data=options_data(user_input),) + return self.async_create_entry( + title="", + data=options_data(user_input), + ) return self.async_show_form( step_id="init", diff --git a/homeassistant/components/vizio/media_player.py b/homeassistant/components/vizio/media_player.py index a2f67b1d5c8..cbddbaa6897 100644 --- a/homeassistant/components/vizio/media_player.py +++ b/homeassistant/components/vizio/media_player.py @@ -226,8 +226,10 @@ class VizioDevice(MediaPlayerEntity): self._supported_commands |= SUPPORT_SELECT_SOUND_MODE self._current_sound_mode = audio_settings[VIZIO_SOUND_MODE] if not self._available_sound_modes: - self._available_sound_modes = await self._device.get_setting_options( - VIZIO_AUDIO_SETTINGS, VIZIO_SOUND_MODE + self._available_sound_modes = ( + await self._device.get_setting_options( + VIZIO_AUDIO_SETTINGS, VIZIO_SOUND_MODE + ) ) else: # Explicitly remove SUPPORT_SELECT_SOUND_MODE from supported features @@ -291,7 +293,9 @@ class VizioDevice(MediaPlayerEntity): ) -> None: """Update a setting when update_setting service is called.""" await self._device.set_setting( - setting_type, setting_name, new_value, + setting_type, + setting_name, + new_value, ) async def async_added_to_hass(self) -> None: diff --git a/homeassistant/components/waqi/sensor.py b/homeassistant/components/waqi/sensor.py index cdac719d890..90e55ea08a0 100644 --- a/homeassistant/components/waqi/sensor.py +++ b/homeassistant/components/waqi/sensor.py @@ -74,11 +74,15 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= _LOGGER.debug("The following stations were returned: %s", stations) for station in stations: waqi_sensor = WaqiSensor(client, station) - if not station_filter or { - waqi_sensor.uid, - waqi_sensor.url, - waqi_sensor.station_name, - } & set(station_filter): + if ( + not station_filter + or { + waqi_sensor.uid, + waqi_sensor.url, + waqi_sensor.station_name, + } + & set(station_filter) + ): dev.append(waqi_sensor) except (aiohttp.client_exceptions.ClientConnectorError, asyncio.TimeoutError): _LOGGER.exception("Failed to connect to WAQI servers") diff --git a/homeassistant/components/wemo/__init__.py b/homeassistant/components/wemo/__init__.py index 9cac85dee09..0594747d0b2 100644 --- a/homeassistant/components/wemo/__init__.py +++ b/homeassistant/components/wemo/__init__.py @@ -121,7 +121,8 @@ async def async_setup_entry(hass, entry): _LOGGER.debug("Scanning network for WeMo devices...") for device in await hass.async_add_executor_job(pywemo.discover_devices): devices.setdefault( - device.serialnumber, device, + device.serialnumber, + device, ) loaded_components = set() @@ -153,7 +154,9 @@ async def async_setup_entry(hass, entry): else: async_dispatcher_send( - hass, f"{DOMAIN}.{component}", device, + hass, + f"{DOMAIN}.{component}", + device, ) return True @@ -172,7 +175,10 @@ def validate_static_config(host, port): try: device = pywemo.discovery.device_from_description(url, None) - except (requests.exceptions.ConnectionError, requests.exceptions.Timeout,) as err: + except ( + requests.exceptions.ConnectionError, + requests.exceptions.Timeout, + ) as err: _LOGGER.error("Unable to access WeMo at %s (%s)", url, err) return None diff --git a/homeassistant/components/wemo/fan.py b/homeassistant/components/wemo/fan.py index f2cb46fa32c..1bc477277c9 100644 --- a/homeassistant/components/wemo/fan.py +++ b/homeassistant/components/wemo/fan.py @@ -129,7 +129,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities): # Register service(s) hass.services.async_register( - WEMO_DOMAIN, SERVICE_SET_HUMIDITY, service_handle, schema=SET_HUMIDITY_SCHEMA, + WEMO_DOMAIN, + SERVICE_SET_HUMIDITY, + service_handle, + schema=SET_HUMIDITY_SCHEMA, ) hass.services.async_register( diff --git a/homeassistant/components/wilight/parent_device.py b/homeassistant/components/wilight/parent_device.py index 9c2c0c1a1de..a53bc352a7b 100644 --- a/homeassistant/components/wilight/parent_device.py +++ b/homeassistant/components/wilight/parent_device.py @@ -95,7 +95,10 @@ def create_api_device(host): """Create an API Device.""" try: device = pywilight.device_from_host(host) - except (requests.exceptions.ConnectionError, requests.exceptions.Timeout,) as err: + except ( + requests.exceptions.ConnectionError, + requests.exceptions.Timeout, + ) as err: _LOGGER.error("Unable to access WiLight at %s (%s)", host, err) return None diff --git a/homeassistant/components/wirelesstag/__init__.py b/homeassistant/components/wirelesstag/__init__.py index 2c2add94527..0b0a6ee519f 100644 --- a/homeassistant/components/wirelesstag/__init__.py +++ b/homeassistant/components/wirelesstag/__init__.py @@ -122,7 +122,8 @@ class WirelessTagPlatform: ) else: _LOGGER.info( - "Installed push notifications for all tags in %s", mac, + "Installed push notifications for all tags in %s", + mac, ) @property diff --git a/homeassistant/components/withings/common.py b/homeassistant/components/withings/common.py index 2f3f4bf849a..23c68facb6f 100644 --- a/homeassistant/components/withings/common.py +++ b/homeassistant/components/withings/common.py @@ -53,7 +53,10 @@ from . import const from .const import Measurement _LOGGER = logging.getLogger(const.LOG_NAMESPACE) -NOT_AUTHENTICATED_ERROR = re.compile("^401,.*", re.IGNORECASE,) +NOT_AUTHENTICATED_ERROR = re.compile( + "^401,.*", + re.IGNORECASE, +) DATA_UPDATED_SIGNAL = "withings_entity_state_updated" MeasurementData = Dict[Measurement, Any] @@ -621,8 +624,8 @@ class DataManager: def empty_listener() -> None: pass - self._cancel_subscription_update = self.subscription_update_coordinator.async_add_listener( - empty_listener + self._cancel_subscription_update = ( + self.subscription_update_coordinator.async_add_listener(empty_listener) ) def async_stop_polling_webhook_subscriptions(self) -> None: @@ -753,7 +756,8 @@ class DataManager: # Start a reauth flow. await self._hass.config_entries.flow.async_init( - const.DOMAIN, context=context, + const.DOMAIN, + context=context, ) return @@ -883,7 +887,9 @@ async def async_get_entity_id( hass: HomeAssistant, attribute: WithingsAttribute, user_id: int ) -> Optional[str]: """Get an entity id for a user's attribute.""" - entity_registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry() + entity_registry: EntityRegistry = ( + await hass.helpers.entity_registry.async_get_registry() + ) unique_id = get_attribute_unique_id(attribute, user_id) entity_id = entity_registry.async_get_entity_id( diff --git a/homeassistant/components/withings/sensor.py b/homeassistant/components/withings/sensor.py index a7580faa3d0..a55d83d717b 100644 --- a/homeassistant/components/withings/sensor.py +++ b/homeassistant/components/withings/sensor.py @@ -17,7 +17,10 @@ async def async_setup_entry( """Set up the sensor config entry.""" entities = await async_create_entities( - hass, entry, WithingsHealthSensor, SENSOR_DOMAIN, + hass, + entry, + WithingsHealthSensor, + SENSOR_DOMAIN, ) async_add_entities(entities, True) diff --git a/homeassistant/components/wled/__init__.py b/homeassistant/components/wled/__init__.py index 5cc2453d78c..76b61dd7808 100644 --- a/homeassistant/components/wled/__init__.py +++ b/homeassistant/components/wled/__init__.py @@ -111,13 +111,19 @@ class WLEDDataUpdateCoordinator(DataUpdateCoordinator[WLEDDevice]): """Class to manage fetching WLED data from single endpoint.""" def __init__( - self, hass: HomeAssistant, *, host: str, + self, + hass: HomeAssistant, + *, + host: str, ): """Initialize global WLED data updater.""" self.wled = WLED(host, session=async_get_clientsession(hass)) super().__init__( - hass, _LOGGER, name=DOMAIN, update_interval=SCAN_INTERVAL, + hass, + _LOGGER, + name=DOMAIN, + update_interval=SCAN_INTERVAL, ) def update_listeners(self) -> None: diff --git a/homeassistant/components/worldclock/sensor.py b/homeassistant/components/worldclock/sensor.py index 86daa6e994a..3a3853d9f68 100644 --- a/homeassistant/components/worldclock/sensor.py +++ b/homeassistant/components/worldclock/sensor.py @@ -32,7 +32,14 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= time_zone = dt_util.get_time_zone(config.get(CONF_TIME_ZONE)) async_add_entities( - [WorldClockSensor(time_zone, name, config.get(CONF_TIME_FORMAT),)], True, + [ + WorldClockSensor( + time_zone, + name, + config.get(CONF_TIME_FORMAT), + ) + ], + True, ) diff --git a/homeassistant/components/xiaomi_aqara/binary_sensor.py b/homeassistant/components/xiaomi_aqara/binary_sensor.py index 0709c7e83fa..fecdfd91a75 100644 --- a/homeassistant/components/xiaomi_aqara/binary_sensor.py +++ b/homeassistant/components/xiaomi_aqara/binary_sensor.py @@ -295,7 +295,12 @@ class XiaomiDoorSensor(XiaomiBinarySensor): else: data_key = "window_status" super().__init__( - device, "Door Window Sensor", xiaomi_hub, data_key, "opening", config_entry, + device, + "Door Window Sensor", + xiaomi_hub, + data_key, + "opening", + config_entry, ) @property @@ -340,7 +345,12 @@ class XiaomiWaterLeakSensor(XiaomiBinarySensor): else: data_key = "wleak_status" super().__init__( - device, "Water Leak Sensor", xiaomi_hub, data_key, "moisture", config_entry, + device, + "Water Leak Sensor", + xiaomi_hub, + data_key, + "moisture", + config_entry, ) def parse_data(self, data, raw_data): diff --git a/homeassistant/components/xiaomi_miio/remote.py b/homeassistant/components/xiaomi_miio/remote.py index eb4e6df9acd..9c8d06e0b0d 100644 --- a/homeassistant/components/xiaomi_miio/remote.py +++ b/homeassistant/components/xiaomi_miio/remote.py @@ -158,10 +158,14 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_service_learn_handler, ) platform.async_register_entity_service( - SERVICE_SET_REMOTE_LED_ON, {}, async_service_led_on_handler, + SERVICE_SET_REMOTE_LED_ON, + {}, + async_service_led_on_handler, ) platform.async_register_entity_service( - SERVICE_SET_REMOTE_LED_OFF, {}, async_service_led_off_handler, + SERVICE_SET_REMOTE_LED_OFF, + {}, + async_service_led_off_handler, ) diff --git a/homeassistant/components/xs1/__init__.py b/homeassistant/components/xs1/__init__.py index 1fbcb49d0c9..8651c33546c 100644 --- a/homeassistant/components/xs1/__init__.py +++ b/homeassistant/components/xs1/__init__.py @@ -63,7 +63,8 @@ def setup(hass, config): ) except ConnectionError as error: _LOGGER.error( - "Failed to create XS1 API client because of a connection error: %s", error, + "Failed to create XS1 API client because of a connection error: %s", + error, ) return False diff --git a/homeassistant/components/yamaha/media_player.py b/homeassistant/components/yamaha/media_player.py index 196e6605eab..5147e57dfc6 100644 --- a/homeassistant/components/yamaha/media_player.py +++ b/homeassistant/components/yamaha/media_player.py @@ -154,7 +154,9 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= # Register Service 'select_scene' platform = entity_platform.current_platform.get() platform.async_register_entity_service( - SERVICE_SELECT_SCENE, {vol.Required(ATTR_SCENE): cv.string}, "set_scene", + SERVICE_SELECT_SCENE, + {vol.Required(ATTR_SCENE): cv.string}, + "set_scene", ) # Register Service 'enable_output' platform.async_register_entity_service( diff --git a/homeassistant/components/zha/config_flow.py b/homeassistant/components/zha/config_flow.py index e3a2044454a..473d39c6f7a 100644 --- a/homeassistant/components/zha/config_flow.py +++ b/homeassistant/components/zha/config_flow.py @@ -60,7 +60,10 @@ class ZhaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): if auto_detected_data is not None: title = f"{port.description}, s/n: {port.serial_number or 'n/a'}" title += f" - {port.manufacturer}" if port.manufacturer else "" - return self.async_create_entry(title=title, data=auto_detected_data,) + return self.async_create_entry( + title=title, + data=auto_detected_data, + ) # did not detect anything self._device_path = dev_path @@ -78,7 +81,8 @@ class ZhaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): schema = {vol.Required(CONF_RADIO_TYPE): vol.In(sorted(RadioType.list()))} return self.async_show_form( - step_id="pick_radio", data_schema=vol.Schema(schema), + step_id="pick_radio", + data_schema=vol.Schema(schema), ) async def async_step_port_config(self, user_input=None): @@ -113,7 +117,9 @@ class ZhaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): schema[param] = value return self.async_show_form( - step_id="port_config", data_schema=vol.Schema(schema), errors=errors, + step_id="port_config", + data_schema=vol.Schema(schema), + errors=errors, ) diff --git a/homeassistant/components/zha/core/channels/hvac.py b/homeassistant/components/zha/core/channels/hvac.py index 56345916cd3..17fbb86fc63 100644 --- a/homeassistant/components/zha/core/channels/hvac.py +++ b/homeassistant/components/zha/core/channels/hvac.py @@ -332,7 +332,10 @@ class ThermostatChannel(ZigbeeChannel): if not isinstance(res, list): # assume default response self.debug( - "attr reporting for '%s' on '%s': %s", attrs, self.name, res, + "attr reporting for '%s' on '%s': %s", + attrs, + self.name, + res, ) return if res[0].status == Status.SUCCESS and len(res) == 1: diff --git a/homeassistant/components/zone/__init__.py b/homeassistant/components/zone/__init__.py index 5f65f1e9596..c3e1beb44af 100644 --- a/homeassistant/components/zone/__init__.py +++ b/homeassistant/components/zone/__init__.py @@ -76,7 +76,8 @@ def empty_value(value: Any) -> Any: CONFIG_SCHEMA = vol.Schema( { vol.Optional(DOMAIN, default=[]): vol.Any( - vol.All(cv.ensure_list, [vol.Schema(CREATE_FIELDS)]), empty_value, + vol.All(cv.ensure_list, [vol.Schema(CREATE_FIELDS)]), + empty_value, ) }, extra=vol.ALLOW_EXTRA, @@ -234,7 +235,10 @@ async def async_setup(hass: HomeAssistant, config: Dict) -> bool: if component.get_entity("zone.home"): return True - home_zone = Zone(_home_conf(hass), True,) + home_zone = Zone( + _home_conf(hass), + True, + ) home_zone.entity_id = ENTITY_ID_HOME await component.async_add_entities([home_zone]) diff --git a/homeassistant/config.py b/homeassistant/config.py index a327ca630f8..80b5a203564 100644 --- a/homeassistant/config.py +++ b/homeassistant/config.py @@ -809,9 +809,7 @@ async def async_process_component_config( # Validate platform specific schema if hasattr(platform, "PLATFORM_SCHEMA"): try: - p_validated = platform.PLATFORM_SCHEMA( # type: ignore - p_config - ) + p_validated = platform.PLATFORM_SCHEMA(p_config) # type: ignore except vol.Invalid as ex: async_log_exception( ex, diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index 01eb63fe05f..878d162c2ff 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -225,9 +225,7 @@ class ConfigEntry: return try: - result = await component.async_setup_entry( # type: ignore - hass, self - ) + result = await component.async_setup_entry(hass, self) # type: ignore if not isinstance(result, bool): _LOGGER.error( @@ -312,9 +310,7 @@ class ConfigEntry: return False try: - result = await component.async_unload_entry( # type: ignore - hass, self - ) + result = await component.async_unload_entry(hass, self) # type: ignore assert isinstance(result, bool) @@ -349,9 +345,7 @@ class ConfigEntry: if not hasattr(component, "async_remove_entry"): return try: - await component.async_remove_entry( # type: ignore - hass, self - ) + await component.async_remove_entry(hass, self) # type: ignore except Exception: # pylint: disable=broad-except _LOGGER.exception( "Error calling entry remove callback %s for %s", @@ -389,9 +383,7 @@ class ConfigEntry: return False try: - result = await component.async_migrate_entry( # type: ignore - hass, self - ) + result = await component.async_migrate_entry(hass, self) # type: ignore if not isinstance(result, bool): _LOGGER.error( "%s.async_migrate_entry did not return boolean", self.domain @@ -878,7 +870,9 @@ class ConfigFlow(data_entry_flow.FlowHandler): @callback def _abort_if_unique_id_configured( - self, updates: Optional[Dict[Any, Any]] = None, reload_on_update: bool = True, + self, + updates: Optional[Dict[Any, Any]] = None, + reload_on_update: bool = True, ) -> None: """Abort if the unique ID is already configured.""" assert self.hass diff --git a/homeassistant/core.py b/homeassistant/core.py index c5a54f0374f..6b44386eadf 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -319,9 +319,7 @@ class HomeAssistant: elif is_callback(check_target): self.loop.call_soon(target, *args) else: - task = self.loop.run_in_executor( # type: ignore - None, target, *args - ) + task = self.loop.run_in_executor(None, target, *args) # type: ignore # If a task is scheduled if self._track_task and task is not None: diff --git a/homeassistant/data_entry_flow.py b/homeassistant/data_entry_flow.py index 49195e1a89a..b553c190f55 100644 --- a/homeassistant/data_entry_flow.py +++ b/homeassistant/data_entry_flow.py @@ -51,7 +51,10 @@ class AbortFlow(FlowError): class FlowManager(abc.ABC): """Manage all the flows that are in progress.""" - def __init__(self, hass: HomeAssistant,) -> None: + def __init__( + self, + hass: HomeAssistant, + ) -> None: """Initialize the flow manager.""" self.hass = hass self._initializing: Dict[str, List[asyncio.Future]] = {} diff --git a/homeassistant/helpers/aiohttp_client.py b/homeassistant/helpers/aiohttp_client.py index 316c02a82f0..d20e34cca36 100644 --- a/homeassistant/helpers/aiohttp_client.py +++ b/homeassistant/helpers/aiohttp_client.py @@ -68,7 +68,9 @@ def async_create_clientsession( connector = _async_get_connector(hass, verify_ssl) clientsession = aiohttp.ClientSession( - connector=connector, headers={USER_AGENT: SERVER_SOFTWARE}, **kwargs, + connector=connector, + headers={USER_AGENT: SERVER_SOFTWARE}, + **kwargs, ) clientsession.close = warn_use( # type: ignore diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index 72cc4650978..5b3366d7554 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -468,9 +468,7 @@ class Entity(ABC): if hasattr(self, "async_update"): await self.async_update() # type: ignore elif hasattr(self, "update"): - await self.hass.async_add_executor_job( - self.update # type: ignore - ) + await self.hass.async_add_executor_job(self.update) # type: ignore finally: self._update_staged = False if warning: diff --git a/homeassistant/helpers/entity_component.py b/homeassistant/helpers/entity_component.py index e3dcbbc3c79..b9d073dbe2e 100644 --- a/homeassistant/helpers/entity_component.py +++ b/homeassistant/helpers/entity_component.py @@ -106,11 +106,7 @@ class EntityComponent: This doesn't block the executor to protect from deadlocks. """ - self.hass.add_job( - self.async_setup( # type: ignore - config - ) - ) + self.hass.add_job(self.async_setup(config)) # type: ignore async def async_setup(self, config: ConfigType) -> None: """Set up a full entity component. diff --git a/homeassistant/helpers/entity_platform.py b/homeassistant/helpers/entity_platform.py index d5fad7fd025..32ef88d361f 100644 --- a/homeassistant/helpers/entity_platform.py +++ b/homeassistant/helpers/entity_platform.py @@ -322,7 +322,9 @@ class EntityPlatform: return self._async_unsub_polling = async_track_time_interval( - self.hass, self._update_entity_states, self.scan_interval, + self.hass, + self._update_entity_states, + self.scan_interval, ) async def _async_add_entity( diff --git a/homeassistant/helpers/instance_id.py b/homeassistant/helpers/instance_id.py index 1df039da47a..5feca605099 100644 --- a/homeassistant/helpers/instance_id.py +++ b/homeassistant/helpers/instance_id.py @@ -18,7 +18,9 @@ async def async_get(hass: HomeAssistant) -> str: store = storage.Store(hass, DATA_VERSION, DATA_KEY, True) data: Optional[Dict[str, str]] = await storage.async_migrator( # type: ignore - hass, hass.config.path(LEGACY_UUID_FILE), store, + hass, + hass.config.path(LEGACY_UUID_FILE), + store, ) if data is not None: diff --git a/homeassistant/helpers/reload.py b/homeassistant/helpers/reload.py index 73d78501578..4ff9198f233 100644 --- a/homeassistant/helpers/reload.py +++ b/homeassistant/helpers/reload.py @@ -97,5 +97,6 @@ def setup_reload_service( """Sync version of async_setup_reload_service.""" asyncio.run_coroutine_threadsafe( - async_setup_reload_service(hass, domain, platforms), hass.loop, + async_setup_reload_service(hass, domain, platforms), + hass.loop, ).result() diff --git a/homeassistant/helpers/script.py b/homeassistant/helpers/script.py index c59d53f2e87..7148f633dfb 100644 --- a/homeassistant/helpers/script.py +++ b/homeassistant/helpers/script.py @@ -450,7 +450,9 @@ class _ScriptRun: ) except exceptions.TemplateError as ex: self._log( - "Error rendering event data template: %s", ex, level=logging.ERROR, + "Error rendering event data template: %s", + ex, + level=logging.ERROR, ) self._hass.bus.async_fire( diff --git a/homeassistant/helpers/storage.py b/homeassistant/helpers/storage.py index 13525b4dab1..daf9e2f6a89 100644 --- a/homeassistant/helpers/storage.py +++ b/homeassistant/helpers/storage.py @@ -20,7 +20,12 @@ _LOGGER = logging.getLogger(__name__) @bind_hass async def async_migrator( - hass, old_path, store, *, old_conf_load_func=None, old_conf_migrate_func=None, + hass, + old_path, + store, + *, + old_conf_load_func=None, + old_conf_migrate_func=None, ): """Migrate old data to a store and then load data. diff --git a/homeassistant/helpers/translation.py b/homeassistant/helpers/translation.py index 217f16d1841..53d808a5a85 100644 --- a/homeassistant/helpers/translation.py +++ b/homeassistant/helpers/translation.py @@ -92,7 +92,9 @@ def load_translations_files( def merge_resources( - translation_strings: Dict[str, Dict[str, Any]], components: Set[str], category: str, + translation_strings: Dict[str, Dict[str, Any]], + components: Set[str], + category: str, ) -> Dict[str, Dict[str, Any]]: """Build and merge the resources response for the given components and platforms.""" # Build response @@ -153,7 +155,9 @@ def merge_resources( def build_resources( - translation_strings: Dict[str, Dict[str, Any]], components: Set[str], category: str, + translation_strings: Dict[str, Dict[str, Any]], + components: Set[str], + category: str, ) -> Dict[str, Dict[str, Any]]: """Build the resources response for the given components.""" # Build response diff --git a/homeassistant/runner.py b/homeassistant/runner.py index b397f9438f2..f35de991a27 100644 --- a/homeassistant/runner.py +++ b/homeassistant/runner.py @@ -117,7 +117,9 @@ def _async_loop_exception_handler(_: Any, context: Dict) -> None: ) -async def setup_and_run_hass(runtime_config: RuntimeConfig,) -> int: +async def setup_and_run_hass( + runtime_config: RuntimeConfig, +) -> int: """Set up Home Assistant and run.""" hass = await bootstrap.async_setup_hass(runtime_config) diff --git a/homeassistant/setup.py b/homeassistant/setup.py index 341229a83b1..870b476d605 100644 --- a/homeassistant/setup.py +++ b/homeassistant/setup.py @@ -177,9 +177,7 @@ async def _async_setup_component( try: if hasattr(component, "async_setup"): - task = component.async_setup( # type: ignore - hass, processed_config - ) + task = component.async_setup(hass, processed_config) # type: ignore elif hasattr(component, "setup"): # This should not be replaced with hass.async_add_executor_job because # we don't want to track this task in case it blocks startup. diff --git a/homeassistant/util/timeout.py b/homeassistant/util/timeout.py index 908d36a41bb..1193c701712 100644 --- a/homeassistant/util/timeout.py +++ b/homeassistant/util/timeout.py @@ -255,7 +255,10 @@ class _ZoneTaskContext: """Context manager that tracks an active task for a zone.""" def __init__( - self, zone: _ZoneTimeoutManager, task: asyncio.Task[Any], timeout: float, + self, + zone: _ZoneTimeoutManager, + task: asyncio.Task[Any], + timeout: float, ) -> None: """Initialize internal timeout context manager.""" self._loop: asyncio.AbstractEventLoop = asyncio.get_running_loop() diff --git a/homeassistant/util/unit_system.py b/homeassistant/util/unit_system.py index 8b276da432d..bac66cd28bc 100644 --- a/homeassistant/util/unit_system.py +++ b/homeassistant/util/unit_system.py @@ -137,9 +137,7 @@ class UnitSystem: raise TypeError(f"{volume!s} is not a numeric value.") # type ignore: https://github.com/python/mypy/issues/7207 - return volume_util.convert( # type: ignore - volume, from_unit, self.volume_unit - ) + return volume_util.convert(volume, from_unit, self.volume_unit) # type: ignore def as_dict(self) -> dict: """Convert the unit system to a dictionary.""" diff --git a/homeassistant/util/yaml/loader.py b/homeassistant/util/yaml/loader.py index 982446597e5..a58480e26b7 100644 --- a/homeassistant/util/yaml/loader.py +++ b/homeassistant/util/yaml/loader.py @@ -88,9 +88,7 @@ def _add_reference( ... -def _add_reference( # type: ignore - obj, loader: SafeLineLoader, node: yaml.nodes.Node -): +def _add_reference(obj, loader: SafeLineLoader, node: yaml.nodes.Node): # type: ignore """Add file reference information to an object.""" if isinstance(obj, list): obj = NodeListClass(obj) diff --git a/requirements_test_pre_commit.txt b/requirements_test_pre_commit.txt index 62c8fa113de..ceca5145010 100644 --- a/requirements_test_pre_commit.txt +++ b/requirements_test_pre_commit.txt @@ -1,7 +1,7 @@ # Automatically generated from .pre-commit-config.yaml by gen_requirements_all.py, do not edit bandit==1.6.2 -black==19.10b0 +black==20.8b1 codespell==1.17.1 flake8-docstrings==1.5.0 flake8==3.8.3 diff --git a/script/scaffold/templates/config_flow/tests/test_config_flow.py b/script/scaffold/templates/config_flow/tests/test_config_flow.py index d6dee8d0bd0..7cd09ad1f42 100644 --- a/script/scaffold/templates/config_flow/tests/test_config_flow.py +++ b/script/scaffold/templates/config_flow/tests/test_config_flow.py @@ -21,7 +21,8 @@ async def test_form(hass): ), patch( "homeassistant.components.NEW_DOMAIN.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.NEW_DOMAIN.async_setup_entry", return_value=True, + "homeassistant.components.NEW_DOMAIN.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/script/scaffold/templates/config_flow_oauth2/integration/__init__.py b/script/scaffold/templates/config_flow_oauth2/integration/__init__.py index d561f284caf..20b5a03206e 100644 --- a/script/scaffold/templates/config_flow_oauth2/integration/__init__.py +++ b/script/scaffold/templates/config_flow_oauth2/integration/__init__.py @@ -56,8 +56,10 @@ async def async_setup(hass: HomeAssistant, config: dict): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up NEW_NAME from a config entry.""" - implementation = await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry + implementation = ( + await config_entry_oauth2_flow.async_get_config_entry_implementation( + hass, entry + ) ) session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation) diff --git a/script/translations/clean.py b/script/translations/clean.py index 0eabf6214ae..370c1d672ea 100644 --- a/script/translations/clean.py +++ b/script/translations/clean.py @@ -12,7 +12,10 @@ def get_arguments() -> argparse.Namespace: """Get parsed passed in arguments.""" parser = get_base_arg_parser() parser.add_argument( - "--target", type=str, default="core", choices=["core", "frontend"], + "--target", + type=str, + default="core", + choices=["core", "frontend"], ) return parser.parse_args() diff --git a/tests/components/abode/test_alarm_control_panel.py b/tests/components/abode/test_alarm_control_panel.py index d64b211f304..b45599c408e 100644 --- a/tests/components/abode/test_alarm_control_panel.py +++ b/tests/components/abode/test_alarm_control_panel.py @@ -61,7 +61,8 @@ async def test_set_alarm_away(hass): mock_set_away.assert_called_once() with patch( - "abodepy.ALARM.AbodeAlarm.mode", new_callable=PropertyMock, + "abodepy.ALARM.AbodeAlarm.mode", + new_callable=PropertyMock, ) as mock_mode: mock_mode.return_value = CONST.MODE_AWAY diff --git a/tests/components/accuweather/test_config_flow.py b/tests/components/accuweather/test_config_flow.py index 6b7430e524d..2d4769204ac 100644 --- a/tests/components/accuweather/test_config_flow.py +++ b/tests/components/accuweather/test_config_flow.py @@ -55,7 +55,9 @@ async def test_invalid_api_key(hass): ): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data=VALID_CONFIG, + DOMAIN, + context={"source": SOURCE_USER}, + data=VALID_CONFIG, ) assert result["errors"] == {CONF_API_KEY: "invalid_api_key"} @@ -69,7 +71,9 @@ async def test_api_error(hass): ): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data=VALID_CONFIG, + DOMAIN, + context={"source": SOURCE_USER}, + data=VALID_CONFIG, ) assert result["errors"] == {"base": "cannot_connect"} @@ -85,7 +89,9 @@ async def test_requests_exceeded_error(hass): ): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data=VALID_CONFIG, + DOMAIN, + context={"source": SOURCE_USER}, + data=VALID_CONFIG, ) assert result["errors"] == {CONF_API_KEY: "requests_exceeded"} @@ -98,11 +104,15 @@ async def test_integration_already_exists(hass): return_value=json.loads(load_fixture("accuweather/location_data.json")), ): MockConfigEntry( - domain=DOMAIN, unique_id="123456", data=VALID_CONFIG, + domain=DOMAIN, + unique_id="123456", + data=VALID_CONFIG, ).add_to_hass(hass) result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data=VALID_CONFIG, + DOMAIN, + context={"source": SOURCE_USER}, + data=VALID_CONFIG, ) assert result["type"] == "abort" @@ -119,7 +129,9 @@ async def test_create_entry(hass): ): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data=VALID_CONFIG, + DOMAIN, + context={"source": SOURCE_USER}, + data=VALID_CONFIG, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY @@ -133,7 +145,9 @@ async def test_create_entry(hass): async def test_options_flow(hass): """Test config flow options.""" config_entry = MockConfigEntry( - domain=DOMAIN, unique_id="123456", data=VALID_CONFIG, + domain=DOMAIN, + unique_id="123456", + data=VALID_CONFIG, ) config_entry.add_to_hass(hass) diff --git a/tests/components/adguard/test_config_flow.py b/tests/components/adguard/test_config_flow.py index 69e1285889b..dae9e0da79d 100644 --- a/tests/components/adguard/test_config_flow.py +++ b/tests/components/adguard/test_config_flow.py @@ -156,16 +156,22 @@ async def test_hassio_update_instance_running(hass, aioclient_mock): entry.add_to_hass(hass) with patch.object( - hass.config_entries, "async_forward_entry_setup", return_value=True, + hass.config_entries, + "async_forward_entry_setup", + return_value=True, ) as mock_load: assert await hass.config_entries.async_setup(entry.entry_id) assert entry.state == config_entries.ENTRY_STATE_LOADED assert len(mock_load.mock_calls) == 2 with patch.object( - hass.config_entries, "async_forward_entry_unload", return_value=True, + hass.config_entries, + "async_forward_entry_unload", + return_value=True, ) as mock_unload, patch.object( - hass.config_entries, "async_forward_entry_setup", return_value=True, + hass.config_entries, + "async_forward_entry_setup", + return_value=True, ) as mock_load: result = await hass.config_entries.flow.async_init( "adguard", diff --git a/tests/components/agent_dvr/__init__.py b/tests/components/agent_dvr/__init__.py index f0c059d12e2..2cda0b8aa73 100644 --- a/tests/components/agent_dvr/__init__.py +++ b/tests/components/agent_dvr/__init__.py @@ -9,7 +9,9 @@ from tests.test_util.aiohttp import AiohttpClientMocker async def init_integration( - hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, skip_setup: bool = False, + hass: HomeAssistant, + aioclient_mock: AiohttpClientMocker, + skip_setup: bool = False, ) -> MockConfigEntry: """Set up the Agent DVR integration in Home Assistant.""" diff --git a/tests/components/agent_dvr/test_config_flow.py b/tests/components/agent_dvr/test_config_flow.py index 33b5805700f..403dd9f4bee 100644 --- a/tests/components/agent_dvr/test_config_flow.py +++ b/tests/components/agent_dvr/test_config_flow.py @@ -15,7 +15,8 @@ from tests.test_util.aiohttp import AiohttpClientMocker async def test_show_user_form(hass: HomeAssistant) -> None: """Test that the user set up form is served.""" result = await hass.config_entries.flow.async_init( - config_flow.DOMAIN, context={"source": SOURCE_USER}, + config_flow.DOMAIN, + context={"source": SOURCE_USER}, ) assert result["step_id"] == "user" @@ -70,7 +71,8 @@ async def test_full_user_flow_implementation( ) result = await hass.config_entries.flow.async_init( - config_flow.DOMAIN, context={"source": SOURCE_USER}, + config_flow.DOMAIN, + context={"source": SOURCE_USER}, ) assert result["step_id"] == "user" diff --git a/tests/components/airvisual/test_config_flow.py b/tests/components/airvisual/test_config_flow.py index 6741731e0e5..8912b0287d7 100644 --- a/tests/components/airvisual/test_config_flow.py +++ b/tests/components/airvisual/test_config_flow.py @@ -68,7 +68,8 @@ async def test_invalid_identifier(hass): } with patch( - "pyairvisual.api.API.nearest_city", side_effect=InvalidKeyError, + "pyairvisual.api.API.nearest_city", + side_effect=InvalidKeyError, ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_IMPORT}, data=geography_conf @@ -82,7 +83,8 @@ async def test_node_pro_error(hass): node_pro_conf = {CONF_IP_ADDRESS: "192.168.1.100", CONF_PASSWORD: "my_password"} with patch( - "pyairvisual.node.Node.from_samba", side_effect=NodeProError, + "pyairvisual.node.Node.from_samba", + side_effect=NodeProError, ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data={"type": "AirVisual Node/Pro"} diff --git a/tests/components/alexa/test_smart_home.py b/tests/components/alexa/test_smart_home.py index 1ac01c3d3ff..c3bbcbb7a31 100644 --- a/tests/components/alexa/test_smart_home.py +++ b/tests/components/alexa/test_smart_home.py @@ -3296,7 +3296,10 @@ async def test_media_player_sound_mode_list_unsupported(hass): # Test equalizer controller is not there assert_endpoint_capabilities( - appliance, "Alexa", "Alexa.PowerController", "Alexa.EndpointHealth", + appliance, + "Alexa", + "Alexa.PowerController", + "Alexa.EndpointHealth", ) @@ -3832,7 +3835,8 @@ async def test_camera_hass_urls(hass, mock_stream, url, result): {"friendly_name": "Test camera", "supported_features": 3}, ) await async_process_ha_core_config( - hass, {"external_url": url}, + hass, + {"external_url": url}, ) appliance = await discovery_test(device, hass) @@ -3846,7 +3850,8 @@ async def test_initialize_camera_stream(hass, mock_camera, mock_stream): ) await async_process_ha_core_config( - hass, {"external_url": "https://mycamerastream.test"}, + hass, + {"external_url": "https://mycamerastream.test"}, ) with patch( diff --git a/tests/components/almond/test_config_flow.py b/tests/components/almond/test_config_flow.py index 3cbcb2d58bb..49694d84410 100644 --- a/tests/components/almond/test_config_flow.py +++ b/tests/components/almond/test_config_flow.py @@ -18,7 +18,9 @@ async def test_import(hass): """Test that we can import a config entry.""" with patch("pyalmond.WebAlmondAPI.async_list_apps"): assert await setup.async_setup_component( - hass, DOMAIN, {DOMAIN: {"type": "local", "host": "http://localhost:3000"}}, + hass, + DOMAIN, + {DOMAIN: {"type": "local", "host": "http://localhost:3000"}}, ) await hass.async_block_till_done() @@ -34,7 +36,9 @@ async def test_import_cannot_connect(hass): "pyalmond.WebAlmondAPI.async_list_apps", side_effect=asyncio.TimeoutError ): assert await setup.async_setup_component( - hass, DOMAIN, {DOMAIN: {"type": "local", "host": "http://localhost:3000"}}, + hass, + DOMAIN, + {DOMAIN: {"type": "local", "host": "http://localhost:3000"}}, ) await hass.async_block_till_done() diff --git a/tests/components/almond/test_init.py b/tests/components/almond/test_init.py index 9fb228dbf66..35a641bac01 100644 --- a/tests/components/almond/test_init.py +++ b/tests/components/almond/test_init.py @@ -99,7 +99,8 @@ async def test_set_up_local(hass, aioclient_mock): # Set up an internal URL, as Almond won't be set up if there is no URL available await async_process_ha_core_config( - hass, {"internal_url": "https://192.168.0.1"}, + hass, + {"internal_url": "https://192.168.0.1"}, ) entry = MockConfigEntry( diff --git a/tests/components/androidtv/test_media_player.py b/tests/components/androidtv/test_media_player.py index bf16957b07f..2641c2b349d 100644 --- a/tests/components/androidtv/test_media_player.py +++ b/tests/components/androidtv/test_media_player.py @@ -1085,7 +1085,10 @@ async def _test_service( f"androidtv.{androidtv_patch}.{androidtv_method}", return_value=return_value ) as service_call: await hass.services.async_call( - DOMAIN, ha_service_name, service_data=service_data, blocking=True, + DOMAIN, + ha_service_name, + service_data=service_data, + blocking=True, ) assert service_call.called diff --git a/tests/components/arcam_fmj/test_config_flow.py b/tests/components/arcam_fmj/test_config_flow.py index 9475c2f110c..032f57c3113 100644 --- a/tests/components/arcam_fmj/test_config_flow.py +++ b/tests/components/arcam_fmj/test_config_flow.py @@ -56,7 +56,9 @@ def dummy_client_fixture(hass): async def test_ssdp(hass, dummy_client): """Test a ssdp import flow.""" result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=MOCK_DISCOVER, + DOMAIN, + context={CONF_SOURCE: SOURCE_SSDP}, + data=MOCK_DISCOVER, ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == "confirm" @@ -75,7 +77,9 @@ async def test_ssdp_abort(hass): entry.add_to_hass(hass) result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=MOCK_DISCOVER, + DOMAIN, + context={CONF_SOURCE: SOURCE_SSDP}, + data=MOCK_DISCOVER, ) assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["reason"] == "already_configured" @@ -86,7 +90,9 @@ async def test_ssdp_unable_to_connect(hass, dummy_client): dummy_client.start.side_effect = AsyncMock(side_effect=ConnectionFailed) result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=MOCK_DISCOVER, + DOMAIN, + context={CONF_SOURCE: SOURCE_SSDP}, + data=MOCK_DISCOVER, ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == "confirm" @@ -107,7 +113,9 @@ async def test_ssdp_update(hass): entry.add_to_hass(hass) result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=MOCK_DISCOVER, + DOMAIN, + context={CONF_SOURCE: SOURCE_SSDP}, + data=MOCK_DISCOVER, ) assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["reason"] == "already_configured" @@ -119,7 +127,9 @@ async def test_user(hass, aioclient_mock): """Test a manual user configuration flow.""" result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=None, + DOMAIN, + context={CONF_SOURCE: SOURCE_USER}, + data=None, ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -149,7 +159,9 @@ async def test_invalid_ssdp(hass, aioclient_mock): aioclient_mock.get(MOCK_UPNP_LOCATION, text="") result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=user_input, + DOMAIN, + context={CONF_SOURCE: SOURCE_USER}, + data=user_input, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result["title"] == f"Arcam FMJ ({MOCK_HOST})" @@ -166,7 +178,9 @@ async def test_user_wrong(hass, aioclient_mock): aioclient_mock.get(MOCK_UPNP_LOCATION, status=404) result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=user_input, + DOMAIN, + context={CONF_SOURCE: SOURCE_USER}, + data=user_input, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result["title"] == f"Arcam FMJ ({MOCK_HOST})" diff --git a/tests/components/arcam_fmj/test_device_trigger.py b/tests/components/arcam_fmj/test_device_trigger.py index 7d0aca8628e..2a119fd2017 100644 --- a/tests/components/arcam_fmj/test_device_trigger.py +++ b/tests/components/arcam_fmj/test_device_trigger.py @@ -38,7 +38,8 @@ async def test_get_triggers(hass, device_reg, entity_reg): config_entry = MockConfigEntry(domain=DOMAIN, data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( - config_entry_id=config_entry.entry_id, identifiers={(DOMAIN, "host", 1234)}, + config_entry_id=config_entry.entry_id, + identifiers={(DOMAIN, "host", 1234)}, ) entity_reg.async_get_or_create( "media_player", DOMAIN, "5678", device_id=device_entry.id @@ -83,7 +84,10 @@ async def test_if_fires_on_turn_on_request(hass, calls, player_setup, state): ) await hass.services.async_call( - "media_player", "turn_on", {"entity_id": player_setup}, blocking=True, + "media_player", + "turn_on", + {"entity_id": player_setup}, + blocking=True, ) await hass.async_block_till_done() diff --git a/tests/components/atag/test_climate.py b/tests/components/atag/test_climate.py index 0ccb67d0eb5..48418050d2d 100644 --- a/tests/components/atag/test_climate.py +++ b/tests/components/atag/test_climate.py @@ -80,7 +80,8 @@ async def test_setting_climate( async def test_incorrect_modes( - hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, + hass: HomeAssistant, + aioclient_mock: AiohttpClientMocker, ) -> None: """Test incorrect values are handled correctly.""" with patch( diff --git a/tests/components/atag/test_config_flow.py b/tests/components/atag/test_config_flow.py index dc675e24eba..63cac2a0e9c 100644 --- a/tests/components/atag/test_config_flow.py +++ b/tests/components/atag/test_config_flow.py @@ -38,7 +38,8 @@ async def test_adding_second_device( assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["reason"] == "already_configured" with patch( - "pyatag.AtagOne.id", new_callable=PropertyMock(return_value="secondary_device"), + "pyatag.AtagOne.id", + new_callable=PropertyMock(return_value="secondary_device"), ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER}, data=USER_INPUT @@ -50,7 +51,9 @@ async def test_connection_error(hass): """Test we show user form on Atag connection error.""" with patch("pyatag.AtagOne.authorize", side_effect=errors.AtagException()): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_USER}, data=USER_INPUT, + DOMAIN, + context={"source": config_entries.SOURCE_USER}, + data=USER_INPUT, ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -62,7 +65,9 @@ async def test_unauthorized(hass): """Test we show correct form when Unauthorized error is raised.""" with patch("pyatag.AtagOne.authorize", side_effect=errors.Unauthorized()): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_USER}, data=USER_INPUT, + DOMAIN, + context={"source": config_entries.SOURCE_USER}, + data=USER_INPUT, ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == "user" @@ -74,13 +79,17 @@ async def test_full_flow_implementation( ) -> None: """Test registering an integration and finishing flow works.""" aioclient_mock.get( - "http://127.0.0.1:10000/retrieve", json=RECEIVE_REPLY, + "http://127.0.0.1:10000/retrieve", + json=RECEIVE_REPLY, ) aioclient_mock.post( - "http://127.0.0.1:10000/pair", json=PAIR_REPLY, + "http://127.0.0.1:10000/pair", + json=PAIR_REPLY, ) result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_USER}, data=USER_INPUT, + DOMAIN, + context={"source": config_entries.SOURCE_USER}, + data=USER_INPUT, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result["title"] == UID diff --git a/tests/components/august/test_config_flow.py b/tests/components/august/test_config_flow.py index ed75bc3685c..2f20347acae 100644 --- a/tests/components/august/test_config_flow.py +++ b/tests/components/august/test_config_flow.py @@ -34,7 +34,8 @@ async def test_form(hass): ), patch( "homeassistant.components.august.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.august.async_setup_entry", return_value=True, + "homeassistant.components.august.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -149,7 +150,8 @@ async def test_form_needs_validate(hass): "homeassistant.components.august.async_setup_entry", return_value=True ) as mock_setup_entry: result3 = await hass.config_entries.flow.async_configure( - result["flow_id"], {VERIFICATION_CODE_KEY: "incorrect"}, + result["flow_id"], + {VERIFICATION_CODE_KEY: "incorrect"}, ) # Make sure we do not resend the code again @@ -176,7 +178,8 @@ async def test_form_needs_validate(hass): "homeassistant.components.august.async_setup_entry", return_value=True ) as mock_setup_entry: result4 = await hass.config_entries.flow.async_configure( - result["flow_id"], {VERIFICATION_CODE_KEY: "correct"}, + result["flow_id"], + {VERIFICATION_CODE_KEY: "correct"}, ) assert len(mock_send_verification_code.mock_calls) == 0 diff --git a/tests/components/august/test_init.py b/tests/components/august/test_init.py index f29403c9f21..bcc05e51c71 100644 --- a/tests/components/august/test_init.py +++ b/tests/components/august/test_init.py @@ -42,7 +42,9 @@ async def test_august_is_offline(hass): """Config entry state is ENTRY_STATE_SETUP_RETRY when august is offline.""" config_entry = MockConfigEntry( - domain=DOMAIN, data=_mock_get_config()[DOMAIN], title="August august", + domain=DOMAIN, + data=_mock_get_config()[DOMAIN], + title="August august", ) config_entry.add_to_hass(hass) @@ -146,7 +148,8 @@ async def test_set_up_from_yaml(hass): await setup.async_setup_component(hass, "persistent_notification", {}) with patch( - "homeassistant.components.august.async_setup_august", return_value=True, + "homeassistant.components.august.async_setup_august", + return_value=True, ) as mock_setup_august, patch( "homeassistant.components.august.config_flow.AugustGateway.async_authenticate", return_value=True, diff --git a/tests/components/august/test_lock.py b/tests/components/august/test_lock.py index e455960fef3..f36a5e3f180 100644 --- a/tests/components/august/test_lock.py +++ b/tests/components/august/test_lock.py @@ -105,7 +105,8 @@ async def test_one_lock_operation(hass): async def test_one_lock_unknown_state(hass): """Test creation of a lock with doorsense and bridge.""" lock_one = await _mock_lock_from_fixture( - hass, "get_lock.online.unknown_state.json", + hass, + "get_lock.online.unknown_state.json", ) await _create_august_with_devices(hass, [lock_one]) diff --git a/tests/components/auth/test_indieauth.py b/tests/components/auth/test_indieauth.py index 8a02502e16c..e8aabce4678 100644 --- a/tests/components/auth/test_indieauth.py +++ b/tests/components/auth/test_indieauth.py @@ -166,7 +166,8 @@ async def test_find_link_tag_max_size(hass, mock_session): @pytest.mark.parametrize( - "client_id", ["https://home-assistant.io/android", "https://home-assistant.io/iOS"], + "client_id", + ["https://home-assistant.io/android", "https://home-assistant.io/iOS"], ) async def test_verify_redirect_uri_android_ios(client_id): """Test that we verify redirect uri correctly for Android/iOS.""" diff --git a/tests/components/automation/test_init.py b/tests/components/automation/test_init.py index 7179fbdaae2..d1c2e47a39e 100644 --- a/tests/components/automation/test_init.py +++ b/tests/components/automation/test_init.py @@ -584,7 +584,11 @@ async def test_automation_stops(hass, calls, service): ], } } - assert await async_setup_component(hass, automation.DOMAIN, config,) + assert await async_setup_component( + hass, + automation.DOMAIN, + config, + ) running = asyncio.Event() diff --git a/tests/components/avri/test_config_flow.py b/tests/components/avri/test_config_flow.py index c05935c62e4..2dba3c3c11d 100644 --- a/tests/components/avri/test_config_flow.py +++ b/tests/components/avri/test_config_flow.py @@ -15,7 +15,8 @@ async def test_form(hass): assert result["errors"] == {} with patch( - "homeassistant.components.avri.async_setup_entry", return_value=True, + "homeassistant.components.avri.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/tests/components/awair/test_config_flow.py b/tests/components/awair/test_config_flow.py index c36780a1803..63253993117 100644 --- a/tests/components/awair/test_config_flow.py +++ b/tests/components/awair/test_config_flow.py @@ -52,7 +52,8 @@ async def test_duplicate_error(hass): with patch( "python_awair.AwairClient.query", side_effect=[USER_FIXTURE, DEVICES_FIXTURE] ), patch( - "homeassistant.components.awair.sensor.async_setup_entry", return_value=True, + "homeassistant.components.awair.sensor.async_setup_entry", + return_value=True, ): MockConfigEntry(domain=DOMAIN, unique_id=UNIQUE_ID, data=CONFIG).add_to_hass( hass @@ -86,7 +87,8 @@ async def test_import(hass): with patch( "python_awair.AwairClient.query", side_effect=[USER_FIXTURE, DEVICES_FIXTURE] ), patch( - "homeassistant.components.awair.sensor.async_setup_entry", return_value=True, + "homeassistant.components.awair.sensor.async_setup_entry", + return_value=True, ): result = await hass.config_entries.flow.async_init( DOMAIN, @@ -120,7 +122,8 @@ async def test_import_aborts_if_configured(hass): with patch( "python_awair.AwairClient.query", side_effect=[USER_FIXTURE, DEVICES_FIXTURE] ), patch( - "homeassistant.components.awair.sensor.async_setup_entry", return_value=True, + "homeassistant.components.awair.sensor.async_setup_entry", + return_value=True, ): MockConfigEntry(domain=DOMAIN, unique_id=UNIQUE_ID, data=CONFIG).add_to_hass( hass @@ -141,7 +144,8 @@ async def test_reauth(hass): with patch( "python_awair.AwairClient.query", side_effect=[USER_FIXTURE, DEVICES_FIXTURE] ), patch( - "homeassistant.components.awair.sensor.async_setup_entry", return_value=True, + "homeassistant.components.awair.sensor.async_setup_entry", + return_value=True, ): mock_config = MockConfigEntry(domain=DOMAIN, unique_id=UNIQUE_ID, data=CONFIG) mock_config.add_to_hass(hass) @@ -150,7 +154,9 @@ async def test_reauth(hass): ) result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": "reauth", "unique_id": UNIQUE_ID}, data=CONFIG, + DOMAIN, + context={"source": "reauth", "unique_id": UNIQUE_ID}, + data=CONFIG, ) assert result["type"] == "abort" @@ -158,14 +164,18 @@ async def test_reauth(hass): with patch("python_awair.AwairClient.query", side_effect=AuthError()): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": "reauth", "unique_id": UNIQUE_ID}, data=CONFIG, + DOMAIN, + context={"source": "reauth", "unique_id": UNIQUE_ID}, + data=CONFIG, ) assert result["errors"] == {CONF_ACCESS_TOKEN: "auth"} with patch("python_awair.AwairClient.query", side_effect=AwairError()): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": "reauth", "unique_id": UNIQUE_ID}, data=CONFIG, + DOMAIN, + context={"source": "reauth", "unique_id": UNIQUE_ID}, + data=CONFIG, ) assert result["type"] == "abort" @@ -178,7 +188,8 @@ async def test_create_entry(hass): with patch( "python_awair.AwairClient.query", side_effect=[USER_FIXTURE, DEVICES_FIXTURE] ), patch( - "homeassistant.components.awair.sensor.async_setup_entry", return_value=True, + "homeassistant.components.awair.sensor.async_setup_entry", + return_value=True, ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=CONFIG diff --git a/tests/components/axis/test_config_flow.py b/tests/components/axis/test_config_flow.py index df0ee32389a..e5a32c4489a 100644 --- a/tests/components/axis/test_config_flow.py +++ b/tests/components/axis/test_config_flow.py @@ -68,7 +68,8 @@ async def test_manual_configuration_update_configuration(hass): assert result["step_id"] == "user" with patch( - "homeassistant.components.axis.async_setup_entry", return_value=True, + "homeassistant.components.axis.async_setup_entry", + return_value=True, ) as mock_setup_entry, patch( "axis.vapix.session_request", new=vapix_session_request ): @@ -170,11 +171,13 @@ async def test_flow_fails_device_unavailable(hass): async def test_flow_create_entry_multiple_existing_entries_of_same_model(hass): """Test that create entry can generate a name with other entries.""" entry = MockConfigEntry( - domain=AXIS_DOMAIN, data={CONF_NAME: "M1065-LW 0", CONF_MODEL: "M1065-LW"}, + domain=AXIS_DOMAIN, + data={CONF_NAME: "M1065-LW 0", CONF_MODEL: "M1065-LW"}, ) entry.add_to_hass(hass) entry2 = MockConfigEntry( - domain=AXIS_DOMAIN, data={CONF_NAME: "M1065-LW 1", CONF_MODEL: "M1065-LW"}, + domain=AXIS_DOMAIN, + data={CONF_NAME: "M1065-LW 1", CONF_MODEL: "M1065-LW"}, ) entry2.add_to_hass(hass) @@ -289,7 +292,8 @@ async def test_zeroconf_flow_updated_configuration(hass): } with patch( - "homeassistant.components.axis.async_setup_entry", return_value=True, + "homeassistant.components.axis.async_setup_entry", + return_value=True, ) as mock_setup_entry, patch( "axis.vapix.session_request", new=vapix_session_request ): @@ -359,7 +363,8 @@ async def test_option_flow(hass): } result = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={CONF_STREAM_PROFILE: "profile_1"}, + result["flow_id"], + user_input={CONF_STREAM_PROFILE: "profile_1"}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY diff --git a/tests/components/axis/test_device.py b/tests/components/axis/test_device.py index c8583a8ce03..c6d78ca66e9 100644 --- a/tests/components/axis/test_device.py +++ b/tests/components/axis/test_device.py @@ -213,7 +213,8 @@ async def setup_axis_integration(hass, config=ENTRY_CONFIG, options=ENTRY_OPTION config_entry.add_to_hass(hass) with patch("axis.vapix.session_request", new=vapix_session_request), patch( - "axis.rtsp.RTSPClient.start", return_value=True, + "axis.rtsp.RTSPClient.start", + return_value=True, ): await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() @@ -291,7 +292,8 @@ async def test_update_address(hass): assert device.api.config.host == "1.2.3.4" with patch("axis.vapix.session_request", new=vapix_session_request), patch( - "homeassistant.components.axis.async_setup_entry", return_value=True, + "homeassistant.components.axis.async_setup_entry", + return_value=True, ) as mock_setup_entry: await hass.config_entries.flow.async_init( AXIS_DOMAIN, diff --git a/tests/components/azure_devops/test_config_flow.py b/tests/components/azure_devops/test_config_flow.py index b89c9cb69aa..fce4c6f5df3 100644 --- a/tests/components/azure_devops/test_config_flow.py +++ b/tests/components/azure_devops/test_config_flow.py @@ -44,7 +44,8 @@ async def test_authorization_error(hass: HomeAssistant) -> None: assert result["step_id"] == "user" result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], FIXTURE_USER_INPUT, + result["flow_id"], + FIXTURE_USER_INPUT, ) await hass.async_block_till_done() @@ -67,7 +68,8 @@ async def test_reauth_authorization_error(hass: HomeAssistant) -> None: assert result["step_id"] == "reauth" result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], FIXTURE_REAUTH_INPUT, + result["flow_id"], + FIXTURE_REAUTH_INPUT, ) await hass.async_block_till_done() @@ -90,7 +92,8 @@ async def test_connection_error(hass: HomeAssistant) -> None: assert result["step_id"] == "user" result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], FIXTURE_USER_INPUT, + result["flow_id"], + FIXTURE_USER_INPUT, ) await hass.async_block_till_done() @@ -113,7 +116,8 @@ async def test_reauth_connection_error(hass: HomeAssistant) -> None: assert result["step_id"] == "reauth" result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], FIXTURE_REAUTH_INPUT, + result["flow_id"], + FIXTURE_REAUTH_INPUT, ) await hass.async_block_till_done() @@ -141,7 +145,8 @@ async def test_project_error(hass: HomeAssistant) -> None: assert result["step_id"] == "user" result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], FIXTURE_USER_INPUT, + result["flow_id"], + FIXTURE_USER_INPUT, ) await hass.async_block_till_done() @@ -169,7 +174,8 @@ async def test_reauth_project_error(hass: HomeAssistant) -> None: assert result["step_id"] == "reauth" result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], FIXTURE_REAUTH_INPUT, + result["flow_id"], + FIXTURE_REAUTH_INPUT, ) await hass.async_block_till_done() @@ -209,7 +215,8 @@ async def test_reauth_flow(hass: HomeAssistant) -> None: ), ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], FIXTURE_REAUTH_INPUT, + result["flow_id"], + FIXTURE_REAUTH_INPUT, ) await hass.async_block_till_done() @@ -222,7 +229,8 @@ async def test_full_flow_implementation(hass: HomeAssistant) -> None: with patch( "homeassistant.components.azure_devops.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.azure_devops.async_setup_entry", return_value=True, + "homeassistant.components.azure_devops.async_setup_entry", + return_value=True, ) as mock_setup_entry, patch( "homeassistant.components.azure_devops.config_flow.DevOpsClient.authorized", return_value=True, @@ -242,7 +250,8 @@ async def test_full_flow_implementation(hass: HomeAssistant) -> None: assert result["step_id"] == "user" result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], FIXTURE_USER_INPUT, + result["flow_id"], + FIXTURE_USER_INPUT, ) await hass.async_block_till_done() assert len(mock_setup.mock_calls) == 1 diff --git a/tests/components/binary_sensor/test_init.py b/tests/components/binary_sensor/test_init.py index a40df84b899..99af954cd4d 100644 --- a/tests/components/binary_sensor/test_init.py +++ b/tests/components/binary_sensor/test_init.py @@ -10,11 +10,13 @@ def test_state(): sensor = binary_sensor.BinarySensorEntity() assert STATE_OFF == sensor.state with mock.patch( - "homeassistant.components.binary_sensor.BinarySensorEntity.is_on", new=False, + "homeassistant.components.binary_sensor.BinarySensorEntity.is_on", + new=False, ): assert STATE_OFF == binary_sensor.BinarySensorEntity().state with mock.patch( - "homeassistant.components.binary_sensor.BinarySensorEntity.is_on", new=True, + "homeassistant.components.binary_sensor.BinarySensorEntity.is_on", + new=True, ): assert STATE_ON == binary_sensor.BinarySensorEntity().state diff --git a/tests/components/blebox/test_cover.py b/tests/components/blebox/test_cover.py index e7c20b10b2c..cd060445bf7 100644 --- a/tests/components/blebox/test_cover.py +++ b/tests/components/blebox/test_cover.py @@ -210,7 +210,10 @@ async def test_open(feature, hass, config): feature_mock.async_update = AsyncMock() await hass.services.async_call( - "cover", SERVICE_OPEN_COVER, {"entity_id": entity_id}, blocking=True, + "cover", + SERVICE_OPEN_COVER, + {"entity_id": entity_id}, + blocking=True, ) assert hass.states.get(entity_id).state == STATE_OPENING diff --git a/tests/components/blebox/test_light.py b/tests/components/blebox/test_light.py index fb0d1302e33..48af534545c 100644 --- a/tests/components/blebox/test_light.py +++ b/tests/components/blebox/test_light.py @@ -116,7 +116,10 @@ async def test_dimmer_on(dimmer, hass, config): feature_mock.async_on = AsyncMock(side_effect=turn_on) await hass.services.async_call( - "light", SERVICE_TURN_ON, {"entity_id": entity_id}, blocking=True, + "light", + SERVICE_TURN_ON, + {"entity_id": entity_id}, + blocking=True, ) state = hass.states.get(entity_id) @@ -186,7 +189,10 @@ async def test_dimmer_off(dimmer, hass, config): feature_mock.async_off = AsyncMock(side_effect=turn_off) await hass.services.async_call( - "light", SERVICE_TURN_OFF, {"entity_id": entity_id}, blocking=True, + "light", + SERVICE_TURN_OFF, + {"entity_id": entity_id}, + blocking=True, ) state = hass.states.get(entity_id) @@ -282,7 +288,10 @@ async def test_wlightbox_s_on(wlightbox_s, hass, config): feature_mock.async_on = AsyncMock(side_effect=turn_on) await hass.services.async_call( - "light", SERVICE_TURN_ON, {"entity_id": entity_id}, blocking=True, + "light", + SERVICE_TURN_ON, + {"entity_id": entity_id}, + blocking=True, ) state = hass.states.get(entity_id) @@ -523,7 +532,10 @@ async def test_wlightbox_on_to_last_color(wlightbox, hass, config): feature_mock.sensible_on_value = "f1e2d3e4" await hass.services.async_call( - "light", SERVICE_TURN_ON, {"entity_id": entity_id}, blocking=True, + "light", + SERVICE_TURN_ON, + {"entity_id": entity_id}, + blocking=True, ) state = hass.states.get(entity_id) @@ -555,7 +567,10 @@ async def test_wlightbox_off(wlightbox, hass, config): feature_mock.async_off = AsyncMock(side_effect=turn_off) await hass.services.async_call( - "light", SERVICE_TURN_OFF, {"entity_id": entity_id}, blocking=True, + "light", + SERVICE_TURN_OFF, + {"entity_id": entity_id}, + blocking=True, ) state = hass.states.get(entity_id) @@ -589,7 +604,10 @@ async def test_turn_on_failure(feature, hass, config, caplog): feature_mock.sensible_on_value = 123 await hass.services.async_call( - "light", SERVICE_TURN_ON, {"entity_id": entity_id}, blocking=True, + "light", + SERVICE_TURN_ON, + {"entity_id": entity_id}, + blocking=True, ) assert ( diff --git a/tests/components/blebox/test_switch.py b/tests/components/blebox/test_switch.py index c41273757f2..43d7d811acc 100644 --- a/tests/components/blebox/test_switch.py +++ b/tests/components/blebox/test_switch.py @@ -117,7 +117,10 @@ async def test_switchbox_on(switchbox, hass, config): feature_mock.async_turn_on = AsyncMock(side_effect=turn_on) await hass.services.async_call( - "switch", SERVICE_TURN_ON, {"entity_id": entity_id}, blocking=True, + "switch", + SERVICE_TURN_ON, + {"entity_id": entity_id}, + blocking=True, ) state = hass.states.get(entity_id) @@ -142,7 +145,10 @@ async def test_switchbox_off(switchbox, hass, config): feature_mock.async_turn_off = AsyncMock(side_effect=turn_off) await hass.services.async_call( - "switch", SERVICE_TURN_OFF, {"entity_id": entity_id}, blocking=True, + "switch", + SERVICE_TURN_OFF, + {"entity_id": entity_id}, + blocking=True, ) state = hass.states.get(entity_id) assert state.state == STATE_OFF @@ -279,7 +285,10 @@ async def test_switchbox_d_turn_first_on(switchbox_d, hass, config): feature_mocks[0].async_turn_on = AsyncMock(side_effect=turn_on0) await hass.services.async_call( - "switch", SERVICE_TURN_ON, {"entity_id": entity_ids[0]}, blocking=True, + "switch", + SERVICE_TURN_ON, + {"entity_id": entity_ids[0]}, + blocking=True, ) assert hass.states.get(entity_ids[0]).state == STATE_ON @@ -305,7 +314,10 @@ async def test_switchbox_d_second_on(switchbox_d, hass, config): feature_mocks[1].async_turn_on = AsyncMock(side_effect=turn_on1) await hass.services.async_call( - "switch", SERVICE_TURN_ON, {"entity_id": entity_ids[1]}, blocking=True, + "switch", + SERVICE_TURN_ON, + {"entity_id": entity_ids[1]}, + blocking=True, ) assert hass.states.get(entity_ids[0]).state == STATE_OFF @@ -331,7 +343,10 @@ async def test_switchbox_d_first_off(switchbox_d, hass, config): feature_mocks[0].async_turn_off = AsyncMock(side_effect=turn_off0) await hass.services.async_call( - "switch", SERVICE_TURN_OFF, {"entity_id": entity_ids[0]}, blocking=True, + "switch", + SERVICE_TURN_OFF, + {"entity_id": entity_ids[0]}, + blocking=True, ) assert hass.states.get(entity_ids[0]).state == STATE_OFF @@ -357,7 +372,10 @@ async def test_switchbox_d_second_off(switchbox_d, hass, config): feature_mocks[1].async_turn_off = AsyncMock(side_effect=turn_off1) await hass.services.async_call( - "switch", SERVICE_TURN_OFF, {"entity_id": entity_ids[1]}, blocking=True, + "switch", + SERVICE_TURN_OFF, + {"entity_id": entity_ids[1]}, + blocking=True, ) assert hass.states.get(entity_ids[0]).state == STATE_ON assert hass.states.get(entity_ids[1]).state == STATE_OFF diff --git a/tests/components/blink/test_config_flow.py b/tests/components/blink/test_config_flow.py index 99b20d9a73c..72a4a5272ed 100644 --- a/tests/components/blink/test_config_flow.py +++ b/tests/components/blink/test_config_flow.py @@ -24,10 +24,12 @@ async def test_form(hass): ), patch( "homeassistant.components.blink.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.blink.async_setup_entry", return_value=True, + "homeassistant.components.blink.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"username": "blink@example.com", "password": "example"}, + result["flow_id"], + {"username": "blink@example.com", "password": "example"}, ) assert result2["type"] == "create_entry" @@ -62,7 +64,8 @@ async def test_form_2fa(hass): "homeassistant.components.blink.async_setup", return_value=True ) as mock_setup: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"username": "blink@example.com", "password": "example"}, + result["flow_id"], + {"username": "blink@example.com", "password": "example"}, ) assert result2["type"] == "form" @@ -106,7 +109,8 @@ async def test_form_2fa_connect_error(hass): return_value=True, ), patch("homeassistant.components.blink.async_setup", return_value=True): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"username": "blink@example.com", "password": "example"}, + result["flow_id"], + {"username": "blink@example.com", "password": "example"}, ) assert result2["type"] == "form" @@ -146,7 +150,8 @@ async def test_form_2fa_invalid_key(hass): return_value=True, ), patch("homeassistant.components.blink.async_setup", return_value=True): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"username": "blink@example.com", "password": "example"}, + result["flow_id"], + {"username": "blink@example.com", "password": "example"}, ) assert result2["type"] == "form" @@ -186,7 +191,8 @@ async def test_form_2fa_unknown_error(hass): return_value=True, ), patch("homeassistant.components.blink.async_setup", return_value=True): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"username": "blink@example.com", "password": "example"}, + result["flow_id"], + {"username": "blink@example.com", "password": "example"}, ) assert result2["type"] == "form" @@ -239,7 +245,8 @@ async def test_form_unknown_error(hass): ) with patch( - "homeassistant.components.blink.config_flow.Auth.startup", side_effect=KeyError, + "homeassistant.components.blink.config_flow.Auth.startup", + side_effect=KeyError, ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], {"username": "blink@example.com", "password": "example"} @@ -288,7 +295,8 @@ async def test_options_flow(hass): assert result["step_id"] == "simple_options" result = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={"scan_interval": 5}, + result["flow_id"], + user_input={"scan_interval": 5}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY diff --git a/tests/components/bond/common.py b/tests/components/bond/common.py index 31308746555..d5e4a0b9418 100644 --- a/tests/components/bond/common.py +++ b/tests/components/bond/common.py @@ -113,7 +113,8 @@ def patch_bond_device_ids(enabled: bool = True, return_value=None, side_effect=N def patch_bond_device(return_value=None): """Patch Bond API device endpoint.""" return patch( - "homeassistant.components.bond.Bond.device", return_value=return_value, + "homeassistant.components.bond.Bond.device", + return_value=return_value, ) diff --git a/tests/components/bond/test_config_flow.py b/tests/components/bond/test_config_flow.py index 8671cc4b601..cd98dd8090a 100644 --- a/tests/components/bond/test_config_flow.py +++ b/tests/components/bond/test_config_flow.py @@ -162,7 +162,8 @@ async def test_zeroconf_form(hass: core.HomeAssistant): return_value={"bondid": "test-bond-id"} ), patch_bond_device_ids(), _patch_async_setup() as mock_setup, _patch_async_setup_entry() as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_ACCESS_TOKEN: "test-token"}, + result["flow_id"], + {CONF_ACCESS_TOKEN: "test-token"}, ) assert result2["type"] == "create_entry" @@ -249,4 +250,7 @@ def _patch_async_setup(): def _patch_async_setup_entry(): - return patch("homeassistant.components.bond.async_setup_entry", return_value=True,) + return patch( + "homeassistant.components.bond.async_setup_entry", + return_value=True, + ) diff --git a/tests/components/bond/test_fan.py b/tests/components/bond/test_fan.py index fa7e59e30e6..72770817110 100644 --- a/tests/components/bond/test_fan.py +++ b/tests/components/bond/test_fan.py @@ -45,7 +45,10 @@ async def turn_fan_on( if speed: service_data[fan.ATTR_SPEED] = speed await hass.services.async_call( - FAN_DOMAIN, SERVICE_TURN_ON, service_data=service_data, blocking=True, + FAN_DOMAIN, + SERVICE_TURN_ON, + service_data=service_data, + blocking=True, ) await hass.async_block_till_done() @@ -149,7 +152,10 @@ async def test_turn_off_fan(hass: core.HomeAssistant): with patch_bond_action() as mock_turn_off, patch_bond_device_state(): await hass.services.async_call( - FAN_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: "fan.name_1"}, blocking=True, + FAN_DOMAIN, + SERVICE_TURN_OFF, + {ATTR_ENTITY_ID: "fan.name_1"}, + blocking=True, ) await hass.async_block_till_done() diff --git a/tests/components/bond/test_init.py b/tests/components/bond/test_init.py index 7a0f057f17b..3dd54f0de6f 100644 --- a/tests/components/bond/test_init.py +++ b/tests/components/bond/test_init.py @@ -27,7 +27,8 @@ async def test_async_setup_no_domain_config(hass: HomeAssistant): async def test_async_setup_raises_entry_not_ready(hass: HomeAssistant): """Test that it throws ConfigEntryNotReady when exception occurs during setup.""" config_entry = MockConfigEntry( - domain=DOMAIN, data={CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"}, + domain=DOMAIN, + data={CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"}, ) config_entry.add_to_hass(hass) @@ -39,7 +40,8 @@ async def test_async_setup_raises_entry_not_ready(hass: HomeAssistant): async def test_async_setup_entry_sets_up_hub_and_supported_domains(hass: HomeAssistant): """Test that configuring entry sets up cover domain.""" config_entry = MockConfigEntry( - domain=DOMAIN, data={CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"}, + domain=DOMAIN, + data={CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"}, ) with patch_bond_version( @@ -86,7 +88,8 @@ async def test_async_setup_entry_sets_up_hub_and_supported_domains(hass: HomeAss async def test_unload_config_entry(hass: HomeAssistant): """Test that configuration entry supports unloading.""" config_entry = MockConfigEntry( - domain=DOMAIN, data={CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"}, + domain=DOMAIN, + data={CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"}, ) result = await setup_bond_entity( diff --git a/tests/components/bond/test_light.py b/tests/components/bond/test_light.py index 57ea859240a..17b8c87978f 100644 --- a/tests/components/bond/test_light.py +++ b/tests/components/bond/test_light.py @@ -165,7 +165,10 @@ async def test_brightness_support(hass: core.HomeAssistant): async def test_brightness_not_supported(hass: core.HomeAssistant): """Tests that a non-dimmable light should not support the brightness feature.""" await setup_platform( - hass, LIGHT_DOMAIN, ceiling_fan("name-1"), bond_device_id="test-device-id", + hass, + LIGHT_DOMAIN, + ceiling_fan("name-1"), + bond_device_id="test-device-id", ) state = hass.states.get("light.name_1") diff --git a/tests/components/broadlink/test_config_flow.py b/tests/components/broadlink/test_config_flow.py index 43237cd70ba..4089c551ff5 100644 --- a/tests/components/broadlink/test_config_flow.py +++ b/tests/components/broadlink/test_config_flow.py @@ -40,7 +40,8 @@ async def test_flow_user_works(hass): with patch("broadlink.discover", return_value=[mock_api]) as mock_discover: result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host, "timeout": device.timeout}, + result["flow_id"], + {"host": device.host, "timeout": device.timeout}, ) assert result["type"] == "form" @@ -48,7 +49,8 @@ async def test_flow_user_works(hass): assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"name": device.name}, + result["flow_id"], + {"name": device.name}, ) assert result["type"] == "create_entry" @@ -69,7 +71,8 @@ async def test_flow_user_already_in_progress(hass): with patch("broadlink.discover", return_value=[device.get_mock_api()]): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host, "timeout": device.timeout}, + result["flow_id"], + {"host": device.host, "timeout": device.timeout}, ) result = await hass.config_entries.flow.async_init( @@ -78,7 +81,8 @@ async def test_flow_user_already_in_progress(hass): with patch("broadlink.discover", return_value=[device.get_mock_api()]): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host, "timeout": device.timeout}, + result["flow_id"], + {"host": device.host, "timeout": device.timeout}, ) assert result["type"] == "abort" @@ -104,7 +108,8 @@ async def test_flow_user_mac_already_configured(hass): with patch("broadlink.discover", return_value=[mock_api]): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host, "timeout": device.timeout}, + result["flow_id"], + {"host": device.host, "timeout": device.timeout}, ) assert result["type"] == "abort" @@ -122,7 +127,8 @@ async def test_flow_user_invalid_ip_address(hass): with patch("broadlink.discover", side_effect=OSError(errno.EINVAL, None)): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": "0.0.0.1"}, + result["flow_id"], + {"host": "0.0.0.1"}, ) assert result["type"] == "form" @@ -138,7 +144,8 @@ async def test_flow_user_invalid_hostname(hass): with patch("broadlink.discover", side_effect=OSError(socket.EAI_NONAME, None)): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": "pancakemaster.local"}, + result["flow_id"], + {"host": "pancakemaster.local"}, ) assert result["type"] == "form" @@ -156,7 +163,8 @@ async def test_flow_user_device_not_found(hass): with patch("broadlink.discover", return_value=[]): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host}, + result["flow_id"], + {"host": device.host}, ) assert result["type"] == "form" @@ -172,7 +180,8 @@ async def test_flow_user_network_unreachable(hass): with patch("broadlink.discover", side_effect=OSError(errno.ENETUNREACH, None)): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": "192.168.1.32"}, + result["flow_id"], + {"host": "192.168.1.32"}, ) assert result["type"] == "form" @@ -188,7 +197,8 @@ async def test_flow_user_os_error(hass): with patch("broadlink.discover", side_effect=OSError()): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": "192.168.1.32"}, + result["flow_id"], + {"host": "192.168.1.32"}, ) assert result["type"] == "form" @@ -208,7 +218,8 @@ async def test_flow_auth_authentication_error(hass): with patch("broadlink.discover", return_value=[mock_api]): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host, "timeout": device.timeout}, + result["flow_id"], + {"host": device.host, "timeout": device.timeout}, ) assert result["type"] == "form" @@ -228,7 +239,8 @@ async def test_flow_auth_device_offline(hass): with patch("broadlink.discover", return_value=[mock_api]): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host}, + result["flow_id"], + {"host": device.host}, ) assert result["type"] == "form" @@ -248,7 +260,8 @@ async def test_flow_auth_firmware_error(hass): with patch("broadlink.discover", return_value=[mock_api]): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host}, + result["flow_id"], + {"host": device.host}, ) assert result["type"] == "form" @@ -268,7 +281,8 @@ async def test_flow_auth_network_unreachable(hass): with patch("broadlink.discover", return_value=[mock_api]): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host}, + result["flow_id"], + {"host": device.host}, ) assert result["type"] == "form" @@ -288,7 +302,8 @@ async def test_flow_auth_os_error(hass): with patch("broadlink.discover", return_value=[mock_api]): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host}, + result["flow_id"], + {"host": device.host}, ) assert result["type"] == "form" @@ -308,16 +323,19 @@ async def test_flow_reset_works(hass): with patch("broadlink.discover", return_value=[mock_api]): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host, "timeout": device.timeout}, + result["flow_id"], + {"host": device.host, "timeout": device.timeout}, ) with patch("broadlink.discover", return_value=[device.get_mock_api()]): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host, "timeout": device.timeout}, + result["flow_id"], + {"host": device.host, "timeout": device.timeout}, ) result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"name": device.name}, + result["flow_id"], + {"name": device.name}, ) assert result["type"] == "create_entry" @@ -337,7 +355,8 @@ async def test_flow_unlock_works(hass): with patch("broadlink.discover", return_value=[mock_api]): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host, "timeout": device.timeout}, + result["flow_id"], + {"host": device.host, "timeout": device.timeout}, ) assert result["type"] == "form" @@ -345,11 +364,13 @@ async def test_flow_unlock_works(hass): assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"unlock": True}, + result["flow_id"], + {"unlock": True}, ) result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"name": device.name}, + result["flow_id"], + {"name": device.name}, ) assert result["type"] == "create_entry" @@ -373,11 +394,13 @@ async def test_flow_unlock_device_offline(hass): with patch("broadlink.discover", return_value=[mock_api]): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host, "timeout": device.timeout}, + result["flow_id"], + {"host": device.host, "timeout": device.timeout}, ) result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"unlock": True}, + result["flow_id"], + {"unlock": True}, ) assert result["type"] == "form" @@ -398,11 +421,13 @@ async def test_flow_unlock_firmware_error(hass): with patch("broadlink.discover", return_value=[mock_api]): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host, "timeout": device.timeout}, + result["flow_id"], + {"host": device.host, "timeout": device.timeout}, ) result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"unlock": True}, + result["flow_id"], + {"unlock": True}, ) assert result["type"] == "form" @@ -423,11 +448,13 @@ async def test_flow_unlock_network_unreachable(hass): with patch("broadlink.discover", return_value=[mock_api]): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host, "timeout": device.timeout}, + result["flow_id"], + {"host": device.host, "timeout": device.timeout}, ) result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"unlock": True}, + result["flow_id"], + {"unlock": True}, ) assert result["type"] == "form" @@ -448,11 +475,13 @@ async def test_flow_unlock_os_error(hass): with patch("broadlink.discover", return_value=[mock_api]): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host, "timeout": device.timeout}, + result["flow_id"], + {"host": device.host, "timeout": device.timeout}, ) result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"unlock": True}, + result["flow_id"], + {"unlock": True}, ) assert result["type"] == "form" @@ -472,15 +501,18 @@ async def test_flow_do_not_unlock(hass): with patch("broadlink.discover", return_value=[mock_api]): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host, "timeout": device.timeout}, + result["flow_id"], + {"host": device.host, "timeout": device.timeout}, ) result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"unlock": False}, + result["flow_id"], + {"unlock": False}, ) result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"name": device.name}, + result["flow_id"], + {"name": device.name}, ) assert result["type"] == "create_entry" @@ -507,7 +539,8 @@ async def test_flow_import_works(hass): assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"name": device.name}, + result["flow_id"], + {"name": device.name}, ) assert result["type"] == "create_entry" @@ -671,7 +704,8 @@ async def test_flow_reauth_works(hass): with patch("broadlink.discover", return_value=[mock_api]) as mock_discover: result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host, "timeout": device.timeout}, + result["flow_id"], + {"host": device.host, "timeout": device.timeout}, ) assert result["type"] == "abort" @@ -704,7 +738,8 @@ async def test_flow_reauth_invalid_host(hass): with patch("broadlink.discover", return_value=[mock_api]) as mock_discover: result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host, "timeout": device.timeout}, + result["flow_id"], + {"host": device.host, "timeout": device.timeout}, ) assert result["type"] == "form" @@ -737,7 +772,8 @@ async def test_flow_reauth_valid_host(hass): with patch("broadlink.discover", return_value=[mock_api]) as mock_discover: result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": device.host, "timeout": device.timeout}, + result["flow_id"], + {"host": device.host, "timeout": device.timeout}, ) assert result["type"] == "abort" diff --git a/tests/components/bsblan/__init__.py b/tests/components/bsblan/__init__.py index 1541555de55..45b0f16c0a1 100644 --- a/tests/components/bsblan/__init__.py +++ b/tests/components/bsblan/__init__.py @@ -13,7 +13,9 @@ from tests.test_util.aiohttp import AiohttpClientMocker async def init_integration( - hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, skip_setup: bool = False, + hass: HomeAssistant, + aioclient_mock: AiohttpClientMocker, + skip_setup: bool = False, ) -> MockConfigEntry: """Set up the BSBLan integration in Home Assistant.""" diff --git a/tests/components/bsblan/test_config_flow.py b/tests/components/bsblan/test_config_flow.py index 48f71a8404f..c24fbc34f6a 100644 --- a/tests/components/bsblan/test_config_flow.py +++ b/tests/components/bsblan/test_config_flow.py @@ -17,7 +17,8 @@ from tests.test_util.aiohttp import AiohttpClientMocker async def test_show_user_form(hass: HomeAssistant) -> None: """Test that the user set up form is served.""" result = await hass.config_entries.flow.async_init( - config_flow.DOMAIN, context={"source": SOURCE_USER}, + config_flow.DOMAIN, + context={"source": SOURCE_USER}, ) assert result["step_id"] == "user" @@ -70,7 +71,8 @@ async def test_full_user_flow_implementation( ) result = await hass.config_entries.flow.async_init( - config_flow.DOMAIN, context={"source": SOURCE_USER}, + config_flow.DOMAIN, + context={"source": SOURCE_USER}, ) assert result["step_id"] == "user" diff --git a/tests/components/camera/test_init.py b/tests/components/camera/test_init.py index 8a79cb39ec9..c3db5067b1f 100644 --- a/tests/components/camera/test_init.py +++ b/tests/components/camera/test_init.py @@ -27,7 +27,8 @@ async def mock_camera_fixture(hass): await hass.async_block_till_done() with patch( - "homeassistant.components.demo.camera.Path.read_bytes", return_value=b"Test", + "homeassistant.components.demo.camera.Path.read_bytes", + return_value=b"Test", ): yield @@ -258,7 +259,8 @@ async def test_play_stream_service_no_source(hass, mock_camera, mock_stream): async def test_handle_play_stream_service(hass, mock_camera, mock_stream): """Test camera play_stream service.""" await async_process_ha_core_config( - hass, {"external_url": "https://example.com"}, + hass, + {"external_url": "https://example.com"}, ) await async_setup_component(hass, "media_player", {}) with patch( diff --git a/tests/components/cast/test_home_assistant_cast.py b/tests/components/cast/test_home_assistant_cast.py index 8a3a935429f..2842ddc23f0 100644 --- a/tests/components/cast/test_home_assistant_cast.py +++ b/tests/components/cast/test_home_assistant_cast.py @@ -9,7 +9,8 @@ from tests.common import MockConfigEntry, async_mock_signal async def test_service_show_view(hass): """Test we don't set app id in prod.""" await async_process_ha_core_config( - hass, {"external_url": "https://example.com"}, + hass, + {"external_url": "https://example.com"}, ) await home_assistant_cast.async_setup_ha_cast(hass, MockConfigEntry()) calls = async_mock_signal(hass, home_assistant_cast.SIGNAL_HASS_CAST_SHOW_VIEW) @@ -35,7 +36,8 @@ async def test_service_show_view(hass): async def test_service_show_view_dashboard(hass): """Test casting a specific dashboard.""" await async_process_ha_core_config( - hass, {"external_url": "https://example.com"}, + hass, + {"external_url": "https://example.com"}, ) await home_assistant_cast.async_setup_ha_cast(hass, MockConfigEntry()) calls = async_mock_signal(hass, home_assistant_cast.SIGNAL_HASS_CAST_SHOW_VIEW) @@ -61,7 +63,8 @@ async def test_service_show_view_dashboard(hass): async def test_use_cloud_url(hass): """Test that we fall back to cloud url.""" await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) hass.config.components.add("cloud") diff --git a/tests/components/cast/test_media_player.py b/tests/components/cast/test_media_player.py index 5d8a54dc691..d3348241ec8 100644 --- a/tests/components/cast/test_media_player.py +++ b/tests/components/cast/test_media_player.py @@ -629,7 +629,8 @@ async def test_failed_cast_other_url(hass, caplog): async def test_failed_cast_internal_url(hass, caplog): """Test warning when casting from internal_url fails.""" await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) with assert_setup_component(1, tts.DOMAIN): assert await async_setup_component( @@ -653,7 +654,8 @@ async def test_failed_cast_internal_url(hass, caplog): async def test_failed_cast_external_url(hass, caplog): """Test warning when casting from external_url fails.""" await async_process_ha_core_config( - hass, {"external_url": "http://example.com:8123"}, + hass, + {"external_url": "http://example.com:8123"}, ) with assert_setup_component(1, tts.DOMAIN): assert await async_setup_component( diff --git a/tests/components/cloud/test_http_api.py b/tests/components/cloud/test_http_api.py index 13c4649f39e..aa59e935a86 100644 --- a/tests/components/cloud/test_http_api.py +++ b/tests/components/cloud/test_http_api.py @@ -462,7 +462,8 @@ async def test_websocket_subscription_not_logged_in(hass, hass_ws_client): """Test querying the status.""" client = await hass_ws_client(hass) with patch( - "hass_nabucasa.Cloud.fetch_subscription_info", return_value={"return": "value"}, + "hass_nabucasa.Cloud.fetch_subscription_info", + return_value={"return": "value"}, ): await client.send_json({"id": 5, "type": "cloud/subscription"}) response = await client.receive_json() diff --git a/tests/components/command_line/test_cover.py b/tests/components/command_line/test_cover.py index 4707296a426..ceb3711f62b 100644 --- a/tests/components/command_line/test_cover.py +++ b/tests/components/command_line/test_cover.py @@ -111,11 +111,16 @@ async def test_reload(hass): assert hass.states.get("cover.test").state yaml_path = path.join( - _get_fixtures_base_path(), "fixtures", "command_line/configuration.yaml", + _get_fixtures_base_path(), + "fixtures", + "command_line/configuration.yaml", ) with patch.object(hass_config, "YAML_CONFIG_FILE", yaml_path): await hass.services.async_call( - "command_line", SERVICE_RELOAD, {}, blocking=True, + "command_line", + SERVICE_RELOAD, + {}, + blocking=True, ) await hass.async_block_till_done() diff --git a/tests/components/command_line/test_sensor.py b/tests/components/command_line/test_sensor.py index 623269b9c16..0a6e29ca00c 100644 --- a/tests/components/command_line/test_sensor.py +++ b/tests/components/command_line/test_sensor.py @@ -78,7 +78,9 @@ class TestCommandSensorSensor(unittest.TestCase): return_value=b"Works\n", ) as check_output: data = command_line.CommandSensorData( - self.hass, 'echo "{{ states.sensor.test_state.state }}" "3 4"', 15, + self.hass, + 'echo "{{ states.sensor.test_state.state }}" "3 4"', + 15, ) data.update() diff --git a/tests/components/config/test_config_entries.py b/tests/components/config/test_config_entries.py index 9bd8875add0..11299f4108b 100644 --- a/tests/components/config/test_config_entries.py +++ b/tests/components/config/test_config_entries.py @@ -406,7 +406,8 @@ async def test_continue_flow_unauth(hass, client, hass_admin_user): hass_admin_user.groups = [] resp = await client.post( - f"/api/config/config_entries/flow/{flow_id}", json={"user_title": "user-title"}, + f"/api/config/config_entries/flow/{flow_id}", + json={"user_title": "user-title"}, ) assert resp.status == 401 diff --git a/tests/components/config/test_core.py b/tests/components/config/test_core.py index 6a7447d9409..1f379727b44 100644 --- a/tests/components/config/test_core.py +++ b/tests/components/config/test_core.py @@ -125,7 +125,8 @@ async def test_websocket_bad_core_update(hass, client): async def test_detect_config(hass, client): """Test detect config.""" with patch( - "homeassistant.util.location.async_detect_location_info", return_value=None, + "homeassistant.util.location.async_detect_location_info", + return_value=None, ): await client.send_json({"id": 1, "type": "config/core/detect"}) diff --git a/tests/components/config/test_customize.py b/tests/components/config/test_customize.py index 30a475dab77..ca3bcc98c7d 100644 --- a/tests/components/config/test_customize.py +++ b/tests/components/config/test_customize.py @@ -55,7 +55,8 @@ async def test_update_entity(hass, hass_client): with patch("homeassistant.components.config._read", mock_read), patch( "homeassistant.components.config._write", mock_write ), patch( - "homeassistant.config.async_hass_config_yaml", return_value={}, + "homeassistant.config.async_hass_config_yaml", + return_value={}, ): resp = await client.post( "/api/config/customize/config/hello.world", diff --git a/tests/components/conftest.py b/tests/components/conftest.py index e78a67a16f3..acfbdeb8629 100644 --- a/tests/components/conftest.py +++ b/tests/components/conftest.py @@ -15,6 +15,7 @@ zeroconf.install_multiple_zeroconf_catcher = lambda zc: None def prevent_io(): """Fixture to prevent certain I/O from happening.""" with patch( - "homeassistant.components.http.ban.async_load_ip_bans_config", return_value=[], + "homeassistant.components.http.ban.async_load_ip_bans_config", + return_value=[], ): yield diff --git a/tests/components/control4/test_config_flow.py b/tests/components/control4/test_config_flow.py index 6d3293b147a..f87c5af3484 100644 --- a/tests/components/control4/test_config_flow.py +++ b/tests/components/control4/test_config_flow.py @@ -64,7 +64,8 @@ async def test_form(hass): ), patch( "homeassistant.components.control4.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.control4.async_setup_entry", return_value=True, + "homeassistant.components.control4.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -171,7 +172,8 @@ async def test_option_flow(hass): assert result["step_id"] == "init" result = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={CONF_SCAN_INTERVAL: 4}, + result["flow_id"], + user_input={CONF_SCAN_INTERVAL: 4}, ) assert result["type"] == "create_entry" assert result["data"] == { diff --git a/tests/components/coolmaster/test_config_flow.py b/tests/components/coolmaster/test_config_flow.py index 88985f7f88a..fc296a53ddf 100644 --- a/tests/components/coolmaster/test_config_flow.py +++ b/tests/components/coolmaster/test_config_flow.py @@ -26,7 +26,8 @@ async def test_form(hass): ), patch( "homeassistant.components.coolmaster.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.coolmaster.async_setup_entry", return_value=True, + "homeassistant.components.coolmaster.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], _flow_data() diff --git a/tests/components/coronavirus/test_config_flow.py b/tests/components/coronavirus/test_config_flow.py index b7af2e343b2..06d586ba2a5 100644 --- a/tests/components/coronavirus/test_config_flow.py +++ b/tests/components/coronavirus/test_config_flow.py @@ -13,7 +13,8 @@ async def test_form(hass): assert result["errors"] == {} result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"country": OPTION_WORLDWIDE}, + result["flow_id"], + {"country": OPTION_WORLDWIDE}, ) assert result2["type"] == "create_entry" assert result2["title"] == "Worldwide" diff --git a/tests/components/daikin/test_config_flow.py b/tests/components/daikin/test_config_flow.py index c315bcc32a8..324c73dfb81 100644 --- a/tests/components/daikin/test_config_flow.py +++ b/tests/components/daikin/test_config_flow.py @@ -54,14 +54,17 @@ def mock_daikin_discovery(): async def test_user(hass, mock_daikin): """Test user config.""" result = await hass.config_entries.flow.async_init( - "daikin", context={"source": SOURCE_USER}, + "daikin", + context={"source": SOURCE_USER}, ) assert result["type"] == RESULT_TYPE_FORM assert result["step_id"] == "user" result = await hass.config_entries.flow.async_init( - "daikin", context={"source": SOURCE_USER}, data={CONF_HOST: HOST}, + "daikin", + context={"source": SOURCE_USER}, + data={CONF_HOST: HOST}, ) assert result["type"] == RESULT_TYPE_CREATE_ENTRY assert result["title"] == HOST @@ -73,7 +76,9 @@ async def test_abort_if_already_setup(hass, mock_daikin): """Test we abort if Daikin is already setup.""" MockConfigEntry(domain="daikin", unique_id=MAC).add_to_hass(hass) result = await hass.config_entries.flow.async_init( - "daikin", context={"source": SOURCE_USER}, data={CONF_HOST: HOST, KEY_MAC: MAC}, + "daikin", + context={"source": SOURCE_USER}, + data={CONF_HOST: HOST, KEY_MAC: MAC}, ) assert result["type"] == RESULT_TYPE_ABORT @@ -83,13 +88,17 @@ async def test_abort_if_already_setup(hass, mock_daikin): async def test_import(hass, mock_daikin): """Test import step.""" result = await hass.config_entries.flow.async_init( - "daikin", context={"source": SOURCE_IMPORT}, data={}, + "daikin", + context={"source": SOURCE_IMPORT}, + data={}, ) assert result["type"] == RESULT_TYPE_FORM assert result["step_id"] == "user" result = await hass.config_entries.flow.async_init( - "daikin", context={"source": SOURCE_IMPORT}, data={CONF_HOST: HOST}, + "daikin", + context={"source": SOURCE_IMPORT}, + data={CONF_HOST: HOST}, ) assert result["type"] == RESULT_TYPE_CREATE_ENTRY assert result["title"] == HOST @@ -111,7 +120,9 @@ async def test_device_abort(hass, mock_daikin, s_effect, reason): mock_daikin.factory.side_effect = s_effect result = await hass.config_entries.flow.async_init( - "daikin", context={"source": SOURCE_USER}, data={CONF_HOST: HOST, KEY_MAC: MAC}, + "daikin", + context={"source": SOURCE_USER}, + data={CONF_HOST: HOST, KEY_MAC: MAC}, ) assert result["type"] == RESULT_TYPE_FORM assert result["errors"] == {"base": reason} @@ -130,7 +141,9 @@ async def test_discovery_zeroconf( ): """Test discovery/zeroconf step.""" result = await hass.config_entries.flow.async_init( - "daikin", context={"source": source}, data=data, + "daikin", + context={"source": source}, + data=data, ) assert result["type"] == RESULT_TYPE_FORM assert result["step_id"] == "user" @@ -146,7 +159,9 @@ async def test_discovery_zeroconf( assert result["reason"] == "already_configured" result = await hass.config_entries.flow.async_init( - "daikin", context={"source": source}, data=data, + "daikin", + context={"source": source}, + data=data, ) assert result["type"] == RESULT_TYPE_ABORT diff --git a/tests/components/datadog/test_init.py b/tests/components/datadog/test_init.py index da4076944d0..06788728115 100644 --- a/tests/components/datadog/test_init.py +++ b/tests/components/datadog/test_init.py @@ -161,7 +161,10 @@ class TestDatadog(unittest.TestCase): ) assert mock_client.gauge.call_args == mock.call( - "ha.sensor", out, sample_rate=1, tags=[f"entity:{state.entity_id}"], + "ha.sensor", + out, + sample_rate=1, + tags=[f"entity:{state.entity_id}"], ) mock_client.gauge.reset_mock() diff --git a/tests/components/debugpy/test_init.py b/tests/components/debugpy/test_init.py index 1de8da9ac9a..86be0d788f6 100644 --- a/tests/components/debugpy/test_init.py +++ b/tests/components/debugpy/test_init.py @@ -53,7 +53,9 @@ async def test_on_demand(hass: HomeAssistant, mock_debugpy) -> None: assert len(mock_debugpy.method_calls) == 0 await hass.services.async_call( - DOMAIN, SERVICE_START, blocking=True, + DOMAIN, + SERVICE_START, + blocking=True, ) mock_debugpy.listen.assert_called_once_with(("127.0.0.1", 80)) diff --git a/tests/components/deconz/test_config_flow.py b/tests/components/deconz/test_config_flow.py index 0a536bcda5b..b51869b01ab 100644 --- a/tests/components/deconz/test_config_flow.py +++ b/tests/components/deconz/test_config_flow.py @@ -87,7 +87,8 @@ async def test_flow_manual_configuration_decision(hass, aioclient_mock): assert result["step_id"] == "manual_input" result = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80}, + result["flow_id"], + user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -134,7 +135,8 @@ async def test_flow_manual_configuration(hass, aioclient_mock): assert result["step_id"] == "manual_input" result = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80}, + result["flow_id"], + user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -209,7 +211,8 @@ async def test_manual_configuration_update_configuration(hass, aioclient_mock): assert result["step_id"] == "manual_input" result = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input={CONF_HOST: "2.3.4.5", CONF_PORT: 80}, + result["flow_id"], + user_input={CONF_HOST: "2.3.4.5", CONF_PORT: 80}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -254,7 +257,8 @@ async def test_manual_configuration_dont_update_configuration(hass, aioclient_mo assert result["step_id"] == "manual_input" result = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80}, + result["flow_id"], + user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -296,7 +300,8 @@ async def test_manual_configuration_timeout_get_bridge(hass, aioclient_mock): assert result["step_id"] == "manual_input" result = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80}, + result["flow_id"], + user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -401,7 +406,8 @@ async def test_ssdp_discovery_update_configuration(hass): gateway = await setup_deconz_integration(hass) with patch( - "homeassistant.components.deconz.async_setup_entry", return_value=True, + "homeassistant.components.deconz.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, @@ -478,7 +484,8 @@ async def test_flow_hassio_discovery(hass): with patch( "homeassistant.components.deconz.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.deconz.async_setup_entry", return_value=True, + "homeassistant.components.deconz.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={} @@ -500,7 +507,8 @@ async def test_hassio_discovery_update_configuration(hass): gateway = await setup_deconz_integration(hass) with patch( - "homeassistant.components.deconz.async_setup_entry", return_value=True, + "homeassistant.components.deconz.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, diff --git a/tests/components/deconz/test_gateway.py b/tests/components/deconz/test_gateway.py index 4236888a5a6..15ff304459b 100644 --- a/tests/components/deconz/test_gateway.py +++ b/tests/components/deconz/test_gateway.py @@ -136,7 +136,8 @@ async def test_update_address(hass): assert gateway.api.host == "1.2.3.4" with patch( - "homeassistant.components.deconz.async_setup_entry", return_value=True, + "homeassistant.components.deconz.async_setup_entry", + return_value=True, ) as mock_setup_entry: await hass.config_entries.flow.async_init( deconz.config_flow.DOMAIN, @@ -173,7 +174,8 @@ async def test_get_gateway(hass): async def test_get_gateway_fails_unauthorized(hass): """Failed call.""" with patch( - "pydeconz.DeconzSession.initialize", side_effect=pydeconz.errors.Unauthorized, + "pydeconz.DeconzSession.initialize", + side_effect=pydeconz.errors.Unauthorized, ), pytest.raises(deconz.errors.AuthenticationRequired): assert ( await deconz.gateway.get_gateway(hass, ENTRY_CONFIG, Mock(), Mock()) @@ -184,7 +186,8 @@ async def test_get_gateway_fails_unauthorized(hass): async def test_get_gateway_fails_cannot_connect(hass): """Failed call.""" with patch( - "pydeconz.DeconzSession.initialize", side_effect=pydeconz.errors.RequestError, + "pydeconz.DeconzSession.initialize", + side_effect=pydeconz.errors.RequestError, ), pytest.raises(deconz.errors.CannotConnect): assert ( await deconz.gateway.get_gateway(hass, ENTRY_CONFIG, Mock(), Mock()) diff --git a/tests/components/denonavr/test_config_flow.py b/tests/components/denonavr/test_config_flow.py index f88ac38c46c..8fcc3af0f26 100644 --- a/tests/components/denonavr/test_config_flow.py +++ b/tests/components/denonavr/test_config_flow.py @@ -55,7 +55,8 @@ def denonavr_connect_fixture(): "homeassistant.components.denonavr.receiver.denonavr.DenonAVR.get_device_info", return_value=True, ), patch( - "homeassistant.components.denonavr.receiver.denonavr.DenonAVR.name", TEST_NAME, + "homeassistant.components.denonavr.receiver.denonavr.DenonAVR.name", + TEST_NAME, ), patch( "homeassistant.components.denonavr.receiver.denonavr.DenonAVR.model_name", TEST_MODEL, @@ -92,7 +93,8 @@ async def test_config_flow_manual_host_success(hass): assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_HOST: TEST_HOST}, + result["flow_id"], + {CONF_HOST: TEST_HOST}, ) assert result["type"] == "create_entry" @@ -125,7 +127,10 @@ async def test_config_flow_manual_discover_1_success(hass): "homeassistant.components.denonavr.config_flow.denonavr.ssdp.identify_denonavr_receivers", return_value=TEST_DISCOVER_1_RECEIVER, ): - result = await hass.config_entries.flow.async_configure(result["flow_id"], {},) + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) assert result["type"] == "create_entry" assert result["title"] == TEST_NAME @@ -157,14 +162,18 @@ async def test_config_flow_manual_discover_2_success(hass): "homeassistant.components.denonavr.config_flow.denonavr.ssdp.identify_denonavr_receivers", return_value=TEST_DISCOVER_2_RECEIVER, ): - result = await hass.config_entries.flow.async_configure(result["flow_id"], {},) + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) assert result["type"] == "form" assert result["step_id"] == "select" assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"select_host": TEST_HOST2}, + result["flow_id"], + {"select_host": TEST_HOST2}, ) assert result["type"] == "create_entry" @@ -197,7 +206,10 @@ async def test_config_flow_manual_discover_error(hass): "homeassistant.components.denonavr.config_flow.denonavr.ssdp.identify_denonavr_receivers", return_value=[], ): - result = await hass.config_entries.flow.async_configure(result["flow_id"], {},) + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) assert result["type"] == "form" assert result["step_id"] == "user" @@ -223,7 +235,8 @@ async def test_config_flow_manual_host_no_serial(hass): None, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_HOST: TEST_HOST}, + result["flow_id"], + {CONF_HOST: TEST_HOST}, ) assert result["type"] == "create_entry" @@ -257,7 +270,8 @@ async def test_config_flow_manual_host_no_mac(hass): return_value=None, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_HOST: TEST_HOST}, + result["flow_id"], + {CONF_HOST: TEST_HOST}, ) assert result["type"] == "create_entry" @@ -294,7 +308,8 @@ async def test_config_flow_manual_host_no_serial_no_mac(hass): return_value=None, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_HOST: TEST_HOST}, + result["flow_id"], + {CONF_HOST: TEST_HOST}, ) assert result["type"] == "create_entry" @@ -331,7 +346,8 @@ async def test_config_flow_manual_host_no_serial_no_mac_exception(hass): side_effect=OSError, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_HOST: TEST_HOST}, + result["flow_id"], + {CONF_HOST: TEST_HOST}, ) assert result["type"] == "create_entry" @@ -368,7 +384,8 @@ async def test_config_flow_manual_host_connection_error(hass): None, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_HOST: TEST_HOST}, + result["flow_id"], + {CONF_HOST: TEST_HOST}, ) assert result["type"] == "abort" @@ -394,7 +411,8 @@ async def test_config_flow_manual_host_no_device_info(hass): None, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_HOST: TEST_HOST}, + result["flow_id"], + {CONF_HOST: TEST_HOST}, ) assert result["type"] == "abort" @@ -417,7 +435,10 @@ async def test_config_flow_ssdp(hass): assert result["type"] == "form" assert result["step_id"] == "confirm" - result = await hass.config_entries.flow.async_configure(result["flow_id"], {},) + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) assert result["type"] == "create_entry" assert result["title"] == TEST_NAME @@ -549,7 +570,8 @@ async def test_config_flow_manual_host_no_serial_double_config(hass): None, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_HOST: TEST_HOST}, + result["flow_id"], + {CONF_HOST: TEST_HOST}, ) assert result["type"] == "create_entry" @@ -576,7 +598,8 @@ async def test_config_flow_manual_host_no_serial_double_config(hass): None, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_HOST: TEST_HOST}, + result["flow_id"], + {CONF_HOST: TEST_HOST}, ) assert result["type"] == "abort" diff --git a/tests/components/denonavr/test_media_player.py b/tests/components/denonavr/test_media_player.py index 980ad758c80..bb9f83b58d7 100644 --- a/tests/components/denonavr/test_media_player.py +++ b/tests/components/denonavr/test_media_player.py @@ -36,7 +36,8 @@ ENTITY_ID = f"{media_player.DOMAIN}.{TEST_NAME}" def client_fixture(): """Patch of client library for tests.""" with patch( - "homeassistant.components.denonavr.receiver.denonavr.DenonAVR", autospec=True, + "homeassistant.components.denonavr.receiver.denonavr.DenonAVR", + autospec=True, ) as mock_client_class, patch( "homeassistant.components.denonavr.receiver.denonavr.discover" ): @@ -64,7 +65,9 @@ async def setup_denonavr(hass): } mock_entry = MockConfigEntry( - domain=DOMAIN, unique_id=TEST_UNIQUE_ID, data=entry_data, + domain=DOMAIN, + unique_id=TEST_UNIQUE_ID, + data=entry_data, ) mock_entry.add_to_hass(hass) diff --git a/tests/components/device_sun_light_trigger/test_init.py b/tests/components/device_sun_light_trigger/test_init.py index 2663018fc09..19715577e2a 100644 --- a/tests/components/device_sun_light_trigger/test_init.py +++ b/tests/components/device_sun_light_trigger/test_init.py @@ -222,7 +222,9 @@ async def test_initialize_start(hass): """Test we initialize when HA starts.""" hass.state = CoreState.not_running assert await async_setup_component( - hass, device_sun_light_trigger.DOMAIN, {device_sun_light_trigger.DOMAIN: {}}, + hass, + device_sun_light_trigger.DOMAIN, + {device_sun_light_trigger.DOMAIN: {}}, ) with patch( diff --git a/tests/components/devolo_home_control/test_config_flow.py b/tests/components/devolo_home_control/test_config_flow.py index 01b4603257a..6790c85b777 100644 --- a/tests/components/devolo_home_control/test_config_flow.py +++ b/tests/components/devolo_home_control/test_config_flow.py @@ -17,7 +17,8 @@ async def test_form(hass): assert result["errors"] == {} with patch( - "homeassistant.components.devolo_home_control.async_setup", return_value=True, + "homeassistant.components.devolo_home_control.async_setup", + return_value=True, ) as mock_setup, patch( "homeassistant.components.devolo_home_control.async_setup_entry", return_value=True, @@ -96,7 +97,8 @@ async def test_form_advanced_options(hass): assert result["errors"] == {} with patch( - "homeassistant.components.devolo_home_control.async_setup", return_value=True, + "homeassistant.components.devolo_home_control.async_setup", + return_value=True, ) as mock_setup, patch( "homeassistant.components.devolo_home_control.async_setup_entry", return_value=True, diff --git a/tests/components/dexcom/test_config_flow.py b/tests/components/dexcom/test_config_flow.py index b244751a811..b95f796b230 100644 --- a/tests/components/dexcom/test_config_flow.py +++ b/tests/components/dexcom/test_config_flow.py @@ -25,10 +25,12 @@ async def test_form(hass): ), patch( "homeassistant.components.dexcom.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.dexcom.async_setup_entry", return_value=True, + "homeassistant.components.dexcom.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], CONFIG, + result["flow_id"], + CONFIG, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY @@ -46,10 +48,12 @@ async def test_form_account_error(hass): ) with patch( - "homeassistant.components.dexcom.config_flow.Dexcom", side_effect=AccountError, + "homeassistant.components.dexcom.config_flow.Dexcom", + side_effect=AccountError, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], CONFIG, + result["flow_id"], + CONFIG, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -63,10 +67,12 @@ async def test_form_session_error(hass): ) with patch( - "homeassistant.components.dexcom.config_flow.Dexcom", side_effect=SessionError, + "homeassistant.components.dexcom.config_flow.Dexcom", + side_effect=SessionError, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], CONFIG, + result["flow_id"], + CONFIG, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -80,10 +86,12 @@ async def test_form_unknown_error(hass): ) with patch( - "homeassistant.components.dexcom.config_flow.Dexcom", side_effect=Exception, + "homeassistant.components.dexcom.config_flow.Dexcom", + side_effect=Exception, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], CONFIG, + result["flow_id"], + CONFIG, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -92,7 +100,11 @@ async def test_form_unknown_error(hass): async def test_option_flow_default(hass): """Test config flow options.""" - entry = MockConfigEntry(domain=DOMAIN, data=CONFIG, options=None,) + entry = MockConfigEntry( + domain=DOMAIN, + data=CONFIG, + options=None, + ) entry.add_to_hass(hass) result = await hass.config_entries.options.async_init(entry.entry_id) @@ -101,7 +113,8 @@ async def test_option_flow_default(hass): assert result["step_id"] == "init" result2 = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={}, + result["flow_id"], + user_input={}, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result2["data"] == { @@ -112,7 +125,9 @@ async def test_option_flow_default(hass): async def test_option_flow(hass): """Test config flow options.""" entry = MockConfigEntry( - domain=DOMAIN, data=CONFIG, options={CONF_UNIT_OF_MEASUREMENT: MG_DL}, + domain=DOMAIN, + data=CONFIG, + options={CONF_UNIT_OF_MEASUREMENT: MG_DL}, ) entry.add_to_hass(hass) @@ -122,7 +137,8 @@ async def test_option_flow(hass): assert result["step_id"] == "init" result = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={CONF_UNIT_OF_MEASUREMENT: MMOL_L}, + result["flow_id"], + user_input={CONF_UNIT_OF_MEASUREMENT: MMOL_L}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result["data"] == { diff --git a/tests/components/dexcom/test_init.py b/tests/components/dexcom/test_init.py index 393aa9cfe98..2cb3ad3bf79 100644 --- a/tests/components/dexcom/test_init.py +++ b/tests/components/dexcom/test_init.py @@ -19,7 +19,8 @@ async def test_setup_entry_account_error(hass): options=None, ) with patch( - "homeassistant.components.dexcom.Dexcom", side_effect=AccountError, + "homeassistant.components.dexcom.Dexcom", + side_effect=AccountError, ): entry.add_to_hass(hass) result = await hass.config_entries.async_setup(entry.entry_id) @@ -38,7 +39,8 @@ async def test_setup_entry_session_error(hass): options=None, ) with patch( - "homeassistant.components.dexcom.Dexcom", side_effect=SessionError, + "homeassistant.components.dexcom.Dexcom", + side_effect=SessionError, ): entry.add_to_hass(hass) result = await hass.config_entries.async_setup(entry.entry_id) diff --git a/tests/components/dexcom/test_sensor.py b/tests/components/dexcom/test_sensor.py index de45e65155f..c9e00398140 100644 --- a/tests/components/dexcom/test_sensor.py +++ b/tests/components/dexcom/test_sensor.py @@ -98,7 +98,8 @@ async def test_sensors_options_changed(hass): return_value="test_session_id", ): hass.config_entries.async_update_entry( - entry=entry, options={CONF_UNIT_OF_MEASUREMENT: MMOL_L}, + entry=entry, + options={CONF_UNIT_OF_MEASUREMENT: MMOL_L}, ) await hass.async_block_till_done() diff --git a/tests/components/dialogflow/test_init.py b/tests/components/dialogflow/test_init.py index 6df59873bd1..2213e52bef7 100644 --- a/tests/components/dialogflow/test_init.py +++ b/tests/components/dialogflow/test_init.py @@ -79,7 +79,8 @@ async def fixture(hass, aiohttp_client): ) await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) result = await hass.config_entries.flow.async_init( diff --git a/tests/components/directv/test_config_flow.py b/tests/components/directv/test_config_flow.py index 0082f9a5439..df3c606f687 100644 --- a/tests/components/directv/test_config_flow.py +++ b/tests/components/directv/test_config_flow.py @@ -28,7 +28,8 @@ from tests.test_util.aiohttp import AiohttpClientMocker async def test_show_user_form(hass: HomeAssistantType) -> None: """Test that the user set up form is served.""" result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_USER}, + DOMAIN, + context={CONF_SOURCE: SOURCE_USER}, ) assert result["step_id"] == "user" @@ -59,7 +60,9 @@ async def test_cannot_connect( user_input = MOCK_USER_INPUT.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=user_input, + DOMAIN, + context={CONF_SOURCE: SOURCE_USER}, + data=user_input, ) assert result["type"] == RESULT_TYPE_FORM @@ -75,7 +78,9 @@ async def test_ssdp_cannot_connect( discovery_info = MOCK_SSDP_DISCOVERY_INFO.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info, + DOMAIN, + context={CONF_SOURCE: SOURCE_SSDP}, + data=discovery_info, ) assert result["type"] == RESULT_TYPE_ABORT @@ -107,7 +112,9 @@ async def test_user_device_exists_abort( user_input = MOCK_USER_INPUT.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=user_input, + DOMAIN, + context={CONF_SOURCE: SOURCE_USER}, + data=user_input, ) assert result["type"] == RESULT_TYPE_ABORT @@ -122,7 +129,9 @@ async def test_ssdp_device_exists_abort( discovery_info = MOCK_SSDP_DISCOVERY_INFO.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info, + DOMAIN, + context={CONF_SOURCE: SOURCE_SSDP}, + data=discovery_info, ) assert result["type"] == RESULT_TYPE_ABORT @@ -138,7 +147,9 @@ async def test_ssdp_with_receiver_id_device_exists_abort( discovery_info = MOCK_SSDP_DISCOVERY_INFO.copy() discovery_info[ATTR_UPNP_SERIAL] = UPNP_SERIAL result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info, + DOMAIN, + context={CONF_SOURCE: SOURCE_SSDP}, + data=discovery_info, ) assert result["type"] == RESULT_TYPE_ABORT @@ -155,7 +166,9 @@ async def test_unknown_error( side_effect=Exception, ): result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=user_input, + DOMAIN, + context={CONF_SOURCE: SOURCE_USER}, + data=user_input, ) assert result["type"] == RESULT_TYPE_ABORT @@ -172,7 +185,9 @@ async def test_ssdp_unknown_error( side_effect=Exception, ): result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info, + DOMAIN, + context={CONF_SOURCE: SOURCE_SSDP}, + data=discovery_info, ) assert result["type"] == RESULT_TYPE_ABORT @@ -209,7 +224,9 @@ async def test_full_import_flow_implementation( "homeassistant.components.directv.async_setup_entry", return_value=True ), patch("homeassistant.components.directv.async_setup", return_value=True): result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_IMPORT}, data=user_input, + DOMAIN, + context={CONF_SOURCE: SOURCE_IMPORT}, + data=user_input, ) assert result["type"] == RESULT_TYPE_CREATE_ENTRY @@ -227,7 +244,8 @@ async def test_full_user_flow_implementation( mock_connection(aioclient_mock) result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_USER}, + DOMAIN, + context={CONF_SOURCE: SOURCE_USER}, ) assert result["type"] == RESULT_TYPE_FORM @@ -238,7 +256,8 @@ async def test_full_user_flow_implementation( "homeassistant.components.directv.async_setup_entry", return_value=True ), patch("homeassistant.components.directv.async_setup", return_value=True): result = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input=user_input, + result["flow_id"], + user_input=user_input, ) assert result["type"] == RESULT_TYPE_CREATE_ENTRY diff --git a/tests/components/doorbird/test_config_flow.py b/tests/components/doorbird/test_config_flow.py index 7c7c034c6b4..f8a01899bd5 100644 --- a/tests/components/doorbird/test_config_flow.py +++ b/tests/components/doorbird/test_config_flow.py @@ -55,10 +55,12 @@ async def test_user_form(hass): ), patch( "homeassistant.components.doorbird.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.doorbird.async_setup_entry", return_value=True, + "homeassistant.components.doorbird.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], VALID_CONFIG, + result["flow_id"], + VALID_CONFIG, ) assert result2["type"] == "create_entry" @@ -98,7 +100,8 @@ async def test_form_import(hass): ), patch("homeassistant.components.logbook.async_setup", return_value=True), patch( "homeassistant.components.doorbird.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.doorbird.async_setup_entry", return_value=True, + "homeassistant.components.doorbird.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, @@ -165,7 +168,8 @@ async def test_form_import_with_zeroconf_already_discovered(hass): ), patch("homeassistant.components.logbook.async_setup", return_value=True), patch( "homeassistant.components.doorbird.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.doorbird.async_setup_entry", return_value=True, + "homeassistant.components.doorbird.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, @@ -264,7 +268,8 @@ async def test_form_zeroconf_correct_oui(hass): ), patch("homeassistant.components.logbook.async_setup", return_value=True), patch( "homeassistant.components.doorbird.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.doorbird.async_setup_entry", return_value=True, + "homeassistant.components.doorbird.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], VALID_CONFIG @@ -299,7 +304,8 @@ async def test_form_user_cannot_connect(hass): return_value=doorbirdapi, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], VALID_CONFIG, + result["flow_id"], + VALID_CONFIG, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -325,7 +331,8 @@ async def test_form_user_invalid_auth(hass): return_value=doorbirdapi, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], VALID_CONFIG, + result["flow_id"], + VALID_CONFIG, ) assert result2["type"] == "form" diff --git a/tests/components/dunehd/test_config_flow.py b/tests/components/dunehd/test_config_flow.py index 2336d2e4a3f..f2d30b2a8dd 100644 --- a/tests/components/dunehd/test_config_flow.py +++ b/tests/components/dunehd/test_config_flow.py @@ -39,7 +39,9 @@ async def test_import_cannot_connect(hass): async def test_import_duplicate_error(hass): """Test that errors are shown when duplicates are added during import.""" config_entry = MockConfigEntry( - domain=DOMAIN, data={CONF_HOST: "dunehd-host"}, title="dunehd-host", + domain=DOMAIN, + data={CONF_HOST: "dunehd-host"}, + title="dunehd-host", ) config_entry.add_to_hass(hass) @@ -74,7 +76,9 @@ async def test_user_cannot_connect(hass): async def test_duplicate_error(hass): """Test that errors are shown when duplicates are added.""" config_entry = MockConfigEntry( - domain=DOMAIN, data=CONFIG_HOSTNAME, title="dunehd-host", + domain=DOMAIN, + data=CONFIG_HOSTNAME, + title="dunehd-host", ) config_entry.add_to_hass(hass) diff --git a/tests/components/dynalite/test_init.py b/tests/components/dynalite/test_init.py index e36e6aeba2a..faa75aadef8 100644 --- a/tests/components/dynalite/test_init.py +++ b/tests/components/dynalite/test_init.py @@ -88,7 +88,8 @@ async def test_service_request_area_preset(hass): "homeassistant.components.dynalite.bridge.DynaliteDevices.async_setup", return_value=True, ), patch( - "dynalite_devices_lib.dynalite.Dynalite.request_area_preset", return_value=True, + "dynalite_devices_lib.dynalite.Dynalite.request_area_preset", + return_value=True, ) as mock_req_area_pres: assert await async_setup_component( hass, @@ -105,25 +106,33 @@ async def test_service_request_area_preset(hass): await hass.async_block_till_done() assert len(hass.config_entries.async_entries(dynalite.DOMAIN)) == 2 await hass.services.async_call( - dynalite.DOMAIN, "request_area_preset", {"host": "1.2.3.4", "area": 2}, + dynalite.DOMAIN, + "request_area_preset", + {"host": "1.2.3.4", "area": 2}, ) await hass.async_block_till_done() mock_req_area_pres.assert_called_once_with(2, 1) mock_req_area_pres.reset_mock() await hass.services.async_call( - dynalite.DOMAIN, "request_area_preset", {"area": 3}, + dynalite.DOMAIN, + "request_area_preset", + {"area": 3}, ) await hass.async_block_till_done() assert mock_req_area_pres.mock_calls == [call(3, 1), call(3, 1)] mock_req_area_pres.reset_mock() await hass.services.async_call( - dynalite.DOMAIN, "request_area_preset", {"host": "5.6.7.8", "area": 4}, + dynalite.DOMAIN, + "request_area_preset", + {"host": "5.6.7.8", "area": 4}, ) await hass.async_block_till_done() mock_req_area_pres.assert_called_once_with(4, 1) mock_req_area_pres.reset_mock() await hass.services.async_call( - dynalite.DOMAIN, "request_area_preset", {"host": "6.5.4.3", "area": 5}, + dynalite.DOMAIN, + "request_area_preset", + {"host": "6.5.4.3", "area": 5}, ) await hass.async_block_till_done() mock_req_area_pres.assert_not_called() @@ -137,7 +146,9 @@ async def test_service_request_area_preset(hass): mock_req_area_pres.assert_called_once_with(6, 9) mock_req_area_pres.reset_mock() await hass.services.async_call( - dynalite.DOMAIN, "request_area_preset", {"host": "1.2.3.4", "area": 7}, + dynalite.DOMAIN, + "request_area_preset", + {"host": "1.2.3.4", "area": 7}, ) await hass.async_block_till_done() mock_req_area_pres.assert_called_once_with(7, 1) @@ -179,12 +190,16 @@ async def test_service_request_channel_level(hass): mock_req_chan_lvl.reset_mock() with pytest.raises(MultipleInvalid): await hass.services.async_call( - dynalite.DOMAIN, "request_channel_level", {"area": 3}, + dynalite.DOMAIN, + "request_channel_level", + {"area": 3}, ) await hass.async_block_till_done() mock_req_chan_lvl.assert_not_called() await hass.services.async_call( - dynalite.DOMAIN, "request_channel_level", {"area": 4, "channel": 5}, + dynalite.DOMAIN, + "request_channel_level", + {"area": 4, "channel": 5}, ) await hass.async_block_till_done() assert mock_req_chan_lvl.mock_calls == [call(4, 5), call(4, 5)] diff --git a/tests/components/efergy/test_sensor.py b/tests/components/efergy/test_sensor.py index 7d1d928cef8..1cf01bdb96c 100644 --- a/tests/components/efergy/test_sensor.py +++ b/tests/components/efergy/test_sensor.py @@ -35,14 +35,16 @@ def mock_responses(mock): """Mock responses for Efergy.""" base_url = "https://engage.efergy.com/mobile_proxy/" mock.get( - f"{base_url}getInstant?token={token}", text=load_fixture("efergy_instant.json"), + f"{base_url}getInstant?token={token}", + text=load_fixture("efergy_instant.json"), ) mock.get( f"{base_url}getEnergy?token={token}&offset=300&period=day", text=load_fixture("efergy_energy.json"), ) mock.get( - f"{base_url}getBudget?token={token}", text=load_fixture("efergy_budget.json"), + f"{base_url}getBudget?token={token}", + text=load_fixture("efergy_budget.json"), ) mock.get( f"{base_url}getCost?token={token}&offset=300&period=day", diff --git a/tests/components/elgato/__init__.py b/tests/components/elgato/__init__.py index 95791161a1f..5f0f2f5fb14 100644 --- a/tests/components/elgato/__init__.py +++ b/tests/components/elgato/__init__.py @@ -9,7 +9,9 @@ from tests.test_util.aiohttp import AiohttpClientMocker async def init_integration( - hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, skip_setup: bool = False, + hass: HomeAssistant, + aioclient_mock: AiohttpClientMocker, + skip_setup: bool = False, ) -> MockConfigEntry: """Set up the Elgato Key Light integration in Home Assistant.""" diff --git a/tests/components/elgato/test_config_flow.py b/tests/components/elgato/test_config_flow.py index 7d50aec2e22..bd65811133a 100644 --- a/tests/components/elgato/test_config_flow.py +++ b/tests/components/elgato/test_config_flow.py @@ -17,7 +17,8 @@ from tests.test_util.aiohttp import AiohttpClientMocker async def test_show_user_form(hass: HomeAssistant) -> None: """Test that the user set up form is served.""" result = await hass.config_entries.flow.async_init( - config_flow.DOMAIN, context={"source": SOURCE_USER}, + config_flow.DOMAIN, + context={"source": SOURCE_USER}, ) assert result["step_id"] == "user" @@ -179,7 +180,8 @@ async def test_full_user_flow_implementation( ) result = await hass.config_entries.flow.async_init( - config_flow.DOMAIN, context={"source": SOURCE_USER}, + config_flow.DOMAIN, + context={"source": SOURCE_USER}, ) assert result["step_id"] == "user" diff --git a/tests/components/elgato/test_light.py b/tests/components/elgato/test_light.py index 13898dad757..838608c0aac 100644 --- a/tests/components/elgato/test_light.py +++ b/tests/components/elgato/test_light.py @@ -51,7 +51,8 @@ async def test_light_change_state( assert state.state == STATE_ON with patch( - "homeassistant.components.elgato.light.Elgato.light", return_value=mock_coro(), + "homeassistant.components.elgato.light.Elgato.light", + return_value=mock_coro(), ) as mock_light: await hass.services.async_call( LIGHT_DOMAIN, @@ -68,7 +69,8 @@ async def test_light_change_state( mock_light.assert_called_with(on=True, brightness=100, temperature=100) with patch( - "homeassistant.components.elgato.light.Elgato.light", return_value=mock_coro(), + "homeassistant.components.elgato.light.Elgato.light", + return_value=mock_coro(), ) as mock_light: await hass.services.async_call( LIGHT_DOMAIN, @@ -87,7 +89,8 @@ async def test_light_unavailable( """Test error/unavailable handling of an Elgato Key Light.""" await init_integration(hass, aioclient_mock) with patch( - "homeassistant.components.elgato.light.Elgato.light", side_effect=ElgatoError, + "homeassistant.components.elgato.light.Elgato.light", + side_effect=ElgatoError, ): with patch( "homeassistant.components.elgato.light.Elgato.state", diff --git a/tests/components/elkm1/test_config_flow.py b/tests/components/elkm1/test_config_flow.py index 992483529a5..0a959cf1b97 100644 --- a/tests/components/elkm1/test_config_flow.py +++ b/tests/components/elkm1/test_config_flow.py @@ -26,11 +26,13 @@ async def test_form_user_with_secure_elk(hass): mocked_elk = mock_elk(invalid_auth=False) with patch( - "homeassistant.components.elkm1.config_flow.elkm1.Elk", return_value=mocked_elk, + "homeassistant.components.elkm1.config_flow.elkm1.Elk", + return_value=mocked_elk, ), patch( "homeassistant.components.elkm1.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.elkm1.async_setup_entry", return_value=True, + "homeassistant.components.elkm1.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -71,11 +73,13 @@ async def test_form_user_with_non_secure_elk(hass): mocked_elk = mock_elk(invalid_auth=False) with patch( - "homeassistant.components.elkm1.config_flow.elkm1.Elk", return_value=mocked_elk, + "homeassistant.components.elkm1.config_flow.elkm1.Elk", + return_value=mocked_elk, ), patch( "homeassistant.components.elkm1.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.elkm1.async_setup_entry", return_value=True, + "homeassistant.components.elkm1.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -114,11 +118,13 @@ async def test_form_user_with_serial_elk(hass): mocked_elk = mock_elk(invalid_auth=False) with patch( - "homeassistant.components.elkm1.config_flow.elkm1.Elk", return_value=mocked_elk, + "homeassistant.components.elkm1.config_flow.elkm1.Elk", + return_value=mocked_elk, ), patch( "homeassistant.components.elkm1.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.elkm1.async_setup_entry", return_value=True, + "homeassistant.components.elkm1.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -154,7 +160,8 @@ async def test_form_cannot_connect(hass): mocked_elk = mock_elk(invalid_auth=False) with patch( - "homeassistant.components.elkm1.config_flow.elkm1.Elk", return_value=mocked_elk, + "homeassistant.components.elkm1.config_flow.elkm1.Elk", + return_value=mocked_elk, ), patch( "homeassistant.components.elkm1.config_flow.async_wait_for_elk_to_sync", return_value=False, @@ -184,7 +191,8 @@ async def test_form_invalid_auth(hass): mocked_elk = mock_elk(invalid_auth=True) with patch( - "homeassistant.components.elkm1.config_flow.elkm1.Elk", return_value=mocked_elk, + "homeassistant.components.elkm1.config_flow.elkm1.Elk", + return_value=mocked_elk, ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -208,11 +216,13 @@ async def test_form_import(hass): mocked_elk = mock_elk(invalid_auth=False) with patch( - "homeassistant.components.elkm1.config_flow.elkm1.Elk", return_value=mocked_elk, + "homeassistant.components.elkm1.config_flow.elkm1.Elk", + return_value=mocked_elk, ), patch( "homeassistant.components.elkm1.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.elkm1.async_setup_entry", return_value=True, + "homeassistant.components.elkm1.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, diff --git a/tests/components/enocean/test_config_flow.py b/tests/components/enocean/test_config_flow.py index aee6765272e..b815d48694a 100644 --- a/tests/components/enocean/test_config_flow.py +++ b/tests/components/enocean/test_config_flow.py @@ -120,7 +120,8 @@ async def test_manual_flow_with_invalid_path(hass): USER_PROVIDED_PATH = "/user/provided/path" with patch( - DONGLE_VALIDATE_PATH_METHOD, Mock(return_value=False), + DONGLE_VALIDATE_PATH_METHOD, + Mock(return_value=False), ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "manual"}, data={CONF_DEVICE: USER_PROVIDED_PATH} @@ -149,7 +150,8 @@ async def test_import_flow_with_invalid_path(hass): DATA_TO_IMPORT = {CONF_DEVICE: "/invalid/path/to/import"} with patch( - DONGLE_VALIDATE_PATH_METHOD, Mock(return_value=False), + DONGLE_VALIDATE_PATH_METHOD, + Mock(return_value=False), ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "import"}, data=DATA_TO_IMPORT diff --git a/tests/components/esphome/test_config_flow.py b/tests/components/esphome/test_config_flow.py index 50aaa989028..4c5cb15a261 100644 --- a/tests/components/esphome/test_config_flow.py +++ b/tests/components/esphome/test_config_flow.py @@ -49,7 +49,9 @@ def mock_api_connection_error(): async def test_user_connection_works(hass, mock_client): """Test we can finish a config flow.""" result = await hass.config_entries.flow.async_init( - "esphome", context={"source": "user"}, data=None, + "esphome", + context={"source": "user"}, + data=None, ) assert result["type"] == RESULT_TYPE_FORM diff --git a/tests/components/filter/test_sensor.py b/tests/components/filter/test_sensor.py index 84db16c1464..0aa390223ca 100644 --- a/tests/components/filter/test_sensor.py +++ b/tests/components/filter/test_sensor.py @@ -345,11 +345,16 @@ async def test_reload(hass): assert hass.states.get("sensor.test") yaml_path = path.join( - _get_fixtures_base_path(), "fixtures", "filter/configuration.yaml", + _get_fixtures_base_path(), + "fixtures", + "filter/configuration.yaml", ) with patch.object(hass_config, "YAML_CONFIG_FILE", yaml_path): await hass.services.async_call( - DOMAIN, SERVICE_RELOAD, {}, blocking=True, + DOMAIN, + SERVICE_RELOAD, + {}, + blocking=True, ) await hass.async_block_till_done() diff --git a/tests/components/flick_electric/test_config_flow.py b/tests/components/flick_electric/test_config_flow.py index 90a6271aa7d..c8fe6298764 100644 --- a/tests/components/flick_electric/test_config_flow.py +++ b/tests/components/flick_electric/test_config_flow.py @@ -15,7 +15,9 @@ CONF = {CONF_USERNAME: "test-username", CONF_PASSWORD: "test-password"} async def _flow_submit(hass): return await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_USER}, data=CONF, + DOMAIN, + context={"source": config_entries.SOURCE_USER}, + data=CONF, ) @@ -34,10 +36,12 @@ async def test_form(hass): ), patch( "homeassistant.components.flick_electric.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.flick_electric.async_setup_entry", return_value=True, + "homeassistant.components.flick_electric.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], CONF, + result["flow_id"], + CONF, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY diff --git a/tests/components/flume/test_config_flow.py b/tests/components/flume/test_config_flow.py index 6f2c8d2ed04..bf95700c2de 100644 --- a/tests/components/flume/test_config_flow.py +++ b/tests/components/flume/test_config_flow.py @@ -31,14 +31,16 @@ async def test_form(hass): mock_flume_device_list = _get_mocked_flume_device_list() with patch( - "homeassistant.components.flume.config_flow.FlumeAuth", return_value=True, + "homeassistant.components.flume.config_flow.FlumeAuth", + return_value=True, ), patch( "homeassistant.components.flume.config_flow.FlumeDeviceList", return_value=mock_flume_device_list, ), patch( "homeassistant.components.flume.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.flume.async_setup_entry", return_value=True, + "homeassistant.components.flume.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -69,14 +71,16 @@ async def test_form_import(hass): mock_flume_device_list = _get_mocked_flume_device_list() with patch( - "homeassistant.components.flume.config_flow.FlumeAuth", return_value=True, + "homeassistant.components.flume.config_flow.FlumeAuth", + return_value=True, ), patch( "homeassistant.components.flume.config_flow.FlumeDeviceList", return_value=mock_flume_device_list, ), patch( "homeassistant.components.flume.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.flume.async_setup_entry", return_value=True, + "homeassistant.components.flume.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, @@ -109,7 +113,8 @@ async def test_form_invalid_auth(hass): ) with patch( - "homeassistant.components.flume.config_flow.FlumeAuth", return_value=True, + "homeassistant.components.flume.config_flow.FlumeAuth", + return_value=True, ), patch( "homeassistant.components.flume.config_flow.FlumeDeviceList", side_effect=Exception, @@ -134,7 +139,8 @@ async def test_form_cannot_connect(hass): DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( - "homeassistant.components.flume.config_flow.FlumeAuth", return_value=True, + "homeassistant.components.flume.config_flow.FlumeAuth", + return_value=True, ), patch( "homeassistant.components.flume.config_flow.FlumeDeviceList", side_effect=requests.exceptions.ConnectionError(), diff --git a/tests/components/flunearyou/test_config_flow.py b/tests/components/flunearyou/test_config_flow.py index a3a0d41e885..d4e650e2b4a 100644 --- a/tests/components/flunearyou/test_config_flow.py +++ b/tests/components/flunearyou/test_config_flow.py @@ -31,7 +31,8 @@ async def test_general_error(hass): conf = {CONF_LATITUDE: "51.528308", CONF_LONGITUDE: "-0.3817765"} with patch( - "pyflunearyou.cdc.CdcReport.status_by_coordinates", side_effect=FluNearYouError, + "pyflunearyou.cdc.CdcReport.status_by_coordinates", + side_effect=FluNearYouError, ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=conf diff --git a/tests/components/forked_daapd/test_config_flow.py b/tests/components/forked_daapd/test_config_flow.py index 17b30121aaf..181c963ee4f 100644 --- a/tests/components/forked_daapd/test_config_flow.py +++ b/tests/components/forked_daapd/test_config_flow.py @@ -89,7 +89,9 @@ async def test_config_flow(hass, config_entry): # Also test that creating a new entry with the same host aborts result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data=config_entry.data, + DOMAIN, + context={"source": SOURCE_USER}, + data=config_entry.data, ) await hass.async_block_till_done() assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT diff --git a/tests/components/forked_daapd/test_media_player.py b/tests/components/forked_daapd/test_media_player.py index 4f5cb57d66c..15755949062 100644 --- a/tests/components/forked_daapd/test_media_player.py +++ b/tests/components/forked_daapd/test_media_player.py @@ -528,7 +528,9 @@ async def test_bunch_of_stuff_master(hass, get_request_return_values, mock_api_o await _service_call(hass, TEST_MASTER_ENTITY_NAME, SERVICE_TOGGLE) for output in SAMPLE_OUTPUTS_ON: mock_api_object.change_output.assert_any_call( - output["id"], selected=output["selected"], volume=output["volume"], + output["id"], + selected=output["selected"], + volume=output["volume"], ) mock_api_object.set_volume.assert_any_call(volume=0) mock_api_object.set_volume.assert_any_call(volume=SAMPLE_PLAYER_PAUSED["volume"]) diff --git a/tests/components/garmin_connect/test_config_flow.py b/tests/components/garmin_connect/test_config_flow.py index 366573a276c..93b24269441 100644 --- a/tests/components/garmin_connect/test_config_flow.py +++ b/tests/components/garmin_connect/test_config_flow.py @@ -23,7 +23,9 @@ MOCK_CONF = { @pytest.fixture(name="mock_garmin_connect") def mock_garmin(): """Mock Garmin.""" - with patch("homeassistant.components.garmin_connect.config_flow.Garmin",) as garmin: + with patch( + "homeassistant.components.garmin_connect.config_flow.Garmin", + ) as garmin: garmin.return_value.get_full_name.return_value = MOCK_CONF[CONF_ID] yield garmin.return_value diff --git a/tests/components/gdacs/test_sensor.py b/tests/components/gdacs/test_sensor.py index 9be6742deed..b123021a7e3 100644 --- a/tests/components/gdacs/test_sensor.py +++ b/tests/components/gdacs/test_sensor.py @@ -29,10 +29,24 @@ async def test_setup(hass, legacy_patchable_time): """Test the general setup of the integration.""" # Set up some mock feed entries for this test. mock_entry_1 = _generate_mock_feed_entry( - "1234", "Title 1", 15.5, (38.0, -3.0), attribution="Attribution 1", + "1234", + "Title 1", + 15.5, + (38.0, -3.0), + attribution="Attribution 1", + ) + mock_entry_2 = _generate_mock_feed_entry( + "2345", + "Title 2", + 20.5, + (38.1, -3.1), + ) + mock_entry_3 = _generate_mock_feed_entry( + "3456", + "Title 3", + 25.5, + (38.2, -3.2), ) - mock_entry_2 = _generate_mock_feed_entry("2345", "Title 2", 20.5, (38.1, -3.1),) - mock_entry_3 = _generate_mock_feed_entry("3456", "Title 3", 25.5, (38.2, -3.2),) mock_entry_4 = _generate_mock_feed_entry("4567", "Title 4", 12.5, (38.3, -3.3)) # Patching 'utcnow' to gain more control over the timed update. diff --git a/tests/components/geofency/test_init.py b/tests/components/geofency/test_init.py index 3a9bdf1fe73..dd3132b0117 100644 --- a/tests/components/geofency/test_init.py +++ b/tests/components/geofency/test_init.py @@ -150,7 +150,8 @@ async def setup_zones(loop, hass): async def webhook_id(hass, geofency_client): """Initialize the Geofency component and get the webhook_id.""" await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "user"} diff --git a/tests/components/gogogate2/common.py b/tests/components/gogogate2/common.py index d344a31cf4b..84999cb0e29 100644 --- a/tests/components/gogogate2/common.py +++ b/tests/components/gogogate2/common.py @@ -129,7 +129,8 @@ class ComponentFactory: assert result["step_id"] == "user" result = await self._hass.config_entries.flow.async_configure( - result["flow_id"], user_input=config_data, + result["flow_id"], + user_input=config_data, ) assert result assert result["type"] == RESULT_TYPE_CREATE_ENTRY diff --git a/tests/components/gogogate2/test_config_flow.py b/tests/components/gogogate2/test_config_flow.py index e921df406d2..55de8701b61 100644 --- a/tests/components/gogogate2/test_config_flow.py +++ b/tests/components/gogogate2/test_config_flow.py @@ -22,7 +22,8 @@ async def test_auth_fail( with patch( "homeassistant.components.gogogate2.async_setup", return_value=True ), patch( - "homeassistant.components.gogogate2.async_setup_entry", return_value=True, + "homeassistant.components.gogogate2.async_setup_entry", + return_value=True, ): await component_factory.configure_component() component_factory.api_class_mock.return_value = api_mock diff --git a/tests/components/gogogate2/test_cover.py b/tests/components/gogogate2/test_cover.py index 5bc9ed9ebd4..b754b88c05e 100644 --- a/tests/components/gogogate2/test_cover.py +++ b/tests/components/gogogate2/test_cover.py @@ -398,7 +398,9 @@ async def test_open_close( assert hass.states.get("cover.door1").state == STATE_OPEN await hass.services.async_call( - COVER_DOMAIN, "close_cover", service_data={"entity_id": "cover.door1"}, + COVER_DOMAIN, + "close_cover", + service_data={"entity_id": "cover.door1"}, ) await hass.async_block_till_done() component_data.api.close_door.assert_called_with(1) @@ -410,7 +412,9 @@ async def test_open_close( # Assert mid state changed when new status is received. await hass.services.async_call( - COVER_DOMAIN, "open_cover", service_data={"entity_id": "cover.door1"}, + COVER_DOMAIN, + "open_cover", + service_data={"entity_id": "cover.door1"}, ) await hass.async_block_till_done() component_data.api.open_door.assert_called_with(1) @@ -423,7 +427,9 @@ async def test_open_close( await component_data.data_update_coordinator.async_refresh() await hass.services.async_call( - HA_DOMAIN, "update_entity", service_data={"entity_id": "cover.door1"}, + HA_DOMAIN, + "update_entity", + service_data={"entity_id": "cover.door1"}, ) await hass.async_block_till_done() assert hass.states.get("cover.door1").state == STATE_CLOSED diff --git a/tests/components/google_assistant/test_helpers.py b/tests/components/google_assistant/test_helpers.py index c58f44c06c8..2bd68926da1 100644 --- a/tests/components/google_assistant/test_helpers.py +++ b/tests/components/google_assistant/test_helpers.py @@ -27,7 +27,8 @@ async def test_google_entity_sync_serialize_with_local_sdk(hass): hass.states.async_set("light.ceiling_lights", "off") hass.config.api = Mock(port=1234, use_ssl=True) await async_process_ha_core_config( - hass, {"external_url": "https://hostname:1234"}, + hass, + {"external_url": "https://hostname:1234"}, ) hass.http = Mock(server_port=1234) @@ -227,7 +228,8 @@ async def test_report_state_all(agents): @pytest.mark.parametrize( - "agents, result", [({}, 204), ({"1": 200}, 200), ({"1": 200, "2": 300}, 300)], + "agents, result", + [({}, 204), ({"1": 200}, 200), ({"1": 200, "2": 300}, 300)], ) async def test_sync_entities_all(agents, result): """Test sync entities .""" diff --git a/tests/components/google_assistant/test_init.py b/tests/components/google_assistant/test_init.py index 0df2b032b5a..e663df19d88 100644 --- a/tests/components/google_assistant/test_init.py +++ b/tests/components/google_assistant/test_init.py @@ -17,7 +17,9 @@ async def test_request_sync_service(aioclient_mock, hass): aioclient_mock.post(ga.const.REQUEST_SYNC_BASE_URL, status=200) await async_setup_component( - hass, "google_assistant", {"google_assistant": DUMMY_CONFIG}, + hass, + "google_assistant", + {"google_assistant": DUMMY_CONFIG}, ) assert aioclient_mock.call_count == 0 diff --git a/tests/components/google_assistant/test_smart_home.py b/tests/components/google_assistant/test_smart_home.py index db97a42dff4..f3bd42c1181 100644 --- a/tests/components/google_assistant/test_smart_home.py +++ b/tests/components/google_assistant/test_smart_home.py @@ -914,7 +914,8 @@ async def test_query_disconnect(hass): async def test_trait_execute_adding_query_data(hass): """Test a trait execute influencing query data.""" await async_process_ha_core_config( - hass, {"external_url": "https://example.com"}, + hass, + {"external_url": "https://example.com"}, ) hass.states.async_set( "camera.office", "idle", {"supported_features": camera.SUPPORT_STREAM} diff --git a/tests/components/google_assistant/test_trait.py b/tests/components/google_assistant/test_trait.py index a8f6b58fc46..ae51ba76ffc 100644 --- a/tests/components/google_assistant/test_trait.py +++ b/tests/components/google_assistant/test_trait.py @@ -110,7 +110,8 @@ async def test_brightness_light(hass): async def test_camera_stream(hass): """Test camera stream trait support for camera domain.""" await async_process_ha_core_config( - hass, {"external_url": "https://example.com"}, + hass, + {"external_url": "https://example.com"}, ) assert helpers.get_google_type(camera.DOMAIN, None) is not None assert trait.CameraStreamTrait.supported(camera.DOMAIN, camera.SUPPORT_STREAM, None) @@ -564,7 +565,8 @@ async def test_light_modes(hass): } assert trt.can_execute( - trait.COMMAND_MODES, params={"updateModeSettings": {"effect": "colorloop"}}, + trait.COMMAND_MODES, + params={"updateModeSettings": {"effect": "colorloop"}}, ) calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON) @@ -988,7 +990,9 @@ async def test_lock_unlock_unlock(hass): # Test with 2FA override with patch.object( - BASIC_CONFIG, "should_2fa", return_value=False, + BASIC_CONFIG, + "should_2fa", + return_value=False, ): await trt.execute(trait.COMMAND_LOCKUNLOCK, BASIC_DATA, {"lock": False}, {}) assert len(calls) == 2 @@ -1150,7 +1154,10 @@ async def test_arm_disarm_arm_away(hass): with pytest.raises(error.SmartHomeError) as err: await trt.execute( - trait.COMMAND_ARMDISARM, PIN_DATA, {"arm": True}, {}, + trait.COMMAND_ARMDISARM, + PIN_DATA, + {"arm": True}, + {}, ) @@ -1483,13 +1490,19 @@ async def test_inputselector(hass): "currentInput": "game", } - assert trt.can_execute(trait.COMMAND_INPUT, params={"newInput": "media"},) + assert trt.can_execute( + trait.COMMAND_INPUT, + params={"newInput": "media"}, + ) calls = async_mock_service( hass, media_player.DOMAIN, media_player.SERVICE_SELECT_SOURCE ) await trt.execute( - trait.COMMAND_INPUT, BASIC_DATA, {"newInput": "media"}, {}, + trait.COMMAND_INPUT, + BASIC_DATA, + {"newInput": "media"}, + {}, ) assert len(calls) == 1 @@ -1526,10 +1539,16 @@ async def test_inputselector_nextprev(hass, sources, source, source_next, source hass, media_player.DOMAIN, media_player.SERVICE_SELECT_SOURCE ) await trt.execute( - "action.devices.commands.NextInput", BASIC_DATA, {}, {}, + "action.devices.commands.NextInput", + BASIC_DATA, + {}, + {}, ) await trt.execute( - "action.devices.commands.PreviousInput", BASIC_DATA, {}, {}, + "action.devices.commands.PreviousInput", + BASIC_DATA, + {}, + {}, ) assert len(calls) == 2 @@ -1563,17 +1582,26 @@ async def test_inputselector_nextprev_invalid(hass, sources, source): with pytest.raises(SmartHomeError): await trt.execute( - "action.devices.commands.NextInput", BASIC_DATA, {}, {}, + "action.devices.commands.NextInput", + BASIC_DATA, + {}, + {}, ) with pytest.raises(SmartHomeError): await trt.execute( - "action.devices.commands.PreviousInput", BASIC_DATA, {}, {}, + "action.devices.commands.PreviousInput", + BASIC_DATA, + {}, + {}, ) with pytest.raises(SmartHomeError): await trt.execute( - "action.devices.commands.InvalidCommand", BASIC_DATA, {}, {}, + "action.devices.commands.InvalidCommand", + BASIC_DATA, + {}, + {}, ) @@ -1583,7 +1611,9 @@ async def test_modes_input_select(hass): assert trait.ModesTrait.supported(input_select.DOMAIN, None, None) trt = trait.ModesTrait( - hass, State("input_select.bla", "unavailable"), BASIC_CONFIG, + hass, + State("input_select.bla", "unavailable"), + BASIC_CONFIG, ) assert trt.sync_attributes() == {"availableModes": []} @@ -1633,14 +1663,18 @@ async def test_modes_input_select(hass): } assert trt.can_execute( - trait.COMMAND_MODES, params={"updateModeSettings": {"option": "xyz"}}, + trait.COMMAND_MODES, + params={"updateModeSettings": {"option": "xyz"}}, ) calls = async_mock_service( hass, input_select.DOMAIN, input_select.SERVICE_SELECT_OPTION ) await trt.execute( - trait.COMMAND_MODES, BASIC_DATA, {"updateModeSettings": {"option": "xyz"}}, {}, + trait.COMMAND_MODES, + BASIC_DATA, + {"updateModeSettings": {"option": "xyz"}}, + {}, ) assert len(calls) == 1 @@ -1711,7 +1745,10 @@ async def test_modes_humidifier(hass): calls = async_mock_service(hass, humidifier.DOMAIN, humidifier.SERVICE_SET_MODE) await trt.execute( - trait.COMMAND_MODES, BASIC_DATA, {"updateModeSettings": {"mode": "away"}}, {}, + trait.COMMAND_MODES, + BASIC_DATA, + {"updateModeSettings": {"mode": "away"}}, + {}, ) assert len(calls) == 1 @@ -1774,7 +1811,8 @@ async def test_sound_modes(hass): } assert trt.can_execute( - trait.COMMAND_MODES, params={"updateModeSettings": {"sound mode": "stereo"}}, + trait.COMMAND_MODES, + params={"updateModeSettings": {"sound mode": "stereo"}}, ) calls = async_mock_service( @@ -2003,7 +2041,9 @@ async def test_volume_media_player(hass): """Test volume trait support for media player domain.""" assert helpers.get_google_type(media_player.DOMAIN, None) is not None assert trait.VolumeTrait.supported( - media_player.DOMAIN, media_player.SUPPORT_VOLUME_SET, None, + media_player.DOMAIN, + media_player.SUPPORT_VOLUME_SET, + None, ) trt = trait.VolumeTrait( @@ -2054,7 +2094,9 @@ async def test_volume_media_player(hass): async def test_volume_media_player_relative(hass): """Test volume trait support for relative-volume-only media players.""" assert trait.VolumeTrait.supported( - media_player.DOMAIN, media_player.SUPPORT_VOLUME_STEP, None, + media_player.DOMAIN, + media_player.SUPPORT_VOLUME_STEP, + None, ) trt = trait.VolumeTrait( hass, @@ -2083,7 +2125,10 @@ async def test_volume_media_player_relative(hass): ) await trt.execute( - trait.COMMAND_VOLUME_RELATIVE, BASIC_DATA, {"relativeSteps": 10}, {}, + trait.COMMAND_VOLUME_RELATIVE, + BASIC_DATA, + {"relativeSteps": 10}, + {}, ) assert len(calls) == 10 for call in calls: @@ -2095,7 +2140,10 @@ async def test_volume_media_player_relative(hass): hass, media_player.DOMAIN, media_player.SERVICE_VOLUME_DOWN ) await trt.execute( - trait.COMMAND_VOLUME_RELATIVE, BASIC_DATA, {"relativeSteps": -10}, {}, + trait.COMMAND_VOLUME_RELATIVE, + BASIC_DATA, + {"relativeSteps": -10}, + {}, ) assert len(calls) == 10 for call in calls: @@ -2144,7 +2192,10 @@ async def test_media_player_mute(hass): hass, media_player.DOMAIN, media_player.SERVICE_VOLUME_MUTE ) await trt.execute( - trait.COMMAND_MUTE, BASIC_DATA, {"mute": True}, {}, + trait.COMMAND_MUTE, + BASIC_DATA, + {"mute": True}, + {}, ) assert len(mute_calls) == 1 assert mute_calls[0].data == { @@ -2156,7 +2207,10 @@ async def test_media_player_mute(hass): hass, media_player.DOMAIN, media_player.SERVICE_VOLUME_MUTE ) await trt.execute( - trait.COMMAND_MUTE, BASIC_DATA, {"mute": False}, {}, + trait.COMMAND_MUTE, + BASIC_DATA, + {"mute": False}, + {}, ) assert len(unmute_calls) == 1 assert unmute_calls[0].data == { diff --git a/tests/components/gpslogger/test_init.py b/tests/components/gpslogger/test_init.py index 18e80647fe7..39dc05303b3 100644 --- a/tests/components/gpslogger/test_init.py +++ b/tests/components/gpslogger/test_init.py @@ -64,7 +64,8 @@ async def setup_zones(loop, hass): async def webhook_id(hass, gpslogger_client): """Initialize the GPSLogger component and get the webhook_id.""" await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "user"} diff --git a/tests/components/griddy/test_config_flow.py b/tests/components/griddy/test_config_flow.py index 79f99d7f8b1..309864dbc11 100644 --- a/tests/components/griddy/test_config_flow.py +++ b/tests/components/griddy/test_config_flow.py @@ -22,10 +22,12 @@ async def test_form(hass): ), patch( "homeassistant.components.griddy.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.griddy.async_setup_entry", return_value=True, + "homeassistant.components.griddy.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"loadzone": "LZ_HOUSTON"}, + result["flow_id"], + {"loadzone": "LZ_HOUSTON"}, ) assert result2["type"] == "create_entry" @@ -47,7 +49,8 @@ async def test_form_cannot_connect(hass): side_effect=asyncio.TimeoutError, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"loadzone": "LZ_NORTH"}, + result["flow_id"], + {"loadzone": "LZ_NORTH"}, ) assert result2["type"] == "form" diff --git a/tests/components/group/common.py b/tests/components/group/common.py index 69de1cfee75..b2c35703e6c 100644 --- a/tests/components/group/common.py +++ b/tests/components/group/common.py @@ -31,18 +31,34 @@ def async_reload(hass): @bind_hass def set_group( - hass, object_id, name=None, entity_ids=None, icon=None, add=None, + hass, + object_id, + name=None, + entity_ids=None, + icon=None, + add=None, ): """Create/Update a group.""" hass.add_job( - async_set_group, hass, object_id, name, entity_ids, icon, add, + async_set_group, + hass, + object_id, + name, + entity_ids, + icon, + add, ) @callback @bind_hass def async_set_group( - hass, object_id, name=None, entity_ids=None, icon=None, add=None, + hass, + object_id, + name=None, + entity_ids=None, + icon=None, + add=None, ): """Create/Update a group.""" data = { diff --git a/tests/components/group/test_light.py b/tests/components/group/test_light.py index 5ca008ba91f..dae975ead03 100644 --- a/tests/components/group/test_light.py +++ b/tests/components/group/test_light.py @@ -667,11 +667,16 @@ async def test_reload(hass): assert hass.states.get("light.light_group").state == STATE_ON yaml_path = path.join( - _get_fixtures_base_path(), "fixtures", "group/configuration.yaml", + _get_fixtures_base_path(), + "fixtures", + "group/configuration.yaml", ) with patch.object(hass_config, "YAML_CONFIG_FILE", yaml_path): await hass.services.async_call( - DOMAIN, SERVICE_RELOAD, {}, blocking=True, + DOMAIN, + SERVICE_RELOAD, + {}, + blocking=True, ) await hass.async_block_till_done() diff --git a/tests/components/guardian/test_config_flow.py b/tests/components/guardian/test_config_flow.py index 91a1a3b83e0..a10bee374f8 100644 --- a/tests/components/guardian/test_config_flow.py +++ b/tests/components/guardian/test_config_flow.py @@ -35,7 +35,8 @@ async def test_connect_error(hass): conf = {CONF_IP_ADDRESS: "192.168.1.100", CONF_PORT: 7777} with patch( - "aioguardian.client.Client.connect", side_effect=GuardianError, + "aioguardian.client.Client.connect", + side_effect=GuardianError, ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=conf diff --git a/tests/components/harmony/test_config_flow.py b/tests/components/harmony/test_config_flow.py index acf1ffd16f1..d6bd4022d9e 100644 --- a/tests/components/harmony/test_config_flow.py +++ b/tests/components/harmony/test_config_flow.py @@ -44,14 +44,17 @@ async def test_user_form(hass): harmonyapi = _get_mock_harmonyapi(connect=True) with patch( - "homeassistant.components.harmony.util.HarmonyAPI", return_value=harmonyapi, + "homeassistant.components.harmony.util.HarmonyAPI", + return_value=harmonyapi, ), patch( "homeassistant.components.harmony.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.harmony.async_setup_entry", return_value=True, + "homeassistant.components.harmony.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": "1.2.3.4", "name": "friend"}, + result["flow_id"], + {"host": "1.2.3.4", "name": "friend"}, ) assert result2["type"] == "create_entry" @@ -68,11 +71,13 @@ async def test_form_import(hass): harmonyapi = _get_mock_harmonyapi(connect=True) with patch( - "homeassistant.components.harmony.util.HarmonyAPI", return_value=harmonyapi, + "homeassistant.components.harmony.util.HarmonyAPI", + return_value=harmonyapi, ), patch( "homeassistant.components.harmony.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.harmony.async_setup_entry", return_value=True, + "homeassistant.components.harmony.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, @@ -110,7 +115,8 @@ async def test_form_ssdp(hass): harmonyapi = _get_mock_harmonyapi(connect=True) with patch( - "homeassistant.components.harmony.util.HarmonyAPI", return_value=harmonyapi, + "homeassistant.components.harmony.util.HarmonyAPI", + return_value=harmonyapi, ): result = await hass.config_entries.flow.async_init( DOMAIN, @@ -129,13 +135,18 @@ async def test_form_ssdp(hass): } with patch( - "homeassistant.components.harmony.util.HarmonyAPI", return_value=harmonyapi, + "homeassistant.components.harmony.util.HarmonyAPI", + return_value=harmonyapi, ), patch( "homeassistant.components.harmony.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.harmony.async_setup_entry", return_value=True, + "homeassistant.components.harmony.async_setup_entry", + return_value=True, ) as mock_setup_entry: - result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {},) + result2 = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) assert result2["type"] == "create_entry" assert result2["title"] == "Harmony Hub" @@ -149,17 +160,22 @@ async def test_form_ssdp_aborts_before_checking_remoteid_if_host_known(hass): """Test we abort without connecting if the host is already known.""" await setup.async_setup_component(hass, "persistent_notification", {}) config_entry = MockConfigEntry( - domain=DOMAIN, data={"host": "2.2.2.2", "name": "any"}, + domain=DOMAIN, + data={"host": "2.2.2.2", "name": "any"}, ) config_entry.add_to_hass(hass) - config_entry_without_host = MockConfigEntry(domain=DOMAIN, data={"name": "other"},) + config_entry_without_host = MockConfigEntry( + domain=DOMAIN, + data={"name": "other"}, + ) config_entry_without_host.add_to_hass(hass) harmonyapi = _get_mock_harmonyapi(connect=True) with patch( - "homeassistant.components.harmony.util.HarmonyAPI", return_value=harmonyapi, + "homeassistant.components.harmony.util.HarmonyAPI", + return_value=harmonyapi, ): result = await hass.config_entries.flow.async_init( DOMAIN, @@ -179,7 +195,8 @@ async def test_form_cannot_connect(hass): ) with patch( - "homeassistant.components.harmony.util.HarmonyAPI", side_effect=CannotConnect, + "homeassistant.components.harmony.util.HarmonyAPI", + side_effect=CannotConnect, ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -208,7 +225,8 @@ async def test_options_flow(hass): harmony_client = _get_mock_harmonyclient() with patch( - "aioharmony.harmonyapi.HarmonyClient", return_value=harmony_client, + "aioharmony.harmonyapi.HarmonyClient", + return_value=harmony_client, ), patch("homeassistant.components.harmony.remote.HarmonyRemote.write_config_file"): config_entry.add_to_hass(hass) assert await hass.config_entries.async_setup(config_entry.entry_id) diff --git a/tests/components/hassio/conftest.py b/tests/components/hassio/conftest.py index 5768d192c8a..f52a825ca29 100644 --- a/tests/components/hassio/conftest.py +++ b/tests/components/hassio/conftest.py @@ -35,7 +35,8 @@ def hassio_stubs(hassio_env, hass, hass_client, aioclient_mock): "homeassistant.components.hassio.HassIO.update_hass_timezone", return_value={"result": "ok"}, ), patch( - "homeassistant.components.hassio.HassIO.get_info", side_effect=HassioAPIError(), + "homeassistant.components.hassio.HassIO.get_info", + side_effect=HassioAPIError(), ): hass.state = CoreState.starting hass.loop.run_until_complete(async_setup_component(hass, "hassio", {})) @@ -60,7 +61,8 @@ async def hassio_client_supervisor(hass, aiohttp_client, hassio_stubs): """Return an authenticated HTTP client.""" access_token = hass.auth.async_create_access_token(hassio_stubs) return await aiohttp_client( - hass.http.app, headers={"Authorization": f"Bearer {access_token}"}, + hass.http.app, + headers={"Authorization": f"Bearer {access_token}"}, ) diff --git a/tests/components/hassio/test_discovery.py b/tests/components/hassio/test_discovery.py index 1cfb5ed9f7b..3bb97a6662e 100644 --- a/tests/components/hassio/test_discovery.py +++ b/tests/components/hassio/test_discovery.py @@ -61,7 +61,8 @@ async def test_hassio_discovery_startup(hass, aioclient_mock, hassio_client): async def test_hassio_discovery_startup_done(hass, aioclient_mock, hassio_client): """Test startup and discovery with hass discovery.""" aioclient_mock.post( - "http://127.0.0.1/supervisor/options", json={"result": "ok", "data": {}}, + "http://127.0.0.1/supervisor/options", + json={"result": "ok", "data": {}}, ) aioclient_mock.get( "http://127.0.0.1/discovery", diff --git a/tests/components/hassio/test_init.py b/tests/components/hassio/test_init.py index 34ba638410a..56792295fec 100644 --- a/tests/components/hassio/test_init.py +++ b/tests/components/hassio/test_init.py @@ -213,7 +213,8 @@ async def test_fail_setup_without_environ_var(hass): async def test_warn_when_cannot_connect(hass, caplog): """Fail warn when we cannot connect.""" with patch.dict(os.environ, MOCK_ENVIRON), patch( - "homeassistant.components.hassio.HassIO.is_connected", return_value=None, + "homeassistant.components.hassio.HassIO.is_connected", + return_value=None, ): result = await async_setup_component(hass, "hassio", {}) assert result diff --git a/tests/components/hisense_aehw4a1/test_init.py b/tests/components/hisense_aehw4a1/test_init.py index 498e8c4c306..bf3c9d2c6a4 100644 --- a/tests/components/hisense_aehw4a1/test_init.py +++ b/tests/components/hisense_aehw4a1/test_init.py @@ -78,7 +78,8 @@ async def test_configuring_hisense_w4a1_not_creates_entry_for_device_not_found(h async def test_configuring_hisense_w4a1_not_creates_entry_for_empty_import(hass): """Test that specifying config will not create an entry.""" with patch( - "homeassistant.components.hisense_aehw4a1.async_setup_entry", return_value=True, + "homeassistant.components.hisense_aehw4a1.async_setup_entry", + return_value=True, ) as mock_setup: await async_setup_component(hass, hisense_aehw4a1.DOMAIN, {}) await hass.async_block_till_done() diff --git a/tests/components/history/test_init.py b/tests/components/history/test_init.py index e9544ce9035..c15e4431f87 100644 --- a/tests/components/history/test_init.py +++ b/tests/components/history/test_init.py @@ -257,7 +257,8 @@ class TestComponentHistory(unittest.TestCase): # will happen with encoding a native state input_state = states["media_player.test"][1] orig_last_changed = json.dumps( - process_timestamp(input_state.last_changed), cls=JSONEncoder, + process_timestamp(input_state.last_changed), + cls=JSONEncoder, ).replace('"', "") orig_state = input_state.state states["media_player.test"][1] = { diff --git a/tests/components/hlk_sw16/test_config_flow.py b/tests/components/hlk_sw16/test_config_flow.py index 6f9d5592893..7b7468047be 100644 --- a/tests/components/hlk_sw16/test_config_flow.py +++ b/tests/components/hlk_sw16/test_config_flow.py @@ -70,10 +70,12 @@ async def test_form(hass): ), patch( "homeassistant.components.hlk_sw16.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.hlk_sw16.async_setup_entry", return_value=True, + "homeassistant.components.hlk_sw16.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], conf, + result["flow_id"], + conf, ) assert result2["type"] == "create_entry" @@ -98,7 +100,10 @@ async def test_form(hass): assert result3["type"] == "form" assert result3["errors"] == {} - result4 = await hass.config_entries.flow.async_configure(result3["flow_id"], conf,) + result4 = await hass.config_entries.flow.async_configure( + result3["flow_id"], + conf, + ) assert result4["type"] == "form" assert result4["errors"] == {"base": "already_configured"} @@ -127,10 +132,12 @@ async def test_import(hass): ), patch( "homeassistant.components.hlk_sw16.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.hlk_sw16.async_setup_entry", return_value=True, + "homeassistant.components.hlk_sw16.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], conf, + result["flow_id"], + conf, ) assert result2["type"] == "create_entry" @@ -162,7 +169,8 @@ async def test_form_invalid_data(hass): return_value=mock_hlk_sw16_connection, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], conf, + result["flow_id"], + conf, ) assert result2["type"] == "form" @@ -186,7 +194,8 @@ async def test_form_cannot_connect(hass): return_value=None, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], conf, + result["flow_id"], + conf, ) assert result2["type"] == "form" diff --git a/tests/components/homeassistant/test_init.py b/tests/components/homeassistant/test_init.py index 3419aea06af..b2ca49712d1 100644 --- a/tests/components/homeassistant/test_init.py +++ b/tests/components/homeassistant/test_init.py @@ -266,7 +266,8 @@ async def test_turn_on_to_not_block_for_domains_without_service(hass): service = hass.services._services["homeassistant"]["turn_on"] with patch( - "homeassistant.core.ServiceRegistry.async_call", return_value=None, + "homeassistant.core.ServiceRegistry.async_call", + return_value=None, ) as mock_call: await service.func(service_call) @@ -290,7 +291,8 @@ async def test_entity_update(hass): await async_setup_component(hass, "homeassistant", {}) with patch( - "homeassistant.helpers.entity_component.async_update_entity", return_value=None, + "homeassistant.helpers.entity_component.async_update_entity", + return_value=None, ) as mock_update: await hass.services.async_call( "homeassistant", @@ -373,7 +375,10 @@ async def test_not_allowing_recursion(hass, caplog): for service in SERVICE_TURN_ON, SERVICE_TURN_OFF, SERVICE_TOGGLE: await hass.services.async_call( - ha.DOMAIN, service, {"entity_id": "homeassistant.light"}, blocking=True, + ha.DOMAIN, + service, + {"entity_id": "homeassistant.light"}, + blocking=True, ) assert ( f"Called service homeassistant.{service} with invalid entity IDs homeassistant.light" diff --git a/tests/components/homeassistant/triggers/test_homeassistant.py b/tests/components/homeassistant/triggers/test_homeassistant.py index d7bdfbeef3e..9272c3620af 100644 --- a/tests/components/homeassistant/triggers/test_homeassistant.py +++ b/tests/components/homeassistant/triggers/test_homeassistant.py @@ -29,7 +29,8 @@ async def test_if_fires_on_hass_start(hass): assert len(calls) == 1 with patch( - "homeassistant.config.async_hass_config_yaml", AsyncMock(return_value=config), + "homeassistant.config.async_hass_config_yaml", + AsyncMock(return_value=config), ): await hass.services.async_call( automation.DOMAIN, automation.SERVICE_RELOAD, blocking=True diff --git a/tests/components/homekit/test_config_flow.py b/tests/components/homekit/test_config_flow.py index fd3d546a507..6e4e03f2137 100644 --- a/tests/components/homekit/test_config_flow.py +++ b/tests/components/homekit/test_config_flow.py @@ -45,7 +45,8 @@ async def test_user_form(hass): return_value=12345, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"auto_start": True, "include_domains": ["light"]}, + result["flow_id"], + {"auto_start": True, "include_domains": ["light"]}, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -54,9 +55,13 @@ async def test_user_form(hass): with patch( "homeassistant.components.homekit.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.homekit.async_setup_entry", return_value=True, + "homeassistant.components.homekit.async_setup_entry", + return_value=True, ) as mock_setup_entry: - result3 = await hass.config_entries.flow.async_configure(result["flow_id"], {},) + result3 = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) assert result3["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result3["title"][:11] == "HASS Bridge" @@ -98,7 +103,8 @@ async def test_import(hass): with patch( "homeassistant.components.homekit.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.homekit.async_setup_entry", return_value=True, + "homeassistant.components.homekit.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_init( DOMAIN, @@ -142,14 +148,16 @@ async def test_options_flow_advanced(hass): assert result["step_id"] == "exclude" result2 = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={"exclude_entities": ["climate.old"]}, + result["flow_id"], + user_input={"exclude_entities": ["climate.old"]}, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM assert result2["step_id"] == "advanced" with patch("homeassistant.components.homekit.async_setup_entry", return_value=True): result3 = await hass.config_entries.options.async_configure( - result2["flow_id"], user_input={"auto_start": True, "safe_mode": True}, + result2["flow_id"], + user_input={"auto_start": True, "safe_mode": True}, ) assert result3["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY @@ -182,21 +190,24 @@ async def test_options_flow_basic(hass): assert result["step_id"] == "init" result = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={"include_domains": ["fan", "vacuum", "climate"]}, + result["flow_id"], + user_input={"include_domains": ["fan", "vacuum", "climate"]}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == "exclude" result2 = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={"exclude_entities": ["climate.old"]}, + result["flow_id"], + user_input={"exclude_entities": ["climate.old"]}, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM assert result2["step_id"] == "advanced" with patch("homeassistant.components.homekit.async_setup_entry", return_value=True): result3 = await hass.config_entries.options.async_configure( - result2["flow_id"], user_input={"safe_mode": True}, + result2["flow_id"], + user_input={"safe_mode": True}, ) assert result3["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY @@ -248,7 +259,8 @@ async def test_options_flow_with_cameras(hass): assert result2["step_id"] == "cameras" result3 = await hass.config_entries.options.async_configure( - result2["flow_id"], user_input={"camera_copy": ["camera.native_h264"]}, + result2["flow_id"], + user_input={"camera_copy": ["camera.native_h264"]}, ) assert result3["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -256,7 +268,8 @@ async def test_options_flow_with_cameras(hass): with patch("homeassistant.components.homekit.async_setup_entry", return_value=True): result4 = await hass.config_entries.options.async_configure( - result3["flow_id"], user_input={"safe_mode": True}, + result3["flow_id"], + user_input={"safe_mode": True}, ) assert result4["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY @@ -297,7 +310,8 @@ async def test_options_flow_with_cameras(hass): assert result2["step_id"] == "cameras" result3 = await hass.config_entries.options.async_configure( - result2["flow_id"], user_input={"camera_copy": []}, + result2["flow_id"], + user_input={"camera_copy": []}, ) assert result3["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -305,7 +319,8 @@ async def test_options_flow_with_cameras(hass): with patch("homeassistant.components.homekit.async_setup_entry", return_value=True): result4 = await hass.config_entries.options.async_configure( - result3["flow_id"], user_input={"safe_mode": True}, + result3["flow_id"], + user_input={"safe_mode": True}, ) assert result4["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY @@ -356,6 +371,7 @@ async def test_options_flow_blocked_when_from_yaml(hass): with patch("homeassistant.components.homekit.async_setup_entry", return_value=True): result2 = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={}, + result["flow_id"], + user_input={}, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY diff --git a/tests/components/homekit/test_get_accessories.py b/tests/components/homekit/test_get_accessories.py index 85f517f28be..9b687e5dda6 100644 --- a/tests/components/homekit/test_get_accessories.py +++ b/tests/components/homekit/test_get_accessories.py @@ -271,7 +271,8 @@ def test_type_vacuum(type_name, entity_id, state, attrs): @pytest.mark.parametrize( - "type_name, entity_id, state, attrs", [("Camera", "camera.basic", "on", {})], + "type_name, entity_id, state, attrs", + [("Camera", "camera.basic", "on", {})], ) def test_type_camera(type_name, entity_id, state, attrs): """Test if camera types are associated correctly.""" diff --git a/tests/components/homekit/test_homekit.py b/tests/components/homekit/test_homekit.py index 8e8e9a3506f..c20b2a9d9fb 100644 --- a/tests/components/homekit/test_homekit.py +++ b/tests/components/homekit/test_homekit.py @@ -917,7 +917,8 @@ async def test_raise_config_entry_not_ready(hass): entry.add_to_hass(hass) with patch( - "homeassistant.components.homekit.port_is_available", return_value=False, + "homeassistant.components.homekit.port_is_available", + return_value=False, ): assert not await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() diff --git a/tests/components/homekit/test_type_cameras.py b/tests/components/homekit/test_type_cameras.py index 118ce2d9934..6386b1d8e69 100644 --- a/tests/components/homekit/test_type_cameras.py +++ b/tests/components/homekit/test_type_cameras.py @@ -142,7 +142,14 @@ async def test_camera_stream_source_configured(hass, run_driver, events): 2, {CONF_STREAM_SOURCE: "/dev/null", CONF_SUPPORT_AUDIO: True}, ) - not_camera_acc = Switch(hass, run_driver, "Switch", entity_id, 4, {},) + not_camera_acc = Switch( + hass, + run_driver, + "Switch", + entity_id, + 4, + {}, + ) bridge = HomeBridge("hass", run_driver, "Test Bridge") bridge.add_accessory(acc) bridge.add_accessory(not_camera_acc) @@ -247,7 +254,14 @@ async def test_camera_stream_source_configured_with_failing_ffmpeg( 2, {CONF_STREAM_SOURCE: "/dev/null", CONF_SUPPORT_AUDIO: True}, ) - not_camera_acc = Switch(hass, run_driver, "Switch", entity_id, 4, {},) + not_camera_acc = Switch( + hass, + run_driver, + "Switch", + entity_id, + 4, + {}, + ) bridge = HomeBridge("hass", run_driver, "Test Bridge") bridge.add_accessory(acc) bridge.add_accessory(not_camera_acc) @@ -284,7 +298,14 @@ async def test_camera_stream_source_found(hass, run_driver, events): hass.states.async_set(entity_id, None) await hass.async_block_till_done() - acc = Camera(hass, run_driver, "Camera", entity_id, 2, {},) + acc = Camera( + hass, + run_driver, + "Camera", + entity_id, + 2, + {}, + ) await acc.run_handler() assert acc.aid == 2 @@ -327,7 +348,14 @@ async def test_camera_stream_source_fails(hass, run_driver, events): hass.states.async_set(entity_id, None) await hass.async_block_till_done() - acc = Camera(hass, run_driver, "Camera", entity_id, 2, {},) + acc = Camera( + hass, + run_driver, + "Camera", + entity_id, + 2, + {}, + ) await acc.run_handler() assert acc.aid == 2 @@ -355,7 +383,14 @@ async def test_camera_with_no_stream(hass, run_driver, events): hass.states.async_set(entity_id, None) await hass.async_block_till_done() - acc = Camera(hass, run_driver, "Camera", entity_id, 2, {},) + acc = Camera( + hass, + run_driver, + "Camera", + entity_id, + 2, + {}, + ) await acc.run_handler() assert acc.aid == 2 diff --git a/tests/components/homekit/test_type_covers.py b/tests/components/homekit/test_type_covers.py index 806aa60ee50..3eed6d05816 100644 --- a/tests/components/homekit/test_type_covers.py +++ b/tests/components/homekit/test_type_covers.py @@ -437,7 +437,10 @@ async def test_window_basic_restore(hass, hk_driver, cls, events): registry = await entity_registry.async_get_registry(hass) registry.async_get_or_create( - "cover", "generic", "1234", suggested_object_id="simple", + "cover", + "generic", + "1234", + suggested_object_id="simple", ) registry.async_get_or_create( "cover", @@ -472,7 +475,10 @@ async def test_window_restore(hass, hk_driver, cls, events): registry = await entity_registry.async_get_registry(hass) registry.async_get_or_create( - "cover", "generic", "1234", suggested_object_id="simple", + "cover", + "generic", + "1234", + suggested_object_id="simple", ) registry.async_get_or_create( "cover", diff --git a/tests/components/homekit/test_type_fans.py b/tests/components/homekit/test_type_fans.py index 6d5b0f9841b..a25567b7004 100644 --- a/tests/components/homekit/test_type_fans.py +++ b/tests/components/homekit/test_type_fans.py @@ -566,7 +566,10 @@ async def test_fan_restore(hass, hk_driver, cls, events): registry = await entity_registry.async_get_registry(hass) registry.async_get_or_create( - "fan", "generic", "1234", suggested_object_id="simple", + "fan", + "generic", + "1234", + suggested_object_id="simple", ) registry.async_get_or_create( "fan", diff --git a/tests/components/homekit/test_type_humidifiers.py b/tests/components/homekit/test_type_humidifiers.py index 34f61a5c0df..f9ac65a1942 100644 --- a/tests/components/homekit/test_type_humidifiers.py +++ b/tests/components/homekit/test_type_humidifiers.py @@ -74,7 +74,9 @@ async def test_humidifier(hass, hk_driver, events): } hass.states.async_set( - entity_id, STATE_ON, {ATTR_HUMIDITY: 47}, + entity_id, + STATE_ON, + {ATTR_HUMIDITY: 47}, ) await hass.async_block_till_done() assert acc.char_target_humidity.value == 47.0 @@ -153,7 +155,9 @@ async def test_dehumidifier(hass, hk_driver, events): } hass.states.async_set( - entity_id, STATE_ON, {ATTR_HUMIDITY: 30}, + entity_id, + STATE_ON, + {ATTR_HUMIDITY: 30}, ) await hass.async_block_till_done() assert acc.char_target_humidity.value == 30.0 @@ -162,7 +166,9 @@ async def test_dehumidifier(hass, hk_driver, events): assert acc.char_active.value == 1 hass.states.async_set( - entity_id, STATE_OFF, {ATTR_HUMIDITY: 42}, + entity_id, + STATE_OFF, + {ATTR_HUMIDITY: 42}, ) await hass.async_block_till_done() assert acc.char_target_humidity.value == 42.0 @@ -204,7 +210,9 @@ async def test_hygrostat_power_state(hass, hk_driver, events): entity_id = "humidifier.test" hass.states.async_set( - entity_id, STATE_ON, {ATTR_HUMIDITY: 43}, + entity_id, + STATE_ON, + {ATTR_HUMIDITY: 43}, ) await hass.async_block_till_done() acc = HumidifierDehumidifier( @@ -220,7 +228,9 @@ async def test_hygrostat_power_state(hass, hk_driver, events): assert acc.char_active.value == 1 hass.states.async_set( - entity_id, STATE_OFF, {ATTR_HUMIDITY: 43}, + entity_id, + STATE_OFF, + {ATTR_HUMIDITY: 43}, ) await hass.async_block_till_done() assert acc.char_current_humidifier_dehumidifier.value == 0 @@ -397,9 +407,9 @@ async def test_humidifier_as_dehumidifier(hass, hk_driver, events, caplog): assert acc.char_target_humidifier_dehumidifier.value == 1 # Set from HomeKit - char_target_humidifier_dehumidifier_iid = acc.char_target_humidifier_dehumidifier.to_HAP()[ - HAP_REPR_IID - ] + char_target_humidifier_dehumidifier_iid = ( + acc.char_target_humidifier_dehumidifier.to_HAP()[HAP_REPR_IID] + ) hk_driver.set_characteristics( { diff --git a/tests/components/homekit_controller/specific_devices/test_homeassistant_bridge.py b/tests/components/homekit_controller/specific_devices/test_homeassistant_bridge.py index e9fc9b522ea..fbdf00698f7 100644 --- a/tests/components/homekit_controller/specific_devices/test_homeassistant_bridge.py +++ b/tests/components/homekit_controller/specific_devices/test_homeassistant_bridge.py @@ -28,7 +28,11 @@ async def test_homeassistant_bridge_fan_setup(hass): assert fan.unique_id == "homekit-fan.living_room_fan-8" fan_helper = Helper( - hass, "fan.living_room_fan", pairing, accessories[0], config_entry, + hass, + "fan.living_room_fan", + pairing, + accessories[0], + config_entry, ) fan_state = await fan_helper.poll_and_get_state() diff --git a/tests/components/homekit_controller/specific_devices/test_simpleconnect_fan.py b/tests/components/homekit_controller/specific_devices/test_simpleconnect_fan.py index 9e88d9d82e9..a83a31166f4 100644 --- a/tests/components/homekit_controller/specific_devices/test_simpleconnect_fan.py +++ b/tests/components/homekit_controller/specific_devices/test_simpleconnect_fan.py @@ -26,7 +26,11 @@ async def test_simpleconnect_fan_setup(hass): assert fan.unique_id == "homekit-1234567890abcd-8" fan_helper = Helper( - hass, "fan.simpleconnect_fan_06f674", pairing, accessories[0], config_entry, + hass, + "fan.simpleconnect_fan_06f674", + pairing, + accessories[0], + config_entry, ) fan_state = await fan_helper.poll_and_get_state() diff --git a/tests/components/homekit_controller/test_fan.py b/tests/components/homekit_controller/test_fan.py index fd24f5215da..e9ebce4045b 100644 --- a/tests/components/homekit_controller/test_fan.py +++ b/tests/components/homekit_controller/test_fan.py @@ -102,7 +102,10 @@ async def test_turn_off(hass, utcnow): helper.characteristics[V1_ON].value = 1 await hass.services.async_call( - "fan", "turn_off", {"entity_id": "fan.testdevice"}, blocking=True, + "fan", + "turn_off", + {"entity_id": "fan.testdevice"}, + blocking=True, ) assert helper.characteristics[V1_ON].value == 0 @@ -255,7 +258,10 @@ async def test_v2_turn_off(hass, utcnow): helper.characteristics[V2_ACTIVE].value = 1 await hass.services.async_call( - "fan", "turn_off", {"entity_id": "fan.testdevice"}, blocking=True, + "fan", + "turn_off", + {"entity_id": "fan.testdevice"}, + blocking=True, ) assert helper.characteristics[V2_ACTIVE].value == 0 diff --git a/tests/components/homematicip_cloud/test_binary_sensor.py b/tests/components/homematicip_cloud/test_binary_sensor.py index cfde3413916..6be0036a737 100644 --- a/tests/components/homematicip_cloud/test_binary_sensor.py +++ b/tests/components/homematicip_cloud/test_binary_sensor.py @@ -31,7 +31,9 @@ from .helper import async_manipulate_test_data, get_and_check_entity_basics async def test_manually_configured_platform(hass): """Test that we do not set up an access point.""" assert await async_setup_component( - hass, BINARY_SENSOR_DOMAIN, {BINARY_SENSOR_DOMAIN: {"platform": HMIPC_DOMAIN}}, + hass, + BINARY_SENSOR_DOMAIN, + {BINARY_SENSOR_DOMAIN: {"platform": HMIPC_DOMAIN}}, ) assert not hass.data.get(HMIPC_DOMAIN) @@ -245,7 +247,10 @@ async def test_hmip_smoke_detector(hass, default_mock_hap_factory): ha_state = hass.states.get(entity_id) assert ha_state.state == STATE_ON await async_manipulate_test_data( - hass, hmip_device, "smokeDetectorAlarmType", None, + hass, + hmip_device, + "smokeDetectorAlarmType", + None, ) ha_state = hass.states.get(entity_id) assert ha_state.state == STATE_OFF diff --git a/tests/components/homematicip_cloud/test_climate.py b/tests/components/homematicip_cloud/test_climate.py index 52ca13aad62..6d5c3fb6060 100644 --- a/tests/components/homematicip_cloud/test_climate.py +++ b/tests/components/homematicip_cloud/test_climate.py @@ -382,7 +382,8 @@ async def test_hmip_heating_group_heat_with_radiator(hass, default_mock_hap_fact entity_name = "Vorzimmer" device_model = None mock_hap = await default_mock_hap_factory.async_get_mock_hap( - test_devices=["Heizkörperthermostat2"], test_groups=[entity_name], + test_devices=["Heizkörperthermostat2"], + test_groups=[entity_name], ) ha_state, hmip_device = get_and_check_entity_basics( hass, mock_hap, entity_id, entity_name, device_model diff --git a/tests/components/homematicip_cloud/test_init.py b/tests/components/homematicip_cloud/test_init.py index 5b201da8aa8..37b293a3452 100644 --- a/tests/components/homematicip_cloud/test_init.py +++ b/tests/components/homematicip_cloud/test_init.py @@ -125,7 +125,9 @@ async def test_load_entry_fails_due_to_generic_exception(hass, hmip_config_entry with patch( "homeassistant.components.homematicip_cloud.hap.AsyncHome.get_current_state", side_effect=Exception, - ), patch("homematicip.aio.connection.AsyncConnection.init",): + ), patch( + "homematicip.aio.connection.AsyncConnection.init", + ): assert await async_setup_component(hass, HMIPC_DOMAIN, {}) assert hass.data[HMIPC_DOMAIN][hmip_config_entry.unique_id] diff --git a/tests/components/http/test_forwarded.py b/tests/components/http/test_forwarded.py index 45853687f13..2946c0b383c 100644 --- a/tests/components/http/test_forwarded.py +++ b/tests/components/http/test_forwarded.py @@ -330,7 +330,8 @@ async def test_x_forwarded_proto_with_multiple_headers(aiohttp_client, caplog): @pytest.mark.parametrize( - "x_forwarded_proto", ["", ",", "https, , https", "https, https, "], + "x_forwarded_proto", + ["", ",", "https, , https", "https, https, "], ) async def test_x_forwarded_proto_empty_element( x_forwarded_proto, aiohttp_client, caplog @@ -342,7 +343,8 @@ async def test_x_forwarded_proto_empty_element( mock_api_client = await aiohttp_client(app) resp = await mock_api_client.get( - "/", headers={X_FORWARDED_FOR: "1.1.1.1", X_FORWARDED_PROTO: x_forwarded_proto}, + "/", + headers={X_FORWARDED_FOR: "1.1.1.1", X_FORWARDED_PROTO: x_forwarded_proto}, ) assert resp.status == 400 diff --git a/tests/components/hue/test_config_flow.py b/tests/components/hue/test_config_flow.py index 42a6f525319..21bb489ffe7 100644 --- a/tests/components/hue/test_config_flow.py +++ b/tests/components/hue/test_config_flow.py @@ -115,7 +115,8 @@ async def test_manual_flow_works(hass, aioclient_mock): ) with patch( - "aiohue.Bridge", return_value=bridge, + "aiohue.Bridge", + return_value=bridge, ): result = await hass.config_entries.flow.async_configure( result["flow_id"], {"host": "2.2.2.2"} @@ -148,7 +149,8 @@ async def test_manual_flow_bridge_exist(hass, aioclient_mock): ).add_to_hass(hass) with patch( - "homeassistant.components.hue.config_flow.discover_nupnp", return_value=[], + "homeassistant.components.hue.config_flow.discover_nupnp", + return_value=[], ): result = await hass.config_entries.flow.async_init( const.DOMAIN, context={"source": "user"} @@ -162,7 +164,8 @@ async def test_manual_flow_bridge_exist(hass, aioclient_mock): ) with patch( - "aiohue.Bridge", return_value=bridge, + "aiohue.Bridge", + return_value=bridge, ): result = await hass.config_entries.flow.async_configure( result["flow_id"], {"host": "2.2.2.2"} @@ -293,7 +296,9 @@ async def test_flow_link_timeout(hass): async def test_flow_link_unknown_error(hass): """Test if a unknown error happened during the linking processes.""" - mock_bridge = get_mock_bridge(mock_create_user=AsyncMock(side_effect=OSError),) + mock_bridge = get_mock_bridge( + mock_create_user=AsyncMock(side_effect=OSError), + ) with patch( "homeassistant.components.hue.config_flow.discover_nupnp", return_value=[mock_bridge], @@ -481,7 +486,9 @@ async def test_bridge_ssdp_already_configured(hass): async def test_import_with_no_config(hass): """Test importing a host without an existing config file.""" result = await hass.config_entries.flow.async_init( - const.DOMAIN, context={"source": "import"}, data={"host": "0.0.0.0"}, + const.DOMAIN, + context={"source": "import"}, + data={"host": "0.0.0.0"}, ) assert result["type"] == "form" @@ -496,12 +503,16 @@ async def test_creating_entry_removes_entries_for_same_host_or_bridge(hass): all existing entries that either have same IP or same bridge_id. """ orig_entry = MockConfigEntry( - domain="hue", data={"host": "0.0.0.0", "username": "aaaa"}, unique_id="id-1234", + domain="hue", + data={"host": "0.0.0.0", "username": "aaaa"}, + unique_id="id-1234", ) orig_entry.add_to_hass(hass) MockConfigEntry( - domain="hue", data={"host": "1.2.3.4", "username": "bbbb"}, unique_id="id-5678", + domain="hue", + data={"host": "1.2.3.4", "username": "bbbb"}, + unique_id="id-5678", ).add_to_hass(hass) assert len(hass.config_entries.async_entries("hue")) == 2 @@ -511,7 +522,8 @@ async def test_creating_entry_removes_entries_for_same_host_or_bridge(hass): ) with patch( - "aiohue.Bridge", return_value=bridge, + "aiohue.Bridge", + return_value=bridge, ): result = await hass.config_entries.flow.async_init( "hue", data={"host": "2.2.2.2"}, context={"source": "import"} @@ -614,7 +626,9 @@ async def test_ssdp_discovery_update_configuration(hass): async def test_options_flow(hass): """Test options config flow.""" entry = MockConfigEntry( - domain="hue", unique_id="aabbccddeeff", data={"host": "0.0.0.0"}, + domain="hue", + unique_id="aabbccddeeff", + data={"host": "0.0.0.0"}, ) entry.add_to_hass(hass) diff --git a/tests/components/hue/test_init.py b/tests/components/hue/test_init.py index b1dc024998e..1d6db3498f1 100644 --- a/tests/components/hue/test_init.py +++ b/tests/components/hue/test_init.py @@ -196,7 +196,9 @@ async def test_fixing_unique_id_other_ignored(hass, mock_bridge_setup): source=config_entries.SOURCE_IGNORE, ).add_to_hass(hass) entry = MockConfigEntry( - domain=hue.DOMAIN, data={"host": "0.0.0.0"}, unique_id="invalid-id", + domain=hue.DOMAIN, + data={"host": "0.0.0.0"}, + unique_id="invalid-id", ) entry.add_to_hass(hass) assert await async_setup_component(hass, hue.DOMAIN, {}) is True @@ -208,11 +210,15 @@ async def test_fixing_unique_id_other_ignored(hass, mock_bridge_setup): async def test_fixing_unique_id_other_correct(hass, mock_bridge_setup): """Test we remove config entry if another one has correct ID.""" correct_entry = MockConfigEntry( - domain=hue.DOMAIN, data={"host": "0.0.0.0"}, unique_id="mock-id", + domain=hue.DOMAIN, + data={"host": "0.0.0.0"}, + unique_id="mock-id", ) correct_entry.add_to_hass(hass) entry = MockConfigEntry( - domain=hue.DOMAIN, data={"host": "0.0.0.0"}, unique_id="invalid-id", + domain=hue.DOMAIN, + data={"host": "0.0.0.0"}, + unique_id="invalid-id", ) entry.add_to_hass(hass) assert await async_setup_component(hass, hue.DOMAIN, {}) is True diff --git a/tests/components/hunterdouglas_powerview/test_config_flow.py b/tests/components/hunterdouglas_powerview/test_config_flow.py index 383d0445a7d..37fb150ddf7 100644 --- a/tests/components/hunterdouglas_powerview/test_config_flow.py +++ b/tests/components/hunterdouglas_powerview/test_config_flow.py @@ -43,7 +43,8 @@ async def test_user_form(hass): return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": "1.2.3.4"}, + result["flow_id"], + {"host": "1.2.3.4"}, ) assert result2["type"] == "create_entry" @@ -62,7 +63,8 @@ async def test_user_form(hass): assert result3["errors"] == {} result4 = await hass.config_entries.flow.async_configure( - result3["flow_id"], {"host": "1.2.3.4"}, + result3["flow_id"], + {"host": "1.2.3.4"}, ) assert result4["type"] == "abort" @@ -175,7 +177,8 @@ async def test_form_cannot_connect(hass): return_value=mock_powerview_userdata, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": "1.2.3.4"}, + result["flow_id"], + {"host": "1.2.3.4"}, ) assert result2["type"] == "form" @@ -194,7 +197,8 @@ async def test_form_no_data(hass): return_value=mock_powerview_userdata, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": "1.2.3.4"}, + result["flow_id"], + {"host": "1.2.3.4"}, ) assert result2["type"] == "form" @@ -213,7 +217,8 @@ async def test_form_unknown_exception(hass): return_value=mock_powerview_userdata, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": "1.2.3.4"}, + result["flow_id"], + {"host": "1.2.3.4"}, ) assert result2["type"] == "form" diff --git a/tests/components/hvv_departures/test_config_flow.py b/tests/components/hvv_departures/test_config_flow.py index 3f9098abfc8..1e37ff2e021 100644 --- a/tests/components/hvv_departures/test_config_flow.py +++ b/tests/components/hvv_departures/test_config_flow.py @@ -33,11 +33,13 @@ async def test_user_flow(hass): "homeassistant.components.hvv_departures.hub.GTI.init", return_value=FIXTURE_INIT, ), patch("pygti.gti.GTI.checkName", return_value=FIXTURE_CHECK_NAME,), patch( - "pygti.gti.GTI.stationInformation", return_value=FIXTURE_STATION_INFORMATION, + "pygti.gti.GTI.stationInformation", + return_value=FIXTURE_STATION_INFORMATION, ), patch( "homeassistant.components.hvv_departures.async_setup", return_value=True ), patch( - "homeassistant.components.hvv_departures.async_setup_entry", return_value=True, + "homeassistant.components.hvv_departures.async_setup_entry", + return_value=True, ): # step: user @@ -56,14 +58,16 @@ async def test_user_flow(hass): # step: station result_station = await hass.config_entries.flow.async_configure( - result_user["flow_id"], {CONF_STATION: "Wartenau"}, + result_user["flow_id"], + {CONF_STATION: "Wartenau"}, ) assert result_station["step_id"] == "station_select" # step: station_select result_station_select = await hass.config_entries.flow.async_configure( - result_user["flow_id"], {CONF_STATION: "Wartenau"}, + result_user["flow_id"], + {CONF_STATION: "Wartenau"}, ) assert result_station_select["type"] == "create_entry" @@ -92,11 +96,13 @@ async def test_user_flow_no_results(hass): "homeassistant.components.hvv_departures.hub.GTI.init", return_value=FIXTURE_INIT, ), patch( - "pygti.gti.GTI.checkName", return_value={"returnCode": "OK", "results": []}, + "pygti.gti.GTI.checkName", + return_value={"returnCode": "OK", "results": []}, ), patch( "homeassistant.components.hvv_departures.async_setup", return_value=True ), patch( - "homeassistant.components.hvv_departures.async_setup_entry", return_value=True, + "homeassistant.components.hvv_departures.async_setup_entry", + return_value=True, ): # step: user @@ -115,7 +121,8 @@ async def test_user_flow_no_results(hass): # step: station result_station = await hass.config_entries.flow.async_configure( - result_user["flow_id"], {CONF_STATION: "non_existing_station"}, + result_user["flow_id"], + {CONF_STATION: "non_existing_station"}, ) assert result_station["step_id"] == "station" @@ -176,9 +183,11 @@ async def test_user_flow_station(hass): """Test that config flow handles empty data on step station.""" with patch( - "homeassistant.components.hvv_departures.hub.GTI.init", return_value=True, + "homeassistant.components.hvv_departures.hub.GTI.init", + return_value=True, ), patch( - "pygti.gti.GTI.checkName", return_value={"returnCode": "OK", "results": []}, + "pygti.gti.GTI.checkName", + return_value={"returnCode": "OK", "results": []}, ): # step: user @@ -197,7 +206,8 @@ async def test_user_flow_station(hass): # step: station result_station = await hass.config_entries.flow.async_configure( - result_user["flow_id"], None, + result_user["flow_id"], + None, ) assert result_station["type"] == "form" assert result_station["step_id"] == "station" @@ -207,9 +217,11 @@ async def test_user_flow_station_select(hass): """Test that config flow handles empty data on step station_select.""" with patch( - "homeassistant.components.hvv_departures.hub.GTI.init", return_value=True, + "homeassistant.components.hvv_departures.hub.GTI.init", + return_value=True, ), patch( - "pygti.gti.GTI.checkName", return_value=FIXTURE_CHECK_NAME, + "pygti.gti.GTI.checkName", + return_value=FIXTURE_CHECK_NAME, ): result_user = await hass.config_entries.flow.async_init( DOMAIN, @@ -222,12 +234,14 @@ async def test_user_flow_station_select(hass): ) result_station = await hass.config_entries.flow.async_configure( - result_user["flow_id"], {CONF_STATION: "Wartenau"}, + result_user["flow_id"], + {CONF_STATION: "Wartenau"}, ) # step: station_select result_station_select = await hass.config_entries.flow.async_configure( - result_station["flow_id"], None, + result_station["flow_id"], + None, ) assert result_station_select["type"] == "form" @@ -251,9 +265,11 @@ async def test_options_flow(hass): config_entry.add_to_hass(hass) with patch( - "homeassistant.components.hvv_departures.hub.GTI.init", return_value=True, + "homeassistant.components.hvv_departures.hub.GTI.init", + return_value=True, ), patch( - "pygti.gti.GTI.departureList", return_value=FIXTURE_DEPARTURE_LIST, + "pygti.gti.GTI.departureList", + return_value=FIXTURE_DEPARTURE_LIST, ): assert await hass.config_entries.async_setup(config_entry.entry_id) @@ -332,7 +348,8 @@ async def test_options_flow_cannot_connect(hass): config_entry.add_to_hass(hass) with patch( - "pygti.gti.GTI.departureList", side_effect=CannotConnect(), + "pygti.gti.GTI.departureList", + side_effect=CannotConnect(), ): assert await hass.config_entries.async_setup(config_entry.entry_id) diff --git a/tests/components/image_processing/test_init.py b/tests/components/image_processing/test_init.py index 72edcd7160a..c006a262e85 100644 --- a/tests/components/image_processing/test_init.py +++ b/tests/components/image_processing/test_init.py @@ -69,7 +69,8 @@ class TestImageProcessing: self.hass.stop() @patch( - "homeassistant.components.demo.camera.Path.read_bytes", return_value=b"Test", + "homeassistant.components.demo.camera.Path.read_bytes", + return_value=b"Test", ) def test_get_image_from_camera(self, mock_camera_read): """Grab an image from camera entity.""" diff --git a/tests/components/influxdb/test_init.py b/tests/components/influxdb/test_init.py index 7e2a9f5d9c3..973b21a8c89 100644 --- a/tests/components/influxdb/test_init.py +++ b/tests/components/influxdb/test_init.py @@ -41,7 +41,8 @@ def mock_batch_timeout(hass, monkeypatch): """Mock the event bus listener and the batch timeout for tests.""" hass.bus.listen = MagicMock() monkeypatch.setattr( - f"{INFLUX_PATH}.InfluxThread.batch_timeout", Mock(return_value=0), + f"{INFLUX_PATH}.InfluxThread.batch_timeout", + Mock(return_value=0), ) @@ -868,7 +869,11 @@ async def test_event_listener_default_measurement( handler_method = await _setup(hass, mock_client, config, get_write_api) state = MagicMock( - state=1, domain="fake", entity_id="fake.ok", object_id="ok", attributes={}, + state=1, + domain="fake", + entity_id="fake.ok", + object_id="ok", + attributes={}, ) event = MagicMock(data={"new_state": state}, time_fired=12345) body = [ diff --git a/tests/components/influxdb/test_sensor.py b/tests/components/influxdb/test_sensor.py index 150e378e383..633f9e891f8 100644 --- a/tests/components/influxdb/test_sensor.py +++ b/tests/components/influxdb/test_sensor.py @@ -356,7 +356,12 @@ async def test_state_matches_first_query_result_for_multiple_return( @pytest.mark.parametrize( "mock_client, config_ext, queries, set_query_mock", [ - (DEFAULT_API_VERSION, BASE_V1_CONFIG, BASE_V1_QUERY, _set_query_mock_v1,), + ( + DEFAULT_API_VERSION, + BASE_V1_CONFIG, + BASE_V1_QUERY, + _set_query_mock_v1, + ), (API_VERSION_2, BASE_V2_CONFIG, BASE_V2_QUERY, _set_query_mock_v2), ], indirect=["mock_client"], @@ -577,7 +582,12 @@ async def test_connection_error_at_startup( indirect=["mock_client"], ) async def test_data_repository_not_found( - hass, caplog, mock_client, config_ext, queries, set_query_mock, + hass, + caplog, + mock_client, + config_ext, + queries, + set_query_mock, ): """Test sensor is not setup when bucket not available.""" set_query_mock(mock_client) diff --git a/tests/components/insteon/test_config_flow.py b/tests/components/insteon/test_config_flow.py index 9b063d038eb..9252f5edad3 100644 --- a/tests/components/insteon/test_config_flow.py +++ b/tests/components/insteon/test_config_flow.py @@ -130,7 +130,8 @@ async def _init_form(hass, modem_type): assert result["errors"] == {} result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {MODEM_TYPE: modem_type}, + result["flow_id"], + {MODEM_TYPE: modem_type}, ) return result2 @@ -140,7 +141,8 @@ async def _device_form(hass, flow_id, connection, user_input): with patch(PATCH_CONNECTION, new=connection,), patch( PATCH_ASYNC_SETUP, return_value=True ) as mock_setup, patch( - PATCH_ASYNC_SETUP_ENTRY, return_value=True, + PATCH_ASYNC_SETUP_ENTRY, + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_configure(flow_id, user_input) return result, mock_setup, mock_setup_entry @@ -397,7 +399,8 @@ async def _options_init_form(hass, entry_id, step): assert result["step_id"] == "init" result2 = await hass.config_entries.options.async_configure( - result["flow_id"], {step: True}, + result["flow_id"], + {step: True}, ) return result2 @@ -673,7 +676,8 @@ async def test_options_dup_selection(hass: HomeAssistantType): assert result["step_id"] == "init" result2 = await hass.config_entries.options.async_configure( - result["flow_id"], {STEP_ADD_OVERRIDE: True, STEP_ADD_X10: True}, + result["flow_id"], + {STEP_ADD_OVERRIDE: True, STEP_ADD_X10: True}, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM assert result2["errors"] == {"base": "select_single"} diff --git a/tests/components/ipma/test_config_flow.py b/tests/components/ipma/test_config_flow.py index b3b8968f451..b45c4e89529 100644 --- a/tests/components/ipma/test_config_flow.py +++ b/tests/components/ipma/test_config_flow.py @@ -79,7 +79,9 @@ async def test_flow_entry_created_from_user_input(): with patch( "homeassistant.components.ipma.config_flow.IpmaFlowHandler._show_config_form" ) as config_form, patch.object( - flow.hass.config_entries, "async_entries", return_value=[], + flow.hass.config_entries, + "async_entries", + return_value=[], ) as config_entries: result = await flow.async_step_user(user_input=test_data) diff --git a/tests/components/ipp/test_config_flow.py b/tests/components/ipp/test_config_flow.py index 7133bf3cde7..19ee2f73231 100644 --- a/tests/components/ipp/test_config_flow.py +++ b/tests/components/ipp/test_config_flow.py @@ -24,7 +24,8 @@ from tests.test_util.aiohttp import AiohttpClientMocker async def test_show_user_form(hass: HomeAssistant) -> None: """Test that the user set up form is served.""" result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, + DOMAIN, + context={"source": SOURCE_USER}, ) assert result["step_id"] == "user" @@ -39,7 +40,9 @@ async def test_show_zeroconf_form( discovery_info = MOCK_ZEROCONF_IPP_SERVICE_INFO.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info, + DOMAIN, + context={"source": SOURCE_ZEROCONF}, + data=discovery_info, ) assert result["step_id"] == "zeroconf_confirm" @@ -55,7 +58,9 @@ async def test_connection_error( user_input = MOCK_USER_INPUT.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data=user_input, + DOMAIN, + context={"source": SOURCE_USER}, + data=user_input, ) assert result["step_id"] == "user" @@ -71,7 +76,9 @@ async def test_zeroconf_connection_error( discovery_info = MOCK_ZEROCONF_IPP_SERVICE_INFO.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info, + DOMAIN, + context={"source": SOURCE_ZEROCONF}, + data=discovery_info, ) assert result["type"] == RESULT_TYPE_ABORT @@ -101,7 +108,9 @@ async def test_user_connection_upgrade_required( user_input = MOCK_USER_INPUT.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data=user_input, + DOMAIN, + context={"source": SOURCE_USER}, + data=user_input, ) assert result["step_id"] == "user" @@ -117,7 +126,9 @@ async def test_zeroconf_connection_upgrade_required( discovery_info = MOCK_ZEROCONF_IPP_SERVICE_INFO.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info, + DOMAIN, + context={"source": SOURCE_ZEROCONF}, + data=discovery_info, ) assert result["type"] == RESULT_TYPE_ABORT @@ -132,7 +143,9 @@ async def test_user_parse_error( user_input = MOCK_USER_INPUT.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data=user_input, + DOMAIN, + context={"source": SOURCE_USER}, + data=user_input, ) assert result["type"] == RESULT_TYPE_ABORT @@ -147,7 +160,9 @@ async def test_zeroconf_parse_error( discovery_info = MOCK_ZEROCONF_IPP_SERVICE_INFO.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info, + DOMAIN, + context={"source": SOURCE_ZEROCONF}, + data=discovery_info, ) assert result["type"] == RESULT_TYPE_ABORT @@ -162,7 +177,9 @@ async def test_user_ipp_error( user_input = MOCK_USER_INPUT.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data=user_input, + DOMAIN, + context={"source": SOURCE_USER}, + data=user_input, ) assert result["type"] == RESULT_TYPE_ABORT @@ -177,7 +194,9 @@ async def test_zeroconf_ipp_error( discovery_info = MOCK_ZEROCONF_IPP_SERVICE_INFO.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info, + DOMAIN, + context={"source": SOURCE_ZEROCONF}, + data=discovery_info, ) assert result["type"] == RESULT_TYPE_ABORT @@ -192,7 +211,9 @@ async def test_user_ipp_version_error( user_input = {**MOCK_USER_INPUT} result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data=user_input, + DOMAIN, + context={"source": SOURCE_USER}, + data=user_input, ) assert result["type"] == RESULT_TYPE_ABORT @@ -207,7 +228,9 @@ async def test_zeroconf_ipp_version_error( discovery_info = {**MOCK_ZEROCONF_IPP_SERVICE_INFO} result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info, + DOMAIN, + context={"source": SOURCE_ZEROCONF}, + data=discovery_info, ) assert result["type"] == RESULT_TYPE_ABORT @@ -222,7 +245,9 @@ async def test_user_device_exists_abort( user_input = MOCK_USER_INPUT.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data=user_input, + DOMAIN, + context={"source": SOURCE_USER}, + data=user_input, ) assert result["type"] == RESULT_TYPE_ABORT @@ -237,7 +262,9 @@ async def test_zeroconf_device_exists_abort( discovery_info = MOCK_ZEROCONF_IPP_SERVICE_INFO.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info, + DOMAIN, + context={"source": SOURCE_ZEROCONF}, + data=discovery_info, ) assert result["type"] == RESULT_TYPE_ABORT @@ -258,7 +285,9 @@ async def test_zeroconf_with_uuid_device_exists_abort( }, } result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info, + DOMAIN, + context={"source": SOURCE_ZEROCONF}, + data=discovery_info, ) assert result["type"] == RESULT_TYPE_ABORT @@ -276,7 +305,9 @@ async def test_zeroconf_empty_unique_id( "properties": {**MOCK_ZEROCONF_IPP_SERVICE_INFO["properties"], "UUID": ""}, } result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info, + DOMAIN, + context={"source": SOURCE_ZEROCONF}, + data=discovery_info, ) assert result["type"] == RESULT_TYPE_FORM @@ -290,7 +321,9 @@ async def test_zeroconf_no_unique_id( discovery_info = MOCK_ZEROCONF_IPP_SERVICE_INFO.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info, + DOMAIN, + context={"source": SOURCE_ZEROCONF}, + data=discovery_info, ) assert result["type"] == RESULT_TYPE_FORM @@ -303,7 +336,8 @@ async def test_full_user_flow_implementation( mock_connection(aioclient_mock) result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, + DOMAIN, + context={"source": SOURCE_USER}, ) assert result["step_id"] == "user" @@ -336,7 +370,9 @@ async def test_full_zeroconf_flow_implementation( discovery_info = MOCK_ZEROCONF_IPP_SERVICE_INFO.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info, + DOMAIN, + context={"source": SOURCE_ZEROCONF}, + data=discovery_info, ) assert result["step_id"] == "zeroconf_confirm" @@ -370,7 +406,9 @@ async def test_full_zeroconf_tls_flow_implementation( discovery_info = MOCK_ZEROCONF_IPPS_SERVICE_INFO.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info, + DOMAIN, + context={"source": SOURCE_ZEROCONF}, + data=discovery_info, ) assert result["step_id"] == "zeroconf_confirm" diff --git a/tests/components/islamic_prayer_times/test_config_flow.py b/tests/components/islamic_prayer_times/test_config_flow.py index 204075ecb8c..4ffd6e4f25d 100644 --- a/tests/components/islamic_prayer_times/test_config_flow.py +++ b/tests/components/islamic_prayer_times/test_config_flow.py @@ -72,7 +72,11 @@ async def test_import(hass): async def test_integration_already_configured(hass): """Test integration is already configured.""" - entry = MockConfigEntry(domain=DOMAIN, data={}, options={},) + entry = MockConfigEntry( + domain=DOMAIN, + data={}, + options={}, + ) entry.add_to_hass(hass) result = await hass.config_entries.flow.async_init( islamic_prayer_times.DOMAIN, context={"source": "user"} diff --git a/tests/components/islamic_prayer_times/test_init.py b/tests/components/islamic_prayer_times/test_init.py index 984bbbf7c75..fd0de854056 100644 --- a/tests/components/islamic_prayer_times/test_init.py +++ b/tests/components/islamic_prayer_times/test_init.py @@ -39,7 +39,10 @@ async def test_setup_with_config(hass, legacy_patchable_time): async def test_successful_config_entry(hass, legacy_patchable_time): """Test that Islamic Prayer Times is configured successfully.""" - entry = MockConfigEntry(domain=islamic_prayer_times.DOMAIN, data={},) + entry = MockConfigEntry( + domain=islamic_prayer_times.DOMAIN, + data={}, + ) entry.add_to_hass(hass) with patch( @@ -58,7 +61,10 @@ async def test_successful_config_entry(hass, legacy_patchable_time): async def test_setup_failed(hass, legacy_patchable_time): """Test Islamic Prayer Times failed due to an error.""" - entry = MockConfigEntry(domain=islamic_prayer_times.DOMAIN, data={},) + entry = MockConfigEntry( + domain=islamic_prayer_times.DOMAIN, + data={}, + ) entry.add_to_hass(hass) # test request error raising ConfigEntryNotReady @@ -73,7 +79,10 @@ async def test_setup_failed(hass, legacy_patchable_time): async def test_unload_entry(hass, legacy_patchable_time): """Test removing Islamic Prayer Times.""" - entry = MockConfigEntry(domain=islamic_prayer_times.DOMAIN, data={},) + entry = MockConfigEntry( + domain=islamic_prayer_times.DOMAIN, + data={}, + ) entry.add_to_hass(hass) with patch( diff --git a/tests/components/isy994/test_config_flow.py b/tests/components/isy994/test_config_flow.py index 55311494d30..cbbc7427f9f 100644 --- a/tests/components/isy994/test_config_flow.py +++ b/tests/components/isy994/test_config_flow.py @@ -83,13 +83,15 @@ async def test_form(hass: HomeAssistantType): ) as mock_connection_class, patch( PATCH_ASYNC_SETUP, return_value=True ) as mock_setup, patch( - PATCH_ASYNC_SETUP_ENTRY, return_value=True, + PATCH_ASYNC_SETUP_ENTRY, + return_value=True, ) as mock_setup_entry: isy_conn = mock_connection_class.return_value isy_conn.get_config.return_value = None mock_config_class.return_value = MOCK_VALIDATED_RESPONSE result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], MOCK_USER_INPUT, + result["flow_id"], + MOCK_USER_INPUT, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result2["title"] == f"{MOCK_DEVICE_NAME} ({MOCK_HOSTNAME})" @@ -126,10 +128,12 @@ async def test_form_invalid_auth(hass: HomeAssistantType): DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch(PATCH_CONFIGURATION), patch( - PATCH_CONNECTION, side_effect=ValueError("PyISY could not connect to the ISY."), + PATCH_CONNECTION, + side_effect=ValueError("PyISY could not connect to the ISY."), ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], MOCK_USER_INPUT, + result["flow_id"], + MOCK_USER_INPUT, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -142,10 +146,12 @@ async def test_form_cannot_connect(hass: HomeAssistantType): DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch(PATCH_CONFIGURATION), patch( - PATCH_CONNECTION, side_effect=CannotConnect, + PATCH_CONNECTION, + side_effect=CannotConnect, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], MOCK_USER_INPUT, + result["flow_id"], + MOCK_USER_INPUT, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -169,7 +175,8 @@ async def test_form_existing_config_entry(hass: HomeAssistantType): isy_conn.get_config.return_value = None mock_config_class.return_value = MOCK_VALIDATED_RESPONSE result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], MOCK_USER_INPUT, + result["flow_id"], + MOCK_USER_INPUT, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_ABORT @@ -179,13 +186,16 @@ async def test_import_flow_some_fields(hass: HomeAssistantType) -> None: with patch(PATCH_CONFIGURATION) as mock_config_class, patch( PATCH_CONNECTION ) as mock_connection_class, patch(PATCH_ASYNC_SETUP, return_value=True), patch( - PATCH_ASYNC_SETUP_ENTRY, return_value=True, + PATCH_ASYNC_SETUP_ENTRY, + return_value=True, ): isy_conn = mock_connection_class.return_value isy_conn.get_config.return_value = None mock_config_class.return_value = MOCK_VALIDATED_RESPONSE result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=MOCK_IMPORT_BASIC_CONFIG, + DOMAIN, + context={"source": SOURCE_IMPORT}, + data=MOCK_IMPORT_BASIC_CONFIG, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY @@ -200,13 +210,16 @@ async def test_import_flow_with_https(hass: HomeAssistantType) -> None: with patch(PATCH_CONFIGURATION) as mock_config_class, patch( PATCH_CONNECTION ) as mock_connection_class, patch(PATCH_ASYNC_SETUP, return_value=True), patch( - PATCH_ASYNC_SETUP_ENTRY, return_value=True, + PATCH_ASYNC_SETUP_ENTRY, + return_value=True, ): isy_conn = mock_connection_class.return_value isy_conn.get_config.return_value = None mock_config_class.return_value = MOCK_VALIDATED_RESPONSE result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=MOCK_IMPORT_WITH_SSL, + DOMAIN, + context={"source": SOURCE_IMPORT}, + data=MOCK_IMPORT_WITH_SSL, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY @@ -220,13 +233,16 @@ async def test_import_flow_all_fields(hass: HomeAssistantType) -> None: with patch(PATCH_CONFIGURATION) as mock_config_class, patch( PATCH_CONNECTION ) as mock_connection_class, patch(PATCH_ASYNC_SETUP, return_value=True), patch( - PATCH_ASYNC_SETUP_ENTRY, return_value=True, + PATCH_ASYNC_SETUP_ENTRY, + return_value=True, ): isy_conn = mock_connection_class.return_value isy_conn.get_config.return_value = None mock_config_class.return_value = MOCK_VALIDATED_RESPONSE result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=MOCK_IMPORT_FULL_CONFIG, + DOMAIN, + context={"source": SOURCE_IMPORT}, + data=MOCK_IMPORT_FULL_CONFIG, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY @@ -284,13 +300,15 @@ async def test_form_ssdp(hass: HomeAssistantType): ) as mock_connection_class, patch( PATCH_ASYNC_SETUP, return_value=True ) as mock_setup, patch( - PATCH_ASYNC_SETUP_ENTRY, return_value=True, + PATCH_ASYNC_SETUP_ENTRY, + return_value=True, ) as mock_setup_entry: isy_conn = mock_connection_class.return_value isy_conn.get_config.return_value = None mock_config_class.return_value = MOCK_VALIDATED_RESPONSE result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], MOCK_USER_INPUT, + result["flow_id"], + MOCK_USER_INPUT, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY diff --git a/tests/components/izone/test_config_flow.py b/tests/components/izone/test_config_flow.py index 72b80e75bcf..df5ec18db8a 100644 --- a/tests/components/izone/test_config_flow.py +++ b/tests/components/izone/test_config_flow.py @@ -57,7 +57,8 @@ async def test_found(hass, mock_disco): mock_disco.pi_disco.controllers["blah"] = object() with patch( - "homeassistant.components.izone.climate.async_setup_entry", return_value=True, + "homeassistant.components.izone.climate.async_setup_entry", + return_value=True, ) as mock_setup, patch( "homeassistant.components.izone.config_flow.async_start_discovery_service" ) as start_disco, patch( diff --git a/tests/components/kodi/test_config_flow.py b/tests/components/kodi/test_config_flow.py index 6ea2ba9d283..4fd61ede8ba 100644 --- a/tests/components/kodi/test_config_flow.py +++ b/tests/components/kodi/test_config_flow.py @@ -39,14 +39,16 @@ async def user_flow(hass): async def test_user_flow(hass, user_flow): """Test a successful user initiated flow.""" with patch( - "homeassistant.components.kodi.config_flow.Kodi.ping", return_value=True, + "homeassistant.components.kodi.config_flow.Kodi.ping", + return_value=True, ), patch( "homeassistant.components.kodi.config_flow.get_kodi_connection", return_value=MockConnection(), ), patch( "homeassistant.components.kodi.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.kodi.async_setup_entry", return_value=True, + "homeassistant.components.kodi.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST) @@ -82,14 +84,16 @@ async def test_form_valid_auth(hass, user_flow): assert result["errors"] == {} with patch( - "homeassistant.components.kodi.config_flow.Kodi.ping", return_value=True, + "homeassistant.components.kodi.config_flow.Kodi.ping", + return_value=True, ), patch( "homeassistant.components.kodi.config_flow.get_kodi_connection", return_value=MockConnection(), ), patch( "homeassistant.components.kodi.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.kodi.async_setup_entry", return_value=True, + "homeassistant.components.kodi.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_configure( result["flow_id"], TEST_CREDENTIALS @@ -113,9 +117,12 @@ async def test_form_valid_auth(hass, user_flow): async def test_form_valid_ws_port(hass, user_flow): """Test we handle valid websocket port.""" with patch( - "homeassistant.components.kodi.config_flow.Kodi.ping", return_value=True, + "homeassistant.components.kodi.config_flow.Kodi.ping", + return_value=True, ), patch.object( - MockWSConnection, "connect", AsyncMock(side_effect=CannotConnectError), + MockWSConnection, + "connect", + AsyncMock(side_effect=CannotConnectError), ), patch( "homeassistant.components.kodi.config_flow.get_kodi_connection", new=get_kodi_connection, @@ -127,14 +134,16 @@ async def test_form_valid_ws_port(hass, user_flow): assert result["errors"] == {} with patch( - "homeassistant.components.kodi.config_flow.Kodi.ping", return_value=True, + "homeassistant.components.kodi.config_flow.Kodi.ping", + return_value=True, ), patch( "homeassistant.components.kodi.config_flow.get_kodi_connection", return_value=MockConnection(), ), patch( "homeassistant.components.kodi.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.kodi.async_setup_entry", return_value=True, + "homeassistant.components.kodi.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_configure( result["flow_id"], TEST_WS_PORT @@ -202,7 +211,8 @@ async def test_form_invalid_auth(hass, user_flow): assert result["errors"] == {"base": "cannot_connect"} with patch( - "homeassistant.components.kodi.config_flow.Kodi.ping", side_effect=Exception, + "homeassistant.components.kodi.config_flow.Kodi.ping", + side_effect=Exception, ), patch( "homeassistant.components.kodi.config_flow.get_kodi_connection", return_value=MockConnection(), @@ -216,9 +226,12 @@ async def test_form_invalid_auth(hass, user_flow): assert result["errors"] == {"base": "unknown"} with patch( - "homeassistant.components.kodi.config_flow.Kodi.ping", return_value=True, + "homeassistant.components.kodi.config_flow.Kodi.ping", + return_value=True, ), patch.object( - MockWSConnection, "connect", AsyncMock(side_effect=CannotConnectError), + MockWSConnection, + "connect", + AsyncMock(side_effect=CannotConnectError), ), patch( "homeassistant.components.kodi.config_flow.get_kodi_connection", new=get_kodi_connection, @@ -251,7 +264,8 @@ async def test_form_cannot_connect_http(hass, user_flow): async def test_form_exception_http(hass, user_flow): """Test we handle generic exception over HTTP.""" with patch( - "homeassistant.components.kodi.config_flow.Kodi.ping", side_effect=Exception, + "homeassistant.components.kodi.config_flow.Kodi.ping", + side_effect=Exception, ), patch( "homeassistant.components.kodi.config_flow.get_kodi_connection", return_value=MockConnection(), @@ -266,9 +280,12 @@ async def test_form_exception_http(hass, user_flow): async def test_form_cannot_connect_ws(hass, user_flow): """Test we handle cannot connect over WebSocket error.""" with patch( - "homeassistant.components.kodi.config_flow.Kodi.ping", return_value=True, + "homeassistant.components.kodi.config_flow.Kodi.ping", + return_value=True, ), patch.object( - MockWSConnection, "connect", AsyncMock(side_effect=CannotConnectError), + MockWSConnection, + "connect", + AsyncMock(side_effect=CannotConnectError), ), patch( "homeassistant.components.kodi.config_flow.get_kodi_connection", new=get_kodi_connection, @@ -280,7 +297,8 @@ async def test_form_cannot_connect_ws(hass, user_flow): assert result["errors"] == {} with patch( - "homeassistant.components.kodi.config_flow.Kodi.ping", return_value=True, + "homeassistant.components.kodi.config_flow.Kodi.ping", + return_value=True, ), patch.object( MockWSConnection, "connected", new_callable=PropertyMock(return_value=False) ), patch( @@ -314,9 +332,12 @@ async def test_form_cannot_connect_ws(hass, user_flow): async def test_form_exception_ws(hass, user_flow): """Test we handle generic exception over WebSocket.""" with patch( - "homeassistant.components.kodi.config_flow.Kodi.ping", return_value=True, + "homeassistant.components.kodi.config_flow.Kodi.ping", + return_value=True, ), patch.object( - MockWSConnection, "connect", AsyncMock(side_effect=CannotConnectError), + MockWSConnection, + "connect", + AsyncMock(side_effect=CannotConnectError), ), patch( "homeassistant.components.kodi.config_flow.get_kodi_connection", new=get_kodi_connection, @@ -328,7 +349,8 @@ async def test_form_exception_ws(hass, user_flow): assert result["errors"] == {} with patch( - "homeassistant.components.kodi.config_flow.Kodi.ping", return_value=True, + "homeassistant.components.kodi.config_flow.Kodi.ping", + return_value=True, ), patch.object( MockWSConnection, "connect", AsyncMock(side_effect=Exception) ), patch( @@ -347,7 +369,8 @@ async def test_form_exception_ws(hass, user_flow): async def test_discovery(hass): """Test discovery flow works.""" with patch( - "homeassistant.components.kodi.config_flow.Kodi.ping", return_value=True, + "homeassistant.components.kodi.config_flow.Kodi.ping", + return_value=True, ), patch( "homeassistant.components.kodi.config_flow.get_kodi_connection", return_value=MockConnection(), @@ -362,7 +385,8 @@ async def test_discovery(hass): with patch( "homeassistant.components.kodi.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.kodi.async_setup_entry", return_value=True, + "homeassistant.components.kodi.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_configure( flow_id=result["flow_id"], user_input={} @@ -404,9 +428,12 @@ async def test_discovery_cannot_connect_http(hass): async def test_discovery_cannot_connect_ws(hass): """Test discovery aborts if cannot connect to websocket.""" with patch( - "homeassistant.components.kodi.config_flow.Kodi.ping", return_value=True, + "homeassistant.components.kodi.config_flow.Kodi.ping", + return_value=True, ), patch.object( - MockWSConnection, "connect", AsyncMock(side_effect=CannotConnectError), + MockWSConnection, + "connect", + AsyncMock(side_effect=CannotConnectError), ), patch( "homeassistant.components.kodi.config_flow.get_kodi_connection", new=get_kodi_connection, @@ -423,7 +450,8 @@ async def test_discovery_cannot_connect_ws(hass): async def test_discovery_exception_http(hass, user_flow): """Test we handle generic exception during discovery validation.""" with patch( - "homeassistant.components.kodi.config_flow.Kodi.ping", side_effect=Exception, + "homeassistant.components.kodi.config_flow.Kodi.ping", + side_effect=Exception, ), patch( "homeassistant.components.kodi.config_flow.get_kodi_connection", return_value=MockConnection(), @@ -457,7 +485,8 @@ async def test_discovery_invalid_auth(hass): async def test_discovery_duplicate_data(hass): """Test discovery aborts if same mDNS packet arrives.""" with patch( - "homeassistant.components.kodi.config_flow.Kodi.ping", return_value=True, + "homeassistant.components.kodi.config_flow.Kodi.ping", + return_value=True, ), patch( "homeassistant.components.kodi.config_flow.get_kodi_connection", return_value=MockConnection(), @@ -502,17 +531,21 @@ async def test_discovery_updates_unique_id(hass): async def test_form_import(hass): """Test we get the form with import source.""" with patch( - "homeassistant.components.kodi.config_flow.Kodi.ping", return_value=True, + "homeassistant.components.kodi.config_flow.Kodi.ping", + return_value=True, ), patch( "homeassistant.components.kodi.config_flow.get_kodi_connection", return_value=MockConnection(), ), patch( "homeassistant.components.kodi.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.kodi.async_setup_entry", return_value=True, + "homeassistant.components.kodi.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}, data=TEST_IMPORT, + DOMAIN, + context={"source": config_entries.SOURCE_IMPORT}, + data=TEST_IMPORT, ) assert result["type"] == "create_entry" @@ -534,7 +567,9 @@ async def test_form_import_invalid_auth(hass): return_value=MockConnection(), ): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=TEST_IMPORT, + DOMAIN, + context={"source": config_entries.SOURCE_IMPORT}, + data=TEST_IMPORT, ) assert result["type"] == "abort" @@ -551,7 +586,9 @@ async def test_form_import_cannot_connect(hass): return_value=MockConnection(), ): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=TEST_IMPORT, + DOMAIN, + context={"source": config_entries.SOURCE_IMPORT}, + data=TEST_IMPORT, ) assert result["type"] == "abort" @@ -561,13 +598,16 @@ async def test_form_import_cannot_connect(hass): async def test_form_import_exception(hass): """Test we handle unknown exception on import.""" with patch( - "homeassistant.components.kodi.config_flow.Kodi.ping", side_effect=Exception, + "homeassistant.components.kodi.config_flow.Kodi.ping", + side_effect=Exception, ), patch( "homeassistant.components.kodi.config_flow.get_kodi_connection", return_value=MockConnection(), ): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=TEST_IMPORT, + DOMAIN, + context={"source": config_entries.SOURCE_IMPORT}, + data=TEST_IMPORT, ) assert result["type"] == "abort" diff --git a/tests/components/kodi/test_device_trigger.py b/tests/components/kodi/test_device_trigger.py index f091343d8a3..5819f2128c8 100644 --- a/tests/components/kodi/test_device_trigger.py +++ b/tests/components/kodi/test_device_trigger.py @@ -48,7 +48,8 @@ async def test_get_triggers(hass, device_reg, entity_reg): config_entry = MockConfigEntry(domain=DOMAIN, data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( - config_entry_id=config_entry.entry_id, identifiers={(DOMAIN, "host", 1234)}, + config_entry_id=config_entry.entry_id, + identifiers={(DOMAIN, "host", 1234)}, ) entity_reg.async_get_or_create(MP_DOMAIN, DOMAIN, "5678", device_id=device_entry.id) expected_triggers = [ @@ -113,7 +114,10 @@ async def test_if_fires_on_state_change(hass, calls, kodi_media_player): ) await hass.services.async_call( - MP_DOMAIN, "turn_on", {"entity_id": kodi_media_player}, blocking=True, + MP_DOMAIN, + "turn_on", + {"entity_id": kodi_media_player}, + blocking=True, ) await hass.async_block_till_done() @@ -121,7 +125,10 @@ async def test_if_fires_on_state_change(hass, calls, kodi_media_player): assert calls[0].data["some"] == f"turn_on - {kodi_media_player}" await hass.services.async_call( - MP_DOMAIN, "turn_off", {"entity_id": kodi_media_player}, blocking=True, + MP_DOMAIN, + "turn_off", + {"entity_id": kodi_media_player}, + blocking=True, ) await hass.async_block_till_done() diff --git a/tests/components/konnected/test_config_flow.py b/tests/components/konnected/test_config_flow.py index 62a159538a0..dfd4600f1fb 100644 --- a/tests/components/konnected/test_config_flow.py +++ b/tests/components/konnected/test_config_flow.py @@ -1108,7 +1108,8 @@ async def test_option_flow_import(hass, mock_panel): assert schema["8"] == "Disabled" result = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={}, + result["flow_id"], + user_input={}, ) assert result["type"] == "form" assert result["step_id"] == "options_binary" @@ -1129,7 +1130,8 @@ async def test_option_flow_import(hass, mock_panel): assert schema["type"] == "ds18b20" assert schema["name"] == "temper" result = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={"type": "dht"}, + result["flow_id"], + user_input={"type": "dht"}, ) assert result["type"] == "form" assert result["step_id"] == "options_switch" diff --git a/tests/components/konnected/test_init.py b/tests/components/konnected/test_init.py index d36b937d3c3..c198812a82b 100644 --- a/tests/components/konnected/test_init.py +++ b/tests/components/konnected/test_init.py @@ -387,7 +387,8 @@ async def test_config_passed_to_config_entry(hass): async def test_unload_entry(hass, mock_panel): """Test being able to unload an entry.""" await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) entry = MockConfigEntry( domain=konnected.DOMAIN, data={konnected.CONF_ID: "aabbccddeeff"} @@ -570,7 +571,8 @@ async def test_api(hass, aiohttp_client, mock_panel): async def test_state_updates_zone(hass, aiohttp_client, mock_panel): """Test callback view.""" await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) device_config = config_flow.CONFIG_ENTRY_SCHEMA( @@ -720,7 +722,8 @@ async def test_state_updates_zone(hass, aiohttp_client, mock_panel): async def test_state_updates_pin(hass, aiohttp_client, mock_panel): """Test callback view.""" await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) device_config = config_flow.CONFIG_ENTRY_SCHEMA( @@ -777,7 +780,11 @@ async def test_state_updates_pin(hass, aiohttp_client, mock_panel): entry.add_to_hass(hass) # Add empty data field to ensure we process it correctly (possible if entry is ignored) - entry = MockConfigEntry(domain="konnected", title="Konnected Alarm Panel", data={},) + entry = MockConfigEntry( + domain="konnected", + title="Konnected Alarm Panel", + data={}, + ) entry.add_to_hass(hass) assert ( diff --git a/tests/components/light/test_device_action.py b/tests/components/light/test_device_action.py index 1f3f0c22bd0..aeedde82af5 100644 --- a/tests/components/light/test_device_action.py +++ b/tests/components/light/test_device_action.py @@ -107,7 +107,10 @@ async def test_get_action_capabilities(hass, device_reg, entity_reg): connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")}, ) entity_reg.async_get_or_create( - DOMAIN, "test", "5678", device_id=device_entry.id, + DOMAIN, + "test", + "5678", + device_id=device_entry.id, ) actions = await async_get_device_automations(hass, "action", device_entry.id) diff --git a/tests/components/light/test_init.py b/tests/components/light/test_init.py index 1660ec422f3..a3f24bef3c9 100644 --- a/tests/components/light/test_init.py +++ b/tests/components/light/test_init.py @@ -589,28 +589,40 @@ async def test_light_brightness_pct_conversion(hass): assert state.attributes["brightness"] == 100 await hass.services.async_call( - "light", "turn_on", {"entity_id": entity.entity_id, "brightness_pct": 1}, True, + "light", + "turn_on", + {"entity_id": entity.entity_id, "brightness_pct": 1}, + True, ) _, data = entity.last_call("turn_on") assert data["brightness"] == 3, data await hass.services.async_call( - "light", "turn_on", {"entity_id": entity.entity_id, "brightness_pct": 2}, True, + "light", + "turn_on", + {"entity_id": entity.entity_id, "brightness_pct": 2}, + True, ) _, data = entity.last_call("turn_on") assert data["brightness"] == 5, data await hass.services.async_call( - "light", "turn_on", {"entity_id": entity.entity_id, "brightness_pct": 50}, True, + "light", + "turn_on", + {"entity_id": entity.entity_id, "brightness_pct": 50}, + True, ) _, data = entity.last_call("turn_on") assert data["brightness"] == 128, data await hass.services.async_call( - "light", "turn_on", {"entity_id": entity.entity_id, "brightness_pct": 99}, True, + "light", + "turn_on", + {"entity_id": entity.entity_id, "brightness_pct": 99}, + True, ) _, data = entity.last_call("turn_on") diff --git a/tests/components/local_ip/test_config_flow.py b/tests/components/local_ip/test_config_flow.py index f6b3ebf6c8e..e3a9ecd9ef8 100644 --- a/tests/components/local_ip/test_config_flow.py +++ b/tests/components/local_ip/test_config_flow.py @@ -23,7 +23,10 @@ async def test_config_flow(hass): async def test_already_setup(hass): """Test we abort if already setup.""" - MockConfigEntry(domain=DOMAIN, data={},).add_to_hass(hass) + MockConfigEntry( + domain=DOMAIN, + data={}, + ).add_to_hass(hass) # Should fail, same NAME result = await hass.config_entries.flow.async_init( diff --git a/tests/components/locative/test_init.py b/tests/components/locative/test_init.py index 0f3d17c9b59..2fa68778f7e 100644 --- a/tests/components/locative/test_init.py +++ b/tests/components/locative/test_init.py @@ -35,7 +35,8 @@ async def locative_client(loop, hass, hass_client): async def webhook_id(hass, locative_client): """Initialize the Geofency component and get the webhook_id.""" await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) result = await hass.config_entries.flow.async_init( "locative", context={"source": "user"} diff --git a/tests/components/lutron_caseta/test_config_flow.py b/tests/components/lutron_caseta/test_config_flow.py index fc9c5fe279d..4ec5f14237c 100644 --- a/tests/components/lutron_caseta/test_config_flow.py +++ b/tests/components/lutron_caseta/test_config_flow.py @@ -50,7 +50,8 @@ async def test_bridge_import_flow(hass): } with patch( - "homeassistant.components.lutron_caseta.async_setup_entry", return_value=True, + "homeassistant.components.lutron_caseta.async_setup_entry", + return_value=True, ) as mock_setup_entry, patch( "homeassistant.components.lutron_caseta.async_setup", return_value=True ), patch.object( @@ -143,7 +144,8 @@ async def test_duplicate_bridge_import(hass): mock_entry.add_to_hass(hass) with patch( - "homeassistant.components.lutron_caseta.async_setup_entry", return_value=True, + "homeassistant.components.lutron_caseta.async_setup_entry", + return_value=True, ) as mock_setup_entry: # Mock entry added, try initializing flow with duplicate host result = await hass.config_entries.flow.async_init( diff --git a/tests/components/mailgun/test_init.py b/tests/components/mailgun/test_init.py index 5d6cec844f2..fd244d87a8f 100644 --- a/tests/components/mailgun/test_init.py +++ b/tests/components/mailgun/test_init.py @@ -31,7 +31,8 @@ async def webhook_id_with_api_key(hass): ) await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) result = await hass.config_entries.flow.async_init( "mailgun", context={"source": "user"} @@ -50,7 +51,8 @@ async def webhook_id_without_api_key(hass): await async_setup_component(hass, mailgun.DOMAIN, {}) await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) result = await hass.config_entries.flow.async_init( "mailgun", context={"source": "user"} diff --git a/tests/components/melissa/test_init.py b/tests/components/melissa/test_init.py index 7e174a4f8a0..b9e09a5d769 100644 --- a/tests/components/melissa/test_init.py +++ b/tests/components/melissa/test_init.py @@ -18,5 +18,6 @@ async def test_setup(hass): assert melissa.DATA_MELISSA in hass.data assert isinstance( - hass.data[melissa.DATA_MELISSA], type(mocked_melissa.return_value), + hass.data[melissa.DATA_MELISSA], + type(mocked_melissa.return_value), ) diff --git a/tests/components/meteo_france/test_config_flow.py b/tests/components/meteo_france/test_config_flow.py index 650a88df84e..3aa70aa48b3 100644 --- a/tests/components/meteo_france/test_config_flow.py +++ b/tests/components/meteo_france/test_config_flow.py @@ -84,9 +84,11 @@ def mock_controller_client_single(): def mock_setup(): """Prevent setup.""" with patch( - "homeassistant.components.meteo_france.async_setup", return_value=True, + "homeassistant.components.meteo_france.async_setup", + return_value=True, ), patch( - "homeassistant.components.meteo_france.async_setup_entry", return_value=True, + "homeassistant.components.meteo_france.async_setup_entry", + return_value=True, ): yield @@ -123,7 +125,9 @@ async def test_user(hass, client_single): # test with all provided with search returning only 1 place result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data={CONF_CITY: CITY_1_POSTAL}, + DOMAIN, + context={"source": SOURCE_USER}, + data={CONF_CITY: CITY_1_POSTAL}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result["result"].unique_id == f"{CITY_1_LAT}, {CITY_1_LON}" @@ -137,7 +141,9 @@ async def test_user_list(hass, client_multiple): # test with all provided with search returning more than 1 place result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data={CONF_CITY: CITY_2_NAME}, + DOMAIN, + context={"source": SOURCE_USER}, + data={CONF_CITY: CITY_2_NAME}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == "cities" @@ -157,7 +163,9 @@ async def test_import(hass, client_multiple): """Test import step.""" # import with all result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data={CONF_CITY: CITY_2_NAME}, + DOMAIN, + context={"source": SOURCE_IMPORT}, + data={CONF_CITY: CITY_2_NAME}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result["result"].unique_id == f"{CITY_2_LAT}, {CITY_2_LON}" @@ -169,7 +177,9 @@ async def test_import(hass, client_multiple): async def test_search_failed(hass, client_empty): """Test error displayed if no result in search.""" result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data={CONF_CITY: CITY_1_POSTAL}, + DOMAIN, + context={"source": SOURCE_USER}, + data={CONF_CITY: CITY_1_POSTAL}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -186,14 +196,18 @@ async def test_abort_if_already_setup(hass, client_single): # Should fail, same CITY same postal code (import) result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data={CONF_CITY: CITY_1_POSTAL}, + DOMAIN, + context={"source": SOURCE_IMPORT}, + data={CONF_CITY: CITY_1_POSTAL}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["reason"] == "already_configured" # Should fail, same CITY same postal code (flow) result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data={CONF_CITY: CITY_1_POSTAL}, + DOMAIN, + context={"source": SOURCE_USER}, + data={CONF_CITY: CITY_1_POSTAL}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["reason"] == "already_configured" @@ -216,7 +230,8 @@ async def test_options_flow(hass: HomeAssistantType): # Default result = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={}, + result["flow_id"], + user_input={}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert config_entry.options[CONF_MODE] == FORECAST_MODE_DAILY @@ -224,7 +239,8 @@ async def test_options_flow(hass: HomeAssistantType): # Manual result = await hass.config_entries.options.async_init(config_entry.entry_id) result = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={CONF_MODE: FORECAST_MODE_HOURLY}, + result["flow_id"], + user_input={CONF_MODE: FORECAST_MODE_HOURLY}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert config_entry.options[CONF_MODE] == FORECAST_MODE_HOURLY diff --git a/tests/components/metoffice/test_config_flow.py b/tests/components/metoffice/test_config_flow.py index 6916e949b1c..5987d44ac27 100644 --- a/tests/components/metoffice/test_config_flow.py +++ b/tests/components/metoffice/test_config_flow.py @@ -36,7 +36,8 @@ async def test_form(hass, requests_mock): with patch( "homeassistant.components.metoffice.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.metoffice.async_setup_entry", return_value=True, + "homeassistant.components.metoffice.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], {"api_key": TEST_API_KEY} @@ -67,7 +68,8 @@ async def test_form_already_configured(hass, requests_mock): requests_mock.get("/public/data/val/wxfcs/all/json/sitelist/", text=all_sites) requests_mock.get( - "/public/data/val/wxfcs/all/json/354107?res=3hourly", text="", + "/public/data/val/wxfcs/all/json/354107?res=3hourly", + text="", ) MockConfigEntry( @@ -98,7 +100,8 @@ async def test_form_cannot_connect(hass, requests_mock): ) result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"api_key": TEST_API_KEY}, + result["flow_id"], + {"api_key": TEST_API_KEY}, ) assert result2["type"] == "form" @@ -115,7 +118,8 @@ async def test_form_unknown_error(hass, mock_simple_manager_fail): ) result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"api_key": TEST_API_KEY}, + result["flow_id"], + {"api_key": TEST_API_KEY}, ) assert result2["type"] == "form" diff --git a/tests/components/metoffice/test_sensor.py b/tests/components/metoffice/test_sensor.py index b04dc6b2422..43dbf3f75e0 100644 --- a/tests/components/metoffice/test_sensor.py +++ b/tests/components/metoffice/test_sensor.py @@ -20,7 +20,8 @@ from tests.common import MockConfigEntry, load_fixture @patch( - "datapoint.Forecast.datetime.datetime", NewDateTime, + "datapoint.Forecast.datetime.datetime", + NewDateTime, ) async def test_one_sensor_site_running(hass, requests_mock, legacy_patchable_time): """Test the Met Office sensor platform.""" @@ -31,10 +32,14 @@ async def test_one_sensor_site_running(hass, requests_mock, legacy_patchable_tim requests_mock.get("/public/data/val/wxfcs/all/json/sitelist/", text=all_sites) requests_mock.get( - "/public/data/val/wxfcs/all/json/354107?res=3hourly", text=wavertree_hourly, + "/public/data/val/wxfcs/all/json/354107?res=3hourly", + text=wavertree_hourly, ) - entry = MockConfigEntry(domain=DOMAIN, data=METOFFICE_CONFIG_WAVERTREE,) + entry = MockConfigEntry( + domain=DOMAIN, + data=METOFFICE_CONFIG_WAVERTREE, + ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() @@ -57,7 +62,8 @@ async def test_one_sensor_site_running(hass, requests_mock, legacy_patchable_tim @patch( - "datapoint.Forecast.datetime.datetime", NewDateTime, + "datapoint.Forecast.datetime.datetime", + NewDateTime, ) async def test_two_sensor_sites_running(hass, requests_mock, legacy_patchable_time): """Test we handle two sets of sensors running for two different sites.""" @@ -76,10 +82,16 @@ async def test_two_sensor_sites_running(hass, requests_mock, legacy_patchable_ti "/public/data/val/wxfcs/all/json/322380?res=3hourly", text=kingslynn_hourly ) - entry = MockConfigEntry(domain=DOMAIN, data=METOFFICE_CONFIG_WAVERTREE,) + entry = MockConfigEntry( + domain=DOMAIN, + data=METOFFICE_CONFIG_WAVERTREE, + ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) - entry2 = MockConfigEntry(domain=DOMAIN, data=METOFFICE_CONFIG_KINGSLYNN,) + entry2 = MockConfigEntry( + domain=DOMAIN, + data=METOFFICE_CONFIG_KINGSLYNN, + ) entry2.add_to_hass(hass) await hass.config_entries.async_setup(entry2.entry_id) await hass.async_block_till_done() diff --git a/tests/components/metoffice/test_weather.py b/tests/components/metoffice/test_weather.py index 673dec7d5a6..f1530021fcf 100644 --- a/tests/components/metoffice/test_weather.py +++ b/tests/components/metoffice/test_weather.py @@ -18,7 +18,8 @@ from tests.common import MockConfigEntry, async_fire_time_changed, load_fixture @patch( - "datapoint.Forecast.datetime.datetime", NewDateTime, + "datapoint.Forecast.datetime.datetime", + NewDateTime, ) async def test_site_cannot_connect(hass, requests_mock, legacy_patchable_time): """Test we handle cannot connect error.""" @@ -26,7 +27,10 @@ async def test_site_cannot_connect(hass, requests_mock, legacy_patchable_time): requests_mock.get("/public/data/val/wxfcs/all/json/sitelist/", text="") requests_mock.get("/public/data/val/wxfcs/all/json/354107?res=3hourly", text="") - entry = MockConfigEntry(domain=DOMAIN, data=METOFFICE_CONFIG_WAVERTREE,) + entry = MockConfigEntry( + domain=DOMAIN, + data=METOFFICE_CONFIG_WAVERTREE, + ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() @@ -39,7 +43,8 @@ async def test_site_cannot_connect(hass, requests_mock, legacy_patchable_time): @patch( - "datapoint.Forecast.datetime.datetime", NewDateTime, + "datapoint.Forecast.datetime.datetime", + NewDateTime, ) async def test_site_cannot_update(hass, requests_mock, legacy_patchable_time): """Test we handle cannot connect error.""" @@ -54,7 +59,10 @@ async def test_site_cannot_update(hass, requests_mock, legacy_patchable_time): "/public/data/val/wxfcs/all/json/354107?res=3hourly", text=wavertree_hourly ) - entry = MockConfigEntry(domain=DOMAIN, data=METOFFICE_CONFIG_WAVERTREE,) + entry = MockConfigEntry( + domain=DOMAIN, + data=METOFFICE_CONFIG_WAVERTREE, + ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() @@ -73,7 +81,8 @@ async def test_site_cannot_update(hass, requests_mock, legacy_patchable_time): @patch( - "datapoint.Forecast.datetime.datetime", NewDateTime, + "datapoint.Forecast.datetime.datetime", + NewDateTime, ) async def test_one_weather_site_running(hass, requests_mock, legacy_patchable_time): """Test the Met Office weather platform.""" @@ -85,10 +94,14 @@ async def test_one_weather_site_running(hass, requests_mock, legacy_patchable_ti requests_mock.get("/public/data/val/wxfcs/all/json/sitelist/", text=all_sites) requests_mock.get( - "/public/data/val/wxfcs/all/json/354107?res=3hourly", text=wavertree_hourly, + "/public/data/val/wxfcs/all/json/354107?res=3hourly", + text=wavertree_hourly, ) - entry = MockConfigEntry(domain=DOMAIN, data=METOFFICE_CONFIG_WAVERTREE,) + entry = MockConfigEntry( + domain=DOMAIN, + data=METOFFICE_CONFIG_WAVERTREE, + ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() @@ -106,7 +119,8 @@ async def test_one_weather_site_running(hass, requests_mock, legacy_patchable_ti @patch( - "datapoint.Forecast.datetime.datetime", NewDateTime, + "datapoint.Forecast.datetime.datetime", + NewDateTime, ) async def test_two_weather_sites_running(hass, requests_mock, legacy_patchable_time): """Test we handle two different weather sites both running.""" @@ -125,10 +139,16 @@ async def test_two_weather_sites_running(hass, requests_mock, legacy_patchable_t "/public/data/val/wxfcs/all/json/322380?res=3hourly", text=kingslynn_hourly ) - entry = MockConfigEntry(domain=DOMAIN, data=METOFFICE_CONFIG_WAVERTREE,) + entry = MockConfigEntry( + domain=DOMAIN, + data=METOFFICE_CONFIG_WAVERTREE, + ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) - entry2 = MockConfigEntry(domain=DOMAIN, data=METOFFICE_CONFIG_KINGSLYNN,) + entry2 = MockConfigEntry( + domain=DOMAIN, + data=METOFFICE_CONFIG_KINGSLYNN, + ) entry2.add_to_hass(hass) await hass.config_entries.async_setup(entry2.entry_id) await hass.async_block_till_done() diff --git a/tests/components/mikrotik/test_init.py b/tests/components/mikrotik/test_init.py index b3dca7269eb..30df96e89a0 100644 --- a/tests/components/mikrotik/test_init.py +++ b/tests/components/mikrotik/test_init.py @@ -16,7 +16,10 @@ async def test_setup_with_no_config(hass): async def test_successful_config_entry(hass): """Test config entry successful setup.""" - entry = MockConfigEntry(domain=mikrotik.DOMAIN, data=MOCK_DATA,) + entry = MockConfigEntry( + domain=mikrotik.DOMAIN, + data=MOCK_DATA, + ) entry.add_to_hass(hass) mock_registry = Mock() @@ -50,7 +53,10 @@ async def test_successful_config_entry(hass): async def test_hub_fail_setup(hass): """Test that a failed setup will not store the hub.""" - entry = MockConfigEntry(domain=mikrotik.DOMAIN, data=MOCK_DATA,) + entry = MockConfigEntry( + domain=mikrotik.DOMAIN, + data=MOCK_DATA, + ) entry.add_to_hass(hass) with patch.object(mikrotik, "MikrotikHub") as mock_hub: @@ -62,11 +68,15 @@ async def test_hub_fail_setup(hass): async def test_unload_entry(hass): """Test being able to unload an entry.""" - entry = MockConfigEntry(domain=mikrotik.DOMAIN, data=MOCK_DATA,) + entry = MockConfigEntry( + domain=mikrotik.DOMAIN, + data=MOCK_DATA, + ) entry.add_to_hass(hass) with patch.object(mikrotik, "MikrotikHub") as mock_hub, patch( - "homeassistant.helpers.device_registry.async_get_registry", return_value=Mock(), + "homeassistant.helpers.device_registry.async_get_registry", + return_value=Mock(), ): mock_hub.return_value.async_setup = AsyncMock(return_value=True) mock_hub.return_value.serial_num = "12345678" diff --git a/tests/components/mill/test_config_flow.py b/tests/components/mill/test_config_flow.py index 54b8dbc9b59..0bd059a1786 100644 --- a/tests/components/mill/test_config_flow.py +++ b/tests/components/mill/test_config_flow.py @@ -51,7 +51,9 @@ async def test_flow_entry_already_exists(hass): } first_entry = MockConfigEntry( - domain="mill", data=test_data, unique_id=test_data[CONF_USERNAME], + domain="mill", + data=test_data, + unique_id=test_data[CONF_USERNAME], ) first_entry.add_to_hass(hass) @@ -73,7 +75,9 @@ async def test_connection_error(hass): } first_entry = MockConfigEntry( - domain="mill", data=test_data, unique_id=test_data[CONF_USERNAME], + domain="mill", + data=test_data, + unique_id=test_data[CONF_USERNAME], ) first_entry.add_to_hass(hass) diff --git a/tests/components/minecraft_server/test_config_flow.py b/tests/components/minecraft_server/test_config_flow.py index 17ec9080e86..2f8ae5ff0bf 100644 --- a/tests/components/minecraft_server/test_config_flow.py +++ b/tests/components/minecraft_server/test_config_flow.py @@ -104,7 +104,8 @@ async def test_invalid_ip(hass: HomeAssistantType) -> None: async def test_same_host(hass: HomeAssistantType) -> None: """Test abort in case of same host name.""" with patch( - "aiodns.DNSResolver.query", side_effect=aiodns.error.DNSError, + "aiodns.DNSResolver.query", + side_effect=aiodns.error.DNSError, ): with patch( "mcstatus.server.MinecraftServer.status", @@ -132,7 +133,8 @@ async def test_same_host(hass: HomeAssistantType) -> None: async def test_port_too_small(hass: HomeAssistantType) -> None: """Test error in case of a too small port.""" with patch( - "aiodns.DNSResolver.query", side_effect=aiodns.error.DNSError, + "aiodns.DNSResolver.query", + side_effect=aiodns.error.DNSError, ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=USER_INPUT_PORT_TOO_SMALL @@ -145,7 +147,8 @@ async def test_port_too_small(hass: HomeAssistantType) -> None: async def test_port_too_large(hass: HomeAssistantType) -> None: """Test error in case of a too large port.""" with patch( - "aiodns.DNSResolver.query", side_effect=aiodns.error.DNSError, + "aiodns.DNSResolver.query", + side_effect=aiodns.error.DNSError, ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=USER_INPUT_PORT_TOO_LARGE @@ -158,7 +161,8 @@ async def test_port_too_large(hass: HomeAssistantType) -> None: async def test_connection_failed(hass: HomeAssistantType) -> None: """Test error in case of a failed connection.""" with patch( - "aiodns.DNSResolver.query", side_effect=aiodns.error.DNSError, + "aiodns.DNSResolver.query", + side_effect=aiodns.error.DNSError, ): with patch("mcstatus.server.MinecraftServer.status", side_effect=OSError): result = await hass.config_entries.flow.async_init( @@ -172,7 +176,8 @@ async def test_connection_failed(hass: HomeAssistantType) -> None: async def test_connection_succeeded_with_srv_record(hass: HomeAssistantType) -> None: """Test config entry in case of a successful connection with a SRV record.""" with patch( - "aiodns.DNSResolver.query", return_value=SRV_RECORDS, + "aiodns.DNSResolver.query", + return_value=SRV_RECORDS, ): with patch( "mcstatus.server.MinecraftServer.status", @@ -191,7 +196,8 @@ async def test_connection_succeeded_with_srv_record(hass: HomeAssistantType) -> async def test_connection_succeeded_with_host(hass: HomeAssistantType) -> None: """Test config entry in case of a successful connection with a host name.""" with patch( - "aiodns.DNSResolver.query", side_effect=aiodns.error.DNSError, + "aiodns.DNSResolver.query", + side_effect=aiodns.error.DNSError, ): with patch( "mcstatus.server.MinecraftServer.status", @@ -211,7 +217,8 @@ async def test_connection_succeeded_with_ip4(hass: HomeAssistantType) -> None: """Test config entry in case of a successful connection with an IPv4 address.""" with patch("getmac.get_mac_address", return_value="01:23:45:67:89:ab"): with patch( - "aiodns.DNSResolver.query", side_effect=aiodns.error.DNSError, + "aiodns.DNSResolver.query", + side_effect=aiodns.error.DNSError, ): with patch( "mcstatus.server.MinecraftServer.status", @@ -231,7 +238,8 @@ async def test_connection_succeeded_with_ip6(hass: HomeAssistantType) -> None: """Test config entry in case of a successful connection with an IPv6 address.""" with patch("getmac.get_mac_address", return_value="01:23:45:67:89:ab"): with patch( - "aiodns.DNSResolver.query", side_effect=aiodns.error.DNSError, + "aiodns.DNSResolver.query", + side_effect=aiodns.error.DNSError, ): with patch( "mcstatus.server.MinecraftServer.status", diff --git a/tests/components/mobile_app/test_webhook.py b/tests/components/mobile_app/test_webhook.py index bd38bca535b..bedaa8ce739 100644 --- a/tests/components/mobile_app/test_webhook.py +++ b/tests/components/mobile_app/test_webhook.py @@ -143,7 +143,9 @@ async def test_webhook_update_registration(webhook_client, authed_api_client): async def test_webhook_handle_get_zones(hass, create_registrations, webhook_client): """Test that we can get zones properly.""" await async_setup_component( - hass, ZONE_DOMAIN, {ZONE_DOMAIN: {}}, + hass, + ZONE_DOMAIN, + {ZONE_DOMAIN: {}}, ) resp = await webhook_client.post( @@ -266,7 +268,8 @@ async def test_webhook_enable_encryption(hass, webhook_client, create_registrati webhook_id = create_registrations[1]["webhook_id"] enable_enc_resp = await webhook_client.post( - f"/api/webhook/{webhook_id}", json={"type": "enable_encryption"}, + f"/api/webhook/{webhook_id}", + json={"type": "enable_encryption"}, ) assert enable_enc_resp.status == 200 @@ -278,7 +281,8 @@ async def test_webhook_enable_encryption(hass, webhook_client, create_registrati key = enable_enc_json["secret"] enc_required_resp = await webhook_client.post( - f"/api/webhook/{webhook_id}", json=RENDER_TEMPLATE, + f"/api/webhook/{webhook_id}", + json=RENDER_TEMPLATE, ) assert enc_required_resp.status == 400 diff --git a/tests/components/monoprice/test_config_flow.py b/tests/components/monoprice/test_config_flow.py index 8c6e2a3916c..49a7ed27e5a 100644 --- a/tests/components/monoprice/test_config_flow.py +++ b/tests/components/monoprice/test_config_flow.py @@ -37,7 +37,8 @@ async def test_form(hass): ), patch( "homeassistant.components.monoprice.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.monoprice.async_setup_entry", return_value=True, + "homeassistant.components.monoprice.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], CONFIG diff --git a/tests/components/monoprice/test_media_player.py b/tests/components/monoprice/test_media_player.py index ccd70c628e2..41a33fd095b 100644 --- a/tests/components/monoprice/test_media_player.py +++ b/tests/components/monoprice/test_media_player.py @@ -97,7 +97,8 @@ async def test_cannot_connect(hass): """Test connection error.""" with patch( - "homeassistant.components.monoprice.get_monoprice", side_effect=SerialException, + "homeassistant.components.monoprice.get_monoprice", + side_effect=SerialException, ): config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG) config_entry.add_to_hass(hass) @@ -108,7 +109,8 @@ async def test_cannot_connect(hass): async def _setup_monoprice(hass, monoprice): with patch( - "homeassistant.components.monoprice.get_monoprice", new=lambda *a: monoprice, + "homeassistant.components.monoprice.get_monoprice", + new=lambda *a: monoprice, ): config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG) config_entry.add_to_hass(hass) @@ -118,7 +120,8 @@ async def _setup_monoprice(hass, monoprice): async def _setup_monoprice_with_options(hass, monoprice): with patch( - "homeassistant.components.monoprice.get_monoprice", new=lambda *a: monoprice, + "homeassistant.components.monoprice.get_monoprice", + new=lambda *a: monoprice, ): config_entry = MockConfigEntry( domain=DOMAIN, data=MOCK_CONFIG, options=MOCK_OPTIONS @@ -130,7 +133,8 @@ async def _setup_monoprice_with_options(hass, monoprice): async def _setup_monoprice_not_first_run(hass, monoprice): with patch( - "homeassistant.components.monoprice.get_monoprice", new=lambda *a: monoprice, + "homeassistant.components.monoprice.get_monoprice", + new=lambda *a: monoprice, ): data = {**MOCK_CONFIG, CONF_NOT_FIRST_RUN: True} config_entry = MockConfigEntry(domain=DOMAIN, data=data) diff --git a/tests/components/moon/test_sensor.py b/tests/components/moon/test_sensor.py index 59210c63b90..234a8a1e34d 100644 --- a/tests/components/moon/test_sensor.py +++ b/tests/components/moon/test_sensor.py @@ -54,6 +54,9 @@ async def test_moon_day2(hass): async def async_update_entity(hass, entity_id): """Run an update action for an entity.""" await hass.services.async_call( - HA_DOMAIN, SERVICE_UPDATE_ENTITY, {ATTR_ENTITY_ID: entity_id}, blocking=True, + HA_DOMAIN, + SERVICE_UPDATE_ENTITY, + {ATTR_ENTITY_ID: entity_id}, + blocking=True, ) await hass.async_block_till_done() diff --git a/tests/components/mqtt/test_alarm_control_panel.py b/tests/components/mqtt/test_alarm_control_panel.py index 734e1fd552f..30ec5316399 100644 --- a/tests/components/mqtt/test_alarm_control_panel.py +++ b/tests/components/mqtt/test_alarm_control_panel.py @@ -105,7 +105,9 @@ async def test_fail_setup_without_command_topic(hass, mqtt_mock): async def test_update_state_via_state_topic(hass, mqtt_mock): """Test updating with via state topic.""" assert await async_setup_component( - hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG, + hass, + alarm_control_panel.DOMAIN, + DEFAULT_CONFIG, ) await hass.async_block_till_done() @@ -131,7 +133,9 @@ async def test_update_state_via_state_topic(hass, mqtt_mock): async def test_ignore_update_state_if_unknown_via_state_topic(hass, mqtt_mock): """Test ignoring updates via state topic.""" assert await async_setup_component( - hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG, + hass, + alarm_control_panel.DOMAIN, + DEFAULT_CONFIG, ) await hass.async_block_till_done() @@ -146,7 +150,9 @@ async def test_ignore_update_state_if_unknown_via_state_topic(hass, mqtt_mock): async def test_arm_home_publishes_mqtt(hass, mqtt_mock): """Test publishing of MQTT messages while armed.""" assert await async_setup_component( - hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG, + hass, + alarm_control_panel.DOMAIN, + DEFAULT_CONFIG, ) await hass.async_block_till_done() @@ -162,7 +168,9 @@ async def test_arm_home_not_publishes_mqtt_with_invalid_code_when_req(hass, mqtt When code_arm_required = True """ assert await async_setup_component( - hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG_CODE, + hass, + alarm_control_panel.DOMAIN, + DEFAULT_CONFIG_CODE, ) call_count = mqtt_mock.async_publish.call_count @@ -177,7 +185,11 @@ async def test_arm_home_publishes_mqtt_when_code_not_req(hass, mqtt_mock): """ config = copy.deepcopy(DEFAULT_CONFIG_CODE) config[alarm_control_panel.DOMAIN]["code_arm_required"] = False - assert await async_setup_component(hass, alarm_control_panel.DOMAIN, config,) + assert await async_setup_component( + hass, + alarm_control_panel.DOMAIN, + config, + ) await hass.async_block_till_done() await common.async_alarm_arm_home(hass) @@ -189,7 +201,9 @@ async def test_arm_home_publishes_mqtt_when_code_not_req(hass, mqtt_mock): async def test_arm_away_publishes_mqtt(hass, mqtt_mock): """Test publishing of MQTT messages while armed.""" assert await async_setup_component( - hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG, + hass, + alarm_control_panel.DOMAIN, + DEFAULT_CONFIG, ) await hass.async_block_till_done() @@ -205,7 +219,9 @@ async def test_arm_away_not_publishes_mqtt_with_invalid_code_when_req(hass, mqtt When code_arm_required = True """ assert await async_setup_component( - hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG_CODE, + hass, + alarm_control_panel.DOMAIN, + DEFAULT_CONFIG_CODE, ) call_count = mqtt_mock.async_publish.call_count @@ -220,7 +236,11 @@ async def test_arm_away_publishes_mqtt_when_code_not_req(hass, mqtt_mock): """ config = copy.deepcopy(DEFAULT_CONFIG_CODE) config[alarm_control_panel.DOMAIN]["code_arm_required"] = False - assert await async_setup_component(hass, alarm_control_panel.DOMAIN, config,) + assert await async_setup_component( + hass, + alarm_control_panel.DOMAIN, + config, + ) await hass.async_block_till_done() await common.async_alarm_arm_away(hass) @@ -232,7 +252,9 @@ async def test_arm_away_publishes_mqtt_when_code_not_req(hass, mqtt_mock): async def test_arm_night_publishes_mqtt(hass, mqtt_mock): """Test publishing of MQTT messages while armed.""" assert await async_setup_component( - hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG, + hass, + alarm_control_panel.DOMAIN, + DEFAULT_CONFIG, ) await hass.async_block_till_done() @@ -248,7 +270,9 @@ async def test_arm_night_not_publishes_mqtt_with_invalid_code_when_req(hass, mqt When code_arm_required = True """ assert await async_setup_component( - hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG_CODE, + hass, + alarm_control_panel.DOMAIN, + DEFAULT_CONFIG_CODE, ) call_count = mqtt_mock.async_publish.call_count @@ -263,7 +287,11 @@ async def test_arm_night_publishes_mqtt_when_code_not_req(hass, mqtt_mock): """ config = copy.deepcopy(DEFAULT_CONFIG_CODE) config[alarm_control_panel.DOMAIN]["code_arm_required"] = False - assert await async_setup_component(hass, alarm_control_panel.DOMAIN, config,) + assert await async_setup_component( + hass, + alarm_control_panel.DOMAIN, + config, + ) await hass.async_block_till_done() await common.async_alarm_arm_night(hass) @@ -352,7 +380,9 @@ async def test_arm_custom_bypass_publishes_mqtt_when_code_not_req(hass, mqtt_moc async def test_disarm_publishes_mqtt(hass, mqtt_mock): """Test publishing of MQTT messages while disarmed.""" assert await async_setup_component( - hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG, + hass, + alarm_control_panel.DOMAIN, + DEFAULT_CONFIG, ) await hass.async_block_till_done() @@ -370,7 +400,11 @@ async def test_disarm_publishes_mqtt_with_template(hass, mqtt_mock): config[alarm_control_panel.DOMAIN]["command_template"] = ( '{"action":"{{ action }}",' '"code":"{{ code }}"}' ) - assert await async_setup_component(hass, alarm_control_panel.DOMAIN, config,) + assert await async_setup_component( + hass, + alarm_control_panel.DOMAIN, + config, + ) await hass.async_block_till_done() await common.async_alarm_disarm(hass, 1234) @@ -387,7 +421,11 @@ async def test_disarm_publishes_mqtt_when_code_not_req(hass, mqtt_mock): config = copy.deepcopy(DEFAULT_CONFIG_CODE) config[alarm_control_panel.DOMAIN]["code"] = "1234" config[alarm_control_panel.DOMAIN]["code_disarm_required"] = False - assert await async_setup_component(hass, alarm_control_panel.DOMAIN, config,) + assert await async_setup_component( + hass, + alarm_control_panel.DOMAIN, + config, + ) await hass.async_block_till_done() await common.async_alarm_disarm(hass) @@ -400,7 +438,9 @@ async def test_disarm_not_publishes_mqtt_with_invalid_code_when_req(hass, mqtt_m When code_disarm_required = True """ assert await async_setup_component( - hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG_CODE, + hass, + alarm_control_panel.DOMAIN, + DEFAULT_CONFIG_CODE, ) call_count = mqtt_mock.async_publish.call_count diff --git a/tests/components/mqtt/test_common.py b/tests/components/mqtt/test_common.py index 89bfde22d87..547d8adad9e 100644 --- a/tests/components/mqtt/test_common.py +++ b/tests/components/mqtt/test_common.py @@ -74,7 +74,11 @@ async def help_test_default_availability_payload( # Add availability settings to config config = copy.deepcopy(config) config[domain]["availability_topic"] = "availability-topic" - assert await async_setup_component(hass, domain, config,) + assert await async_setup_component( + hass, + domain, + config, + ) await hass.async_block_till_done() state = hass.states.get(f"{domain}.test") @@ -123,7 +127,11 @@ async def help_test_default_availability_list_payload( {"topic": "availability-topic1"}, {"topic": "availability-topic2"}, ] - assert await async_setup_component(hass, domain, config,) + assert await async_setup_component( + hass, + domain, + config, + ) await hass.async_block_till_done() state = hass.states.get(f"{domain}.test") @@ -185,7 +193,11 @@ async def help_test_default_availability_list_single( {"topic": "availability-topic1"}, ] config[domain]["availability_topic"] = "availability-topic" - assert await async_setup_component(hass, domain, config,) + assert await async_setup_component( + hass, + domain, + config, + ) await hass.async_block_till_done() state = hass.states.get(f"{domain}.test") @@ -214,7 +226,11 @@ async def help_test_custom_availability_payload( config[domain]["availability_topic"] = "availability-topic" config[domain]["payload_available"] = "good" config[domain]["payload_not_available"] = "nogood" - assert await async_setup_component(hass, domain, config,) + assert await async_setup_component( + hass, + domain, + config, + ) await hass.async_block_till_done() state = hass.states.get(f"{domain}.test") @@ -336,7 +352,11 @@ async def help_test_setting_attribute_via_mqtt_json_message( # Add JSON attributes settings to config config = copy.deepcopy(config) config[domain]["json_attributes_topic"] = "attr-topic" - assert await async_setup_component(hass, domain, config,) + assert await async_setup_component( + hass, + domain, + config, + ) await hass.async_block_till_done() async_fire_mqtt_message(hass, "attr-topic", '{ "val": "100" }') @@ -354,7 +374,11 @@ async def help_test_setting_attribute_with_template(hass, mqtt_mock, domain, con config = copy.deepcopy(config) config[domain]["json_attributes_topic"] = "attr-topic" config[domain]["json_attributes_template"] = "{{ value_json['Timer1'] | tojson }}" - assert await async_setup_component(hass, domain, config,) + assert await async_setup_component( + hass, + domain, + config, + ) await hass.async_block_till_done() async_fire_mqtt_message( @@ -376,7 +400,11 @@ async def help_test_update_with_json_attrs_not_dict( # Add JSON attributes settings to config config = copy.deepcopy(config) config[domain]["json_attributes_topic"] = "attr-topic" - assert await async_setup_component(hass, domain, config,) + assert await async_setup_component( + hass, + domain, + config, + ) await hass.async_block_till_done() async_fire_mqtt_message(hass, "attr-topic", '[ "list", "of", "things"]') @@ -396,7 +424,11 @@ async def help_test_update_with_json_attrs_bad_JSON( # Add JSON attributes settings to config config = copy.deepcopy(config) config[domain]["json_attributes_topic"] = "attr-topic" - assert await async_setup_component(hass, domain, config,) + assert await async_setup_component( + hass, + domain, + config, + ) await hass.async_block_till_done() async_fire_mqtt_message(hass, "attr-topic", "This is not JSON") @@ -670,7 +702,11 @@ async def help_test_entity_id_update_subscriptions( topics = ["avty-topic", "test-topic"] assert len(topics) > 0 registry = mock_registry(hass, {}) - assert await async_setup_component(hass, domain, config,) + assert await async_setup_component( + hass, + domain, + config, + ) await hass.async_block_till_done() state = hass.states.get(f"{domain}.test") diff --git a/tests/components/mqtt/test_config_flow.py b/tests/components/mqtt/test_config_flow.py index 5fbb772f949..ef6e7a7656c 100644 --- a/tests/components/mqtt/test_config_flow.py +++ b/tests/components/mqtt/test_config_flow.py @@ -505,7 +505,8 @@ async def test_options_bad_birth_message_fails(hass, mock_try_connection): assert result["step_id"] == "options" result = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={"birth_topic": "ha_state/online/#"}, + result["flow_id"], + user_input={"birth_topic": "ha_state/online/#"}, ) assert result["type"] == "form" assert result["errors"]["base"] == "bad_birth" @@ -540,7 +541,8 @@ async def test_options_bad_will_message_fails(hass, mock_try_connection): assert result["step_id"] == "options" result = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={"will_topic": "ha_state/offline/#"}, + result["flow_id"], + user_input={"will_topic": "ha_state/offline/#"}, ) assert result["type"] == "form" assert result["errors"]["base"] == "bad_will" diff --git a/tests/components/mqtt/test_init.py b/tests/components/mqtt/test_init.py index 0dfef17a145..a4d1261daf8 100644 --- a/tests/components/mqtt/test_init.py +++ b/tests/components/mqtt/test_init.py @@ -791,7 +791,8 @@ async def test_default_birth_message(hass, mqtt_client_mock, mqtt_mock): @pytest.mark.parametrize( - "mqtt_config", [{mqtt.CONF_BROKER: "mock-broker", mqtt.CONF_BIRTH_MESSAGE: {}}], + "mqtt_config", + [{mqtt.CONF_BROKER: "mock-broker", mqtt.CONF_BIRTH_MESSAGE: {}}], ) async def test_no_birth_message(hass, mqtt_client_mock, mqtt_mock): """Test disabling birth message.""" @@ -829,7 +830,8 @@ async def test_default_will_message(hass, mqtt_client_mock, mqtt_mock): @pytest.mark.parametrize( - "mqtt_config", [{mqtt.CONF_BROKER: "mock-broker", mqtt.CONF_WILL_MESSAGE: {}}], + "mqtt_config", + [{mqtt.CONF_BROKER: "mock-broker", mqtt.CONF_WILL_MESSAGE: {}}], ) async def test_no_will_message(hass, mqtt_client_mock, mqtt_mock): """Test will message.""" @@ -837,7 +839,8 @@ async def test_no_will_message(hass, mqtt_client_mock, mqtt_mock): @pytest.mark.parametrize( - "mqtt_config", [{mqtt.CONF_BROKER: "mock-broker", mqtt.CONF_BIRTH_MESSAGE: {}}], + "mqtt_config", + [{mqtt.CONF_BROKER: "mock-broker", mqtt.CONF_BIRTH_MESSAGE: {}}], ) async def test_mqtt_subscribes_topics_on_connect(hass, mqtt_client_mock, mqtt_mock): """Test subscription to topic on connect.""" diff --git a/tests/components/mqtt/test_light_json.py b/tests/components/mqtt/test_light_json.py index 54292aeeb7b..9a3d9abacc9 100644 --- a/tests/components/mqtt/test_light_json.py +++ b/tests/components/mqtt/test_light_json.py @@ -1006,7 +1006,9 @@ async def test_invalid_values(hass, mqtt_mock): # Bad HS color values async_fire_mqtt_message( - hass, "test_light_rgb", '{"state":"ON",' '"color":{"h":"bad","s":"val"}}', + hass, + "test_light_rgb", + '{"state":"ON",' '"color":{"h":"bad","s":"val"}}', ) # Color should not have changed @@ -1028,7 +1030,9 @@ async def test_invalid_values(hass, mqtt_mock): # Bad XY color values async_fire_mqtt_message( - hass, "test_light_rgb", '{"state":"ON",' '"color":{"x":"bad","y":"val"}}', + hass, + "test_light_rgb", + '{"state":"ON",' '"color":{"x":"bad","y":"val"}}', ) # Color should not have changed diff --git a/tests/components/mqtt_eventstream/test_init.py b/tests/components/mqtt_eventstream/test_init.py index ecdedf904d4..87139a0f3ee 100644 --- a/tests/components/mqtt_eventstream/test_init.py +++ b/tests/components/mqtt_eventstream/test_init.py @@ -70,7 +70,8 @@ async def test_state_changed_event_sends_message(hass, mqtt_mock): e_id = "fake.entity" pub_topic = "bar" with patch( - ("homeassistant.core.dt_util.utcnow"), return_value=now, + ("homeassistant.core.dt_util.utcnow"), + return_value=now, ): # Add the eventstream component for publishing events assert await add_eventstream(hass, pub_topic=pub_topic) diff --git a/tests/components/myq/test_config_flow.py b/tests/components/myq/test_config_flow.py index ed022df0dd7..4d1bf7db683 100644 --- a/tests/components/myq/test_config_flow.py +++ b/tests/components/myq/test_config_flow.py @@ -19,11 +19,13 @@ async def test_form_user(hass): assert result["errors"] == {} with patch( - "homeassistant.components.myq.config_flow.pymyq.login", return_value=True, + "homeassistant.components.myq.config_flow.pymyq.login", + return_value=True, ), patch( "homeassistant.components.myq.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.myq.async_setup_entry", return_value=True, + "homeassistant.components.myq.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -46,11 +48,13 @@ async def test_import(hass): await setup.async_setup_component(hass, "persistent_notification", {}) with patch( - "homeassistant.components.myq.config_flow.pymyq.login", return_value=True, + "homeassistant.components.myq.config_flow.pymyq.login", + return_value=True, ), patch( "homeassistant.components.myq.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.myq.async_setup_entry", return_value=True, + "homeassistant.components.myq.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, @@ -95,7 +99,8 @@ async def test_form_cannot_connect(hass): ) with patch( - "homeassistant.components.myq.config_flow.pymyq.login", side_effect=MyQError, + "homeassistant.components.myq.config_flow.pymyq.login", + side_effect=MyQError, ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/tests/components/myq/util.py b/tests/components/myq/util.py index 61e49a98b83..61c19325d57 100644 --- a/tests/components/myq/util.py +++ b/tests/components/myq/util.py @@ -11,7 +11,8 @@ from tests.common import MockConfigEntry, load_fixture async def async_init_integration( - hass: HomeAssistant, skip_setup: bool = False, + hass: HomeAssistant, + skip_setup: bool = False, ) -> MockConfigEntry: """Set up the myq integration in Home Assistant.""" diff --git a/tests/components/netatmo/test_config_flow.py b/tests/components/netatmo/test_config_flow.py index 1ad2fd196cf..8cee7a8c750 100644 --- a/tests/components/netatmo/test_config_flow.py +++ b/tests/components/netatmo/test_config_flow.py @@ -127,7 +127,10 @@ async def test_option_flow(hass): } config_entry = MockConfigEntry( - domain=DOMAIN, unique_id=DOMAIN, data=VALID_CONFIG, options={}, + domain=DOMAIN, + unique_id=DOMAIN, + data=VALID_CONFIG, + options={}, ) config_entry.add_to_hass(hass) @@ -182,7 +185,10 @@ async def test_option_flow_wrong_coordinates(hass): } config_entry = MockConfigEntry( - domain=DOMAIN, unique_id=DOMAIN, data=VALID_CONFIG, options={}, + domain=DOMAIN, + unique_id=DOMAIN, + data=VALID_CONFIG, + options={}, ) config_entry.add_to_hass(hass) diff --git a/tests/components/nexia/test_config_flow.py b/tests/components/nexia/test_config_flow.py index 0dce512cff4..2d9ca00fbe3 100644 --- a/tests/components/nexia/test_config_flow.py +++ b/tests/components/nexia/test_config_flow.py @@ -26,10 +26,12 @@ async def test_form(hass): ), patch( "homeassistant.components.nexia.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.nexia.async_setup_entry", return_value=True, + "homeassistant.components.nexia.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_USERNAME: "username", CONF_PASSWORD: "password"}, + result["flow_id"], + {CONF_USERNAME: "username", CONF_PASSWORD: "password"}, ) assert result2["type"] == "create_entry" @@ -51,7 +53,8 @@ async def test_form_invalid_auth(hass): with patch("homeassistant.components.nexia.config_flow.NexiaHome.login"): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_USERNAME: "username", CONF_PASSWORD: "password"}, + result["flow_id"], + {CONF_USERNAME: "username", CONF_PASSWORD: "password"}, ) assert result2["type"] == "form" @@ -69,7 +72,8 @@ async def test_form_cannot_connect(hass): side_effect=ConnectTimeout, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_USERNAME: "username", CONF_PASSWORD: "password"}, + result["flow_id"], + {CONF_USERNAME: "username", CONF_PASSWORD: "password"}, ) assert result2["type"] == "form" @@ -89,7 +93,8 @@ async def test_form_import(hass): ), patch( "homeassistant.components.nexia.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.nexia.async_setup_entry", return_value=True, + "homeassistant.components.nexia.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, diff --git a/tests/components/nexia/util.py b/tests/components/nexia/util.py index 2da56d50f37..7d34f0894e0 100644 --- a/tests/components/nexia/util.py +++ b/tests/components/nexia/util.py @@ -13,7 +13,8 @@ from tests.common import MockConfigEntry, load_fixture async def async_init_integration( - hass: HomeAssistant, skip_setup: bool = False, + hass: HomeAssistant, + skip_setup: bool = False, ) -> MockConfigEntry: """Set up the nexia integration in Home Assistant.""" diff --git a/tests/components/nightscout/__init__.py b/tests/components/nightscout/__init__.py index de1bb8a2b7c..52064d1a92b 100644 --- a/tests/components/nightscout/__init__.py +++ b/tests/components/nightscout/__init__.py @@ -26,7 +26,10 @@ SERVER_STATUS = ServerStatus.new_from_json_dict( async def init_integration(hass) -> MockConfigEntry: """Set up the Nightscout integration in Home Assistant.""" - entry = MockConfigEntry(domain=DOMAIN, data={CONF_URL: "https://some.url:1234"},) + entry = MockConfigEntry( + domain=DOMAIN, + data={CONF_URL: "https://some.url:1234"}, + ) with patch( "homeassistant.components.nightscout.NightscoutAPI.get_sgvs", return_value=GLUCOSE_READINGS, @@ -43,7 +46,10 @@ async def init_integration(hass) -> MockConfigEntry: async def init_integration_unavailable(hass) -> MockConfigEntry: """Set up the Nightscout integration in Home Assistant.""" - entry = MockConfigEntry(domain=DOMAIN, data={CONF_URL: "https://some.url:1234"},) + entry = MockConfigEntry( + domain=DOMAIN, + data={CONF_URL: "https://some.url:1234"}, + ) with patch( "homeassistant.components.nightscout.NightscoutAPI.get_sgvs", side_effect=ClientConnectionError(), @@ -60,7 +66,10 @@ async def init_integration_unavailable(hass) -> MockConfigEntry: async def init_integration_empty_response(hass) -> MockConfigEntry: """Set up the Nightscout integration in Home Assistant.""" - entry = MockConfigEntry(domain=DOMAIN, data={CONF_URL: "https://some.url:1234"},) + entry = MockConfigEntry( + domain=DOMAIN, + data={CONF_URL: "https://some.url:1234"}, + ) with patch( "homeassistant.components.nightscout.NightscoutAPI.get_sgvs", return_value=[] ), patch( diff --git a/tests/components/nightscout/test_config_flow.py b/tests/components/nightscout/test_config_flow.py index 99eae99160a..a5f3315fbb1 100644 --- a/tests/components/nightscout/test_config_flow.py +++ b/tests/components/nightscout/test_config_flow.py @@ -24,7 +24,8 @@ async def test_form(hass): with _patch_glucose_readings(), _patch_server_status(), _patch_async_setup() as mock_setup, _patch_async_setup_entry() as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], CONFIG, + result["flow_id"], + CONFIG, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY @@ -46,7 +47,8 @@ async def test_user_form_cannot_connect(hass): side_effect=ClientConnectionError(), ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_URL: "https://some.url:1234"}, + result["flow_id"], + {CONF_URL: "https://some.url:1234"}, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -64,7 +66,8 @@ async def test_user_form_unexpected_exception(hass): side_effect=Exception(), ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_URL: "https://some.url:1234"}, + result["flow_id"], + {CONF_URL: "https://some.url:1234"}, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -78,7 +81,9 @@ async def test_user_form_duplicate(hass): entry = MockConfigEntry(domain=DOMAIN, unique_id=unique_id) await hass.config_entries.async_add(entry) result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_USER}, data=CONFIG, + DOMAIN, + context={"source": config_entries.SOURCE_USER}, + data=CONFIG, ) assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["reason"] == "already_configured" @@ -90,7 +95,8 @@ def _patch_async_setup(): def _patch_async_setup_entry(): return patch( - "homeassistant.components.nightscout.async_setup_entry", return_value=True, + "homeassistant.components.nightscout.async_setup_entry", + return_value=True, ) diff --git a/tests/components/nightscout/test_init.py b/tests/components/nightscout/test_init.py index 94953b7e5b2..d81559ceba7 100644 --- a/tests/components/nightscout/test_init.py +++ b/tests/components/nightscout/test_init.py @@ -31,7 +31,8 @@ async def test_unload_entry(hass): async def test_async_setup_raises_entry_not_ready(hass): """Test that it throws ConfigEntryNotReady when exception occurs during setup.""" config_entry = MockConfigEntry( - domain=DOMAIN, data={CONF_URL: "https://some.url:1234"}, + domain=DOMAIN, + data={CONF_URL: "https://some.url:1234"}, ) config_entry.add_to_hass(hass) diff --git a/tests/components/nuheat/test_climate.py b/tests/components/nuheat/test_climate.py index b407461fa89..51e80e6b3c1 100644 --- a/tests/components/nuheat/test_climate.py +++ b/tests/components/nuheat/test_climate.py @@ -20,7 +20,8 @@ async def test_climate_thermostat_run(hass): mock_nuheat = _get_mock_nuheat(get_thermostat=mock_thermostat) with patch( - "homeassistant.components.nuheat.nuheat.NuHeat", return_value=mock_nuheat, + "homeassistant.components.nuheat.nuheat.NuHeat", + return_value=mock_nuheat, ): assert await async_setup_component(hass, DOMAIN, _mock_get_config()) await hass.async_block_till_done() @@ -50,7 +51,8 @@ async def test_climate_thermostat_schedule_hold_unavailable(hass): mock_nuheat = _get_mock_nuheat(get_thermostat=mock_thermostat) with patch( - "homeassistant.components.nuheat.nuheat.NuHeat", return_value=mock_nuheat, + "homeassistant.components.nuheat.nuheat.NuHeat", + return_value=mock_nuheat, ): assert await async_setup_component(hass, DOMAIN, _mock_get_config()) await hass.async_block_till_done() @@ -77,7 +79,8 @@ async def test_climate_thermostat_schedule_hold_available(hass): mock_nuheat = _get_mock_nuheat(get_thermostat=mock_thermostat) with patch( - "homeassistant.components.nuheat.nuheat.NuHeat", return_value=mock_nuheat, + "homeassistant.components.nuheat.nuheat.NuHeat", + return_value=mock_nuheat, ): assert await async_setup_component(hass, DOMAIN, _mock_get_config()) await hass.async_block_till_done() @@ -108,7 +111,8 @@ async def test_climate_thermostat_schedule_temporary_hold(hass): mock_nuheat = _get_mock_nuheat(get_thermostat=mock_thermostat) with patch( - "homeassistant.components.nuheat.nuheat.NuHeat", return_value=mock_nuheat, + "homeassistant.components.nuheat.nuheat.NuHeat", + return_value=mock_nuheat, ): assert await async_setup_component(hass, DOMAIN, _mock_get_config()) await hass.async_block_till_done() diff --git a/tests/components/nuheat/test_init.py b/tests/components/nuheat/test_init.py index 4a7a8673230..8cd08f2edd5 100644 --- a/tests/components/nuheat/test_init.py +++ b/tests/components/nuheat/test_init.py @@ -17,7 +17,8 @@ async def test_init_success(hass): mock_nuheat = _get_mock_nuheat() with patch( - "homeassistant.components.nuheat.nuheat.NuHeat", return_value=mock_nuheat, + "homeassistant.components.nuheat.nuheat.NuHeat", + return_value=mock_nuheat, ): assert await async_setup_component(hass, DOMAIN, VALID_CONFIG) await hass.async_block_till_done() diff --git a/tests/components/nut/test_config_flow.py b/tests/components/nut/test_config_flow.py index d86c0d8eb88..8d50d77c31d 100644 --- a/tests/components/nut/test_config_flow.py +++ b/tests/components/nut/test_config_flow.py @@ -33,7 +33,8 @@ async def test_form_zeroconf(hass): ) with patch( - "homeassistant.components.nut.PyNUTClient", return_value=mock_pynut, + "homeassistant.components.nut.PyNUTClient", + return_value=mock_pynut, ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -44,11 +45,13 @@ async def test_form_zeroconf(hass): assert result2["type"] == "form" with patch( - "homeassistant.components.nut.PyNUTClient", return_value=mock_pynut, + "homeassistant.components.nut.PyNUTClient", + return_value=mock_pynut, ), patch( "homeassistant.components.nut.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.nut.async_setup_entry", return_value=True, + "homeassistant.components.nut.async_setup_entry", + return_value=True, ) as mock_setup_entry: result3 = await hass.config_entries.flow.async_configure( result2["flow_id"], @@ -84,7 +87,8 @@ async def test_form_user_one_ups(hass): ) with patch( - "homeassistant.components.nut.PyNUTClient", return_value=mock_pynut, + "homeassistant.components.nut.PyNUTClient", + return_value=mock_pynut, ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -100,11 +104,13 @@ async def test_form_user_one_ups(hass): assert result2["type"] == "form" with patch( - "homeassistant.components.nut.PyNUTClient", return_value=mock_pynut, + "homeassistant.components.nut.PyNUTClient", + return_value=mock_pynut, ), patch( "homeassistant.components.nut.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.nut.async_setup_entry", return_value=True, + "homeassistant.components.nut.async_setup_entry", + return_value=True, ) as mock_setup_entry: result3 = await hass.config_entries.flow.async_configure( result2["flow_id"], @@ -148,7 +154,8 @@ async def test_form_user_multiple_ups(hass): ) with patch( - "homeassistant.components.nut.PyNUTClient", return_value=mock_pynut, + "homeassistant.components.nut.PyNUTClient", + return_value=mock_pynut, ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -164,24 +171,29 @@ async def test_form_user_multiple_ups(hass): assert result2["type"] == "form" with patch( - "homeassistant.components.nut.PyNUTClient", return_value=mock_pynut, + "homeassistant.components.nut.PyNUTClient", + return_value=mock_pynut, ): result3 = await hass.config_entries.flow.async_configure( - result2["flow_id"], {"alias": "ups2"}, + result2["flow_id"], + {"alias": "ups2"}, ) assert result3["step_id"] == "resources" assert result3["type"] == "form" with patch( - "homeassistant.components.nut.PyNUTClient", return_value=mock_pynut, + "homeassistant.components.nut.PyNUTClient", + return_value=mock_pynut, ), patch( "homeassistant.components.nut.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.nut.async_setup_entry", return_value=True, + "homeassistant.components.nut.async_setup_entry", + return_value=True, ) as mock_setup_entry: result4 = await hass.config_entries.flow.async_configure( - result3["flow_id"], {"resources": ["battery.voltage"]}, + result3["flow_id"], + {"resources": ["battery.voltage"]}, ) assert result4["type"] == "create_entry" @@ -209,11 +221,13 @@ async def test_form_import(hass): ) with patch( - "homeassistant.components.nut.PyNUTClient", return_value=mock_pynut, + "homeassistant.components.nut.PyNUTClient", + return_value=mock_pynut, ), patch( "homeassistant.components.nut.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.nut.async_setup_entry", return_value=True, + "homeassistant.components.nut.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, @@ -280,7 +294,8 @@ async def test_form_cannot_connect(hass): mock_pynut = _get_mock_pynutclient() with patch( - "homeassistant.components.nut.PyNUTClient", return_value=mock_pynut, + "homeassistant.components.nut.PyNUTClient", + return_value=mock_pynut, ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -312,7 +327,8 @@ async def test_options_flow(hass): ) with patch( - "homeassistant.components.nut.PyNUTClient", return_value=mock_pynut, + "homeassistant.components.nut.PyNUTClient", + return_value=mock_pynut, ), patch("homeassistant.components.nut.async_setup_entry", return_value=True): result = await hass.config_entries.options.async_init(config_entry.entry_id) @@ -330,7 +346,8 @@ async def test_options_flow(hass): } with patch( - "homeassistant.components.nut.PyNUTClient", return_value=mock_pynut, + "homeassistant.components.nut.PyNUTClient", + return_value=mock_pynut, ), patch("homeassistant.components.nut.async_setup_entry", return_value=True): result2 = await hass.config_entries.options.async_init(config_entry.entry_id) diff --git a/tests/components/nut/util.py b/tests/components/nut/util.py index 5622438d70b..772667b6b50 100644 --- a/tests/components/nut/util.py +++ b/tests/components/nut/util.py @@ -28,7 +28,8 @@ async def async_init_integration( mock_pynut = _get_mock_pynutclient(list_ups={"ups1": "UPS 1"}, list_vars=list_vars) with patch( - "homeassistant.components.nut.PyNUTClient", return_value=mock_pynut, + "homeassistant.components.nut.PyNUTClient", + return_value=mock_pynut, ): entry = MockConfigEntry( domain=DOMAIN, diff --git a/tests/components/nws/test_config_flow.py b/tests/components/nws/test_config_flow.py index bca852fa379..72e02f32b9d 100644 --- a/tests/components/nws/test_config_flow.py +++ b/tests/components/nws/test_config_flow.py @@ -22,7 +22,8 @@ async def test_form(hass, mock_simple_nws_config): with patch( "homeassistant.components.nws.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.nws.async_setup_entry", return_value=True, + "homeassistant.components.nws.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], {"api_key": "test"} @@ -51,7 +52,8 @@ async def test_form_cannot_connect(hass, mock_simple_nws_config): ) result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"api_key": "test"}, + result["flow_id"], + {"api_key": "test"}, ) assert result2["type"] == "form" @@ -68,7 +70,8 @@ async def test_form_unknown_error(hass, mock_simple_nws_config): ) result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"api_key": "test"}, + result["flow_id"], + {"api_key": "test"}, ) assert result2["type"] == "form" @@ -84,10 +87,12 @@ async def test_form_already_configured(hass, mock_simple_nws_config): with patch( "homeassistant.components.nws.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.nws.async_setup_entry", return_value=True, + "homeassistant.components.nws.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"api_key": "test"}, + result["flow_id"], + {"api_key": "test"}, ) assert result2["type"] == "create_entry" @@ -102,10 +107,12 @@ async def test_form_already_configured(hass, mock_simple_nws_config): with patch( "homeassistant.components.nws.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.nws.async_setup_entry", return_value=True, + "homeassistant.components.nws.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"api_key": "test"}, + result["flow_id"], + {"api_key": "test"}, ) assert result2["type"] == "abort" assert result2["reason"] == "already_configured" diff --git a/tests/components/nws/test_init.py b/tests/components/nws/test_init.py index 68c1e8c8130..9d4acd7dde1 100644 --- a/tests/components/nws/test_init.py +++ b/tests/components/nws/test_init.py @@ -8,7 +8,10 @@ from tests.components.nws.const import NWS_CONFIG async def test_unload_entry(hass, mock_simple_nws): """Test that nws setup with config yaml.""" - entry = MockConfigEntry(domain=DOMAIN, data=NWS_CONFIG,) + entry = MockConfigEntry( + domain=DOMAIN, + data=NWS_CONFIG, + ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) diff --git a/tests/components/nws/test_weather.py b/tests/components/nws/test_weather.py index 1486015d80e..06053302ec7 100644 --- a/tests/components/nws/test_weather.py +++ b/tests/components/nws/test_weather.py @@ -35,7 +35,10 @@ async def test_imperial_metric( ): """Test with imperial and metric units.""" hass.config.units = units - entry = MockConfigEntry(domain=nws.DOMAIN, data=NWS_CONFIG,) + entry = MockConfigEntry( + domain=nws.DOMAIN, + data=NWS_CONFIG, + ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() @@ -73,7 +76,10 @@ async def test_none_values(hass, mock_simple_nws): instance.observation = NONE_OBSERVATION instance.forecast = NONE_FORECAST - entry = MockConfigEntry(domain=nws.DOMAIN, data=NWS_CONFIG,) + entry = MockConfigEntry( + domain=nws.DOMAIN, + data=NWS_CONFIG, + ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() @@ -95,7 +101,10 @@ async def test_none(hass, mock_simple_nws): instance.observation = None instance.forecast = None - entry = MockConfigEntry(domain=nws.DOMAIN, data=NWS_CONFIG,) + entry = MockConfigEntry( + domain=nws.DOMAIN, + data=NWS_CONFIG, + ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() @@ -118,7 +127,10 @@ async def test_error_station(hass, mock_simple_nws): instance = mock_simple_nws.return_value instance.set_station.side_effect = aiohttp.ClientError - entry = MockConfigEntry(domain=nws.DOMAIN, data=NWS_CONFIG,) + entry = MockConfigEntry( + domain=nws.DOMAIN, + data=NWS_CONFIG, + ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() @@ -133,7 +145,10 @@ async def test_entity_refresh(hass, mock_simple_nws): await async_setup_component(hass, "homeassistant", {}) - entry = MockConfigEntry(domain=nws.DOMAIN, data=NWS_CONFIG,) + entry = MockConfigEntry( + domain=nws.DOMAIN, + data=NWS_CONFIG, + ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() @@ -171,7 +186,10 @@ async def test_error_observation(hass, mock_simple_nws): # first update fails instance.update_observation.side_effect = aiohttp.ClientError - entry = MockConfigEntry(domain=nws.DOMAIN, data=NWS_CONFIG,) + entry = MockConfigEntry( + domain=nws.DOMAIN, + data=NWS_CONFIG, + ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() @@ -235,7 +253,10 @@ async def test_error_forecast(hass, mock_simple_nws): instance = mock_simple_nws.return_value instance.update_forecast.side_effect = aiohttp.ClientError - entry = MockConfigEntry(domain=nws.DOMAIN, data=NWS_CONFIG,) + entry = MockConfigEntry( + domain=nws.DOMAIN, + data=NWS_CONFIG, + ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() @@ -263,7 +284,10 @@ async def test_error_forecast_hourly(hass, mock_simple_nws): instance = mock_simple_nws.return_value instance.update_forecast_hourly.side_effect = aiohttp.ClientError - entry = MockConfigEntry(domain=nws.DOMAIN, data=NWS_CONFIG,) + entry = MockConfigEntry( + domain=nws.DOMAIN, + data=NWS_CONFIG, + ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() diff --git a/tests/components/onvif/test_config_flow.py b/tests/components/onvif/test_config_flow.py index 5c41349bbbe..864968f848d 100644 --- a/tests/components/onvif/test_config_flow.py +++ b/tests/components/onvif/test_config_flow.py @@ -130,7 +130,12 @@ def setup_mock_device(mock_device): async def setup_onvif_integration( - hass, config=None, options=None, unique_id=MAC, entry_id="1", source="user", + hass, + config=None, + options=None, + unique_id=MAC, + entry_id="1", + source="user", ): """Create an ONVIF config entry.""" if not config: @@ -353,7 +358,8 @@ async def test_flow_manual_entry(hass): setup_mock_device(mock_device) result = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input={}, + result["flow_id"], + user_input={}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM diff --git a/tests/components/opentherm_gw/test_config_flow.py b/tests/components/opentherm_gw/test_config_flow.py index 003d2ad7170..a696bc47590 100644 --- a/tests/components/opentherm_gw/test_config_flow.py +++ b/tests/components/opentherm_gw/test_config_flow.py @@ -26,11 +26,14 @@ async def test_form_user(hass): assert result["errors"] == {} with patch( - "homeassistant.components.opentherm_gw.async_setup", return_value=True, + "homeassistant.components.opentherm_gw.async_setup", + return_value=True, ) as mock_setup, patch( - "homeassistant.components.opentherm_gw.async_setup_entry", return_value=True, + "homeassistant.components.opentherm_gw.async_setup_entry", + return_value=True, ) as mock_setup_entry, patch( - "pyotgw.pyotgw.connect", return_value={OTGW_ABOUT: "OpenTherm Gateway 4.2.5"}, + "pyotgw.pyotgw.connect", + return_value={OTGW_ABOUT: "OpenTherm Gateway 4.2.5"}, ) as mock_pyotgw_connect, patch( "pyotgw.pyotgw.disconnect", return_value=None ) as mock_pyotgw_disconnect: @@ -56,11 +59,14 @@ async def test_form_import(hass): """Test import from existing config.""" await setup.async_setup_component(hass, "persistent_notification", {}) with patch( - "homeassistant.components.opentherm_gw.async_setup", return_value=True, + "homeassistant.components.opentherm_gw.async_setup", + return_value=True, ) as mock_setup, patch( - "homeassistant.components.opentherm_gw.async_setup_entry", return_value=True, + "homeassistant.components.opentherm_gw.async_setup_entry", + return_value=True, ) as mock_setup_entry, patch( - "pyotgw.pyotgw.connect", return_value={OTGW_ABOUT: "OpenTherm Gateway 4.2.5"}, + "pyotgw.pyotgw.connect", + return_value={OTGW_ABOUT: "OpenTherm Gateway 4.2.5"}, ) as mock_pyotgw_connect, patch( "pyotgw.pyotgw.disconnect", return_value=None ) as mock_pyotgw_disconnect: @@ -96,11 +102,14 @@ async def test_form_duplicate_entries(hass): ) with patch( - "homeassistant.components.opentherm_gw.async_setup", return_value=True, + "homeassistant.components.opentherm_gw.async_setup", + return_value=True, ) as mock_setup, patch( - "homeassistant.components.opentherm_gw.async_setup_entry", return_value=True, + "homeassistant.components.opentherm_gw.async_setup_entry", + return_value=True, ) as mock_setup_entry, patch( - "pyotgw.pyotgw.connect", return_value={OTGW_ABOUT: "OpenTherm Gateway 4.2.5"}, + "pyotgw.pyotgw.connect", + return_value={OTGW_ABOUT: "OpenTherm Gateway 4.2.5"}, ) as mock_pyotgw_connect, patch( "pyotgw.pyotgw.disconnect", return_value=None ) as mock_pyotgw_disconnect: diff --git a/tests/components/openuv/test_config_flow.py b/tests/components/openuv/test_config_flow.py index 06eca531d2d..9c07322acca 100644 --- a/tests/components/openuv/test_config_flow.py +++ b/tests/components/openuv/test_config_flow.py @@ -20,9 +20,11 @@ from tests.common import MockConfigEntry def mock_setup(): """Prevent setup.""" with patch( - "homeassistant.components.openuv.async_setup", return_value=True, + "homeassistant.components.openuv.async_setup", + return_value=True, ), patch( - "homeassistant.components.openuv.async_setup_entry", return_value=True, + "homeassistant.components.openuv.async_setup_entry", + return_value=True, ): yield @@ -58,7 +60,8 @@ async def test_invalid_api_key(hass): } with patch( - "pyopenuv.client.Client.uv_index", side_effect=InvalidApiKeyError, + "pyopenuv.client.Client.uv_index", + side_effect=InvalidApiKeyError, ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=conf diff --git a/tests/components/ovo_energy/test_config_flow.py b/tests/components/ovo_energy/test_config_flow.py index 73b2610cc7a..b89a9729c35 100644 --- a/tests/components/ovo_energy/test_config_flow.py +++ b/tests/components/ovo_energy/test_config_flow.py @@ -35,7 +35,8 @@ async def test_authorization_error(hass: HomeAssistant) -> None: return_value=False, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], FIXTURE_USER_INPUT, + result["flow_id"], + FIXTURE_USER_INPUT, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -57,7 +58,8 @@ async def test_connection_error(hass: HomeAssistant) -> None: side_effect=aiohttp.ClientError, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], FIXTURE_USER_INPUT, + result["flow_id"], + FIXTURE_USER_INPUT, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -79,7 +81,8 @@ async def test_full_flow_implementation(hass: HomeAssistant) -> None: return_value=True, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], FIXTURE_USER_INPUT, + result["flow_id"], + FIXTURE_USER_INPUT, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY diff --git a/tests/components/owntracks/test_config_flow.py b/tests/components/owntracks/test_config_flow.py index 3e6101e1989..396870c2975 100644 --- a/tests/components/owntracks/test_config_flow.py +++ b/tests/components/owntracks/test_config_flow.py @@ -50,7 +50,8 @@ def mock_not_supports_encryption(): async def init_config_flow(hass): """Init a configuration flow.""" await async_process_ha_core_config( - hass, {"external_url": BASE_URL}, + hass, + {"external_url": BASE_URL}, ) flow = config_flow.OwnTracksFlow() flow.hass = hass @@ -90,7 +91,8 @@ async def test_import(hass, webhook_id, secret): async def test_import_setup(hass): """Test that we automatically create a config flow.""" await async_process_ha_core_config( - hass, {"external_url": "http://example.com"}, + hass, + {"external_url": "http://example.com"}, ) assert not hass.config_entries.async_entries(DOMAIN) @@ -132,7 +134,8 @@ async def test_user_not_supports_encryption(hass, not_supports_encryption): async def test_unload(hass): """Test unloading a config flow.""" await async_process_ha_core_config( - hass, {"external_url": "http://example.com"}, + hass, + {"external_url": "http://example.com"}, ) with patch( diff --git a/tests/components/ozw/test_config_flow.py b/tests/components/ozw/test_config_flow.py index bfe3f922402..3446bbfc7de 100644 --- a/tests/components/ozw/test_config_flow.py +++ b/tests/components/ozw/test_config_flow.py @@ -20,7 +20,8 @@ async def test_user_create_entry(hass): with patch( "homeassistant.components.ozw.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.ozw.async_setup_entry", return_value=True, + "homeassistant.components.ozw.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) diff --git a/tests/components/panasonic_viera/test_config_flow.py b/tests/components/panasonic_viera/test_config_flow.py index 0e7731dbdc0..5359811c52c 100644 --- a/tests/components/panasonic_viera/test_config_flow.py +++ b/tests/components/panasonic_viera/test_config_flow.py @@ -27,7 +27,8 @@ def panasonic_viera_setup_fixture(): with patch( "homeassistant.components.panasonic_viera.async_setup", return_value=True ), patch( - "homeassistant.components.panasonic_viera.async_setup_entry", return_value=True, + "homeassistant.components.panasonic_viera.async_setup_entry", + return_value=True, ): yield @@ -80,7 +81,8 @@ async def test_flow_non_encrypted(hass): return_value=mock_remote, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_HOST: "1.2.3.4", CONF_NAME: DEFAULT_NAME}, + result["flow_id"], + {CONF_HOST: "1.2.3.4", CONF_NAME: DEFAULT_NAME}, ) assert result["type"] == "create_entry" @@ -108,7 +110,8 @@ async def test_flow_not_connected_error(hass): side_effect=TimeoutError, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_HOST: "1.2.3.4", CONF_NAME: DEFAULT_NAME}, + result["flow_id"], + {CONF_HOST: "1.2.3.4", CONF_NAME: DEFAULT_NAME}, ) assert result["type"] == "form" @@ -131,7 +134,8 @@ async def test_flow_unknown_abort(hass): side_effect=Exception, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_HOST: "1.2.3.4", CONF_NAME: DEFAULT_NAME}, + result["flow_id"], + {CONF_HOST: "1.2.3.4", CONF_NAME: DEFAULT_NAME}, ) assert result["type"] == "abort" @@ -149,7 +153,9 @@ async def test_flow_encrypted_valid_pin_code(hass): assert result["step_id"] == "user" mock_remote = get_mock_remote( - encrypted=True, app_id="test-app-id", encryption_key="test-encryption-key", + encrypted=True, + app_id="test-app-id", + encryption_key="test-encryption-key", ) with patch( @@ -157,14 +163,16 @@ async def test_flow_encrypted_valid_pin_code(hass): return_value=mock_remote, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_HOST: "1.2.3.4", CONF_NAME: DEFAULT_NAME}, + result["flow_id"], + {CONF_HOST: "1.2.3.4", CONF_NAME: DEFAULT_NAME}, ) assert result["type"] == "form" assert result["step_id"] == "pairing" result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_PIN: "1234"}, + result["flow_id"], + {CONF_PIN: "1234"}, ) assert result["type"] == "create_entry" @@ -196,7 +204,8 @@ async def test_flow_encrypted_invalid_pin_code_error(hass): return_value=mock_remote, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_HOST: "1.2.3.4", CONF_NAME: DEFAULT_NAME}, + result["flow_id"], + {CONF_HOST: "1.2.3.4", CONF_NAME: DEFAULT_NAME}, ) assert result["type"] == "form" @@ -207,7 +216,8 @@ async def test_flow_encrypted_invalid_pin_code_error(hass): return_value=mock_remote, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_PIN: "0000"}, + result["flow_id"], + {CONF_PIN: "0000"}, ) assert result["type"] == "form" @@ -232,14 +242,16 @@ async def test_flow_encrypted_not_connected_abort(hass): return_value=mock_remote, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_HOST: "1.2.3.4", CONF_NAME: DEFAULT_NAME}, + result["flow_id"], + {CONF_HOST: "1.2.3.4", CONF_NAME: DEFAULT_NAME}, ) assert result["type"] == "form" assert result["step_id"] == "pairing" result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_PIN: "0000"}, + result["flow_id"], + {CONF_PIN: "0000"}, ) assert result["type"] == "abort" @@ -263,14 +275,16 @@ async def test_flow_encrypted_unknown_abort(hass): return_value=mock_remote, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_HOST: "1.2.3.4", CONF_NAME: DEFAULT_NAME}, + result["flow_id"], + {CONF_HOST: "1.2.3.4", CONF_NAME: DEFAULT_NAME}, ) assert result["type"] == "form" assert result["step_id"] == "pairing" result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_PIN: "0000"}, + result["flow_id"], + {CONF_PIN: "0000"}, ) assert result["type"] == "abort" @@ -355,7 +369,9 @@ async def test_imported_flow_encrypted_valid_pin_code(hass): """Test imported flow with encryption and valid PIN code.""" mock_remote = get_mock_remote( - encrypted=True, app_id="test-app-id", encryption_key="test-encryption-key", + encrypted=True, + app_id="test-app-id", + encryption_key="test-encryption-key", ) with patch( @@ -377,7 +393,8 @@ async def test_imported_flow_encrypted_valid_pin_code(hass): assert result["step_id"] == "pairing" result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_PIN: "1234"}, + result["flow_id"], + {CONF_PIN: "1234"}, ) assert result["type"] == "create_entry" @@ -420,7 +437,8 @@ async def test_imported_flow_encrypted_invalid_pin_code_error(hass): return_value=mock_remote, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_PIN: "0000"}, + result["flow_id"], + {CONF_PIN: "0000"}, ) assert result["type"] == "form" @@ -452,7 +470,8 @@ async def test_imported_flow_encrypted_not_connected_abort(hass): assert result["step_id"] == "pairing" result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_PIN: "0000"}, + result["flow_id"], + {CONF_PIN: "0000"}, ) assert result["type"] == "abort" @@ -483,7 +502,8 @@ async def test_imported_flow_encrypted_unknown_abort(hass): assert result["step_id"] == "pairing" result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_PIN: "0000"}, + result["flow_id"], + {CONF_PIN: "0000"}, ) assert result["type"] == "abort" diff --git a/tests/components/panasonic_viera/test_init.py b/tests/components/panasonic_viera/test_init.py index 327ab5829c1..a4a1ca94fe5 100644 --- a/tests/components/panasonic_viera/test_init.py +++ b/tests/components/panasonic_viera/test_init.py @@ -52,7 +52,8 @@ async def test_setup_entry_encrypted(hass): mock_remote = get_mock_remote() with patch( - "homeassistant.components.panasonic_viera.Remote", return_value=mock_remote, + "homeassistant.components.panasonic_viera.Remote", + return_value=mock_remote, ): await hass.config_entries.async_setup(mock_entry.entry_id) await hass.async_block_till_done() @@ -66,7 +67,9 @@ async def test_setup_entry_encrypted(hass): async def test_setup_entry_unencrypted(hass): """Test setup with unencrypted config entry.""" mock_entry = MockConfigEntry( - domain=DOMAIN, unique_id=MOCK_CONFIG_DATA[CONF_HOST], data=MOCK_CONFIG_DATA, + domain=DOMAIN, + unique_id=MOCK_CONFIG_DATA[CONF_HOST], + data=MOCK_CONFIG_DATA, ) mock_entry.add_to_hass(hass) @@ -74,7 +77,8 @@ async def test_setup_entry_unencrypted(hass): mock_remote = get_mock_remote() with patch( - "homeassistant.components.panasonic_viera.Remote", return_value=mock_remote, + "homeassistant.components.panasonic_viera.Remote", + return_value=mock_remote, ): await hass.config_entries.async_setup(mock_entry.entry_id) await hass.async_block_till_done() @@ -88,7 +92,11 @@ async def test_setup_entry_unencrypted(hass): async def test_setup_config_flow_initiated(hass): """Test if config flow is initiated in setup.""" assert ( - await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_HOST: "0.0.0.0"}},) + await async_setup_component( + hass, + DOMAIN, + {DOMAIN: {CONF_HOST: "0.0.0.0"}}, + ) is True ) @@ -106,7 +114,8 @@ async def test_setup_unload_entry(hass): mock_remote = get_mock_remote() with patch( - "homeassistant.components.panasonic_viera.Remote", return_value=mock_remote, + "homeassistant.components.panasonic_viera.Remote", + return_value=mock_remote, ): await hass.config_entries.async_setup(mock_entry.entry_id) await hass.async_block_till_done() diff --git a/tests/components/pi_hole/test_config_flow.py b/tests/components/pi_hole/test_config_flow.py index 07a9e08313a..714f211d4f8 100644 --- a/tests/components/pi_hole/test_config_flow.py +++ b/tests/components/pi_hole/test_config_flow.py @@ -30,7 +30,8 @@ def _flow_next(hass, flow_id): def _patch_setup(): return patch( - "homeassistant.components.pi_hole.async_setup_entry", return_value=True, + "homeassistant.components.pi_hole.async_setup_entry", + return_value=True, ) @@ -70,7 +71,8 @@ async def test_flow_user(hass): mocked_hole = _create_mocked_hole() with _patch_config_flow_hole(mocked_hole), _patch_setup(): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, + DOMAIN, + context={"source": SOURCE_USER}, ) assert result["type"] == RESULT_TYPE_FORM assert result["step_id"] == "user" @@ -78,7 +80,8 @@ async def test_flow_user(hass): _flow_next(hass, result["flow_id"]) result = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input=CONF_CONFIG_FLOW, + result["flow_id"], + user_input=CONF_CONFIG_FLOW, ) assert result["type"] == RESULT_TYPE_CREATE_ENTRY assert result["title"] == NAME @@ -86,7 +89,9 @@ async def test_flow_user(hass): # duplicated server result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data=CONF_CONFIG_FLOW, + DOMAIN, + context={"source": SOURCE_USER}, + data=CONF_CONFIG_FLOW, ) assert result["type"] == RESULT_TYPE_ABORT assert result["reason"] == "already_configured" diff --git a/tests/components/plant/test_init.py b/tests/components/plant/test_init.py index 991eb1d385d..866702488dc 100644 --- a/tests/components/plant/test_init.py +++ b/tests/components/plant/test_init.py @@ -71,7 +71,8 @@ async def test_low_battery(hass): sensor.hass = hass assert sensor.state_attributes["problem"] == "none" sensor.state_changed( - "sensor.mqtt_plant_battery", State("sensor.mqtt_plant_battery", 10), + "sensor.mqtt_plant_battery", + State("sensor.mqtt_plant_battery", 10), ) assert sensor.state == "problem" assert sensor.state_attributes["problem"] == "battery low" diff --git a/tests/components/plex/test_config_flow.py b/tests/components/plex/test_config_flow.py index 92124b7b39c..1bd2ce82863 100644 --- a/tests/components/plex/test_config_flow.py +++ b/tests/components/plex/test_config_flow.py @@ -45,7 +45,8 @@ from tests.common import MockConfigEntry async def test_bad_credentials(hass): """Test when provided credentials are rejected.""" await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) result = await hass.config_entries.flow.async_init( @@ -79,7 +80,8 @@ async def test_bad_hostname(hass): mock_plex_account = MockPlexAccount() await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) result = await hass.config_entries.flow.async_init( @@ -115,7 +117,8 @@ async def test_bad_hostname(hass): async def test_unknown_exception(hass): """Test when an unknown exception is encountered.""" await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) result = await hass.config_entries.flow.async_init( @@ -144,7 +147,8 @@ async def test_no_servers_found(hass): """Test when no servers are on an account.""" await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) result = await hass.config_entries.flow.async_init( @@ -178,7 +182,8 @@ async def test_single_available_server(hass): mock_plex_server = MockPlexServer() await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) result = await hass.config_entries.flow.async_init( @@ -217,7 +222,8 @@ async def test_multiple_servers_with_selection(hass): mock_plex_server = MockPlexServer() await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) result = await hass.config_entries.flow.async_init( @@ -246,7 +252,8 @@ async def test_multiple_servers_with_selection(hass): assert result["step_id"] == "select_server" result = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input={CONF_SERVER: MOCK_SERVERS[0][CONF_SERVER]}, + result["flow_id"], + user_input={CONF_SERVER: MOCK_SERVERS[0][CONF_SERVER]}, ) assert result["type"] == "create_entry" assert result["title"] == mock_plex_server.friendlyName @@ -264,7 +271,8 @@ async def test_adding_last_unconfigured_server(hass): mock_plex_server = MockPlexServer() await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) MockConfigEntry( @@ -311,7 +319,8 @@ async def test_all_available_servers_configured(hass): """Test when all available servers are already configured.""" await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) MockConfigEntry( @@ -503,7 +512,8 @@ async def test_external_timed_out(hass): """Test when external flow times out.""" await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) result = await hass.config_entries.flow.async_init( @@ -532,7 +542,8 @@ async def test_callback_view(hass, aiohttp_client): """Test callback view.""" await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) result = await hass.config_entries.flow.async_init( @@ -559,7 +570,8 @@ async def test_callback_view(hass, aiohttp_client): async def test_manual_config(hass): """Test creating via manual configuration.""" await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) class WrongCertValidaitionException(requests.exceptions.SSLError): @@ -638,7 +650,8 @@ async def test_manual_config(hass): assert result["errors"]["base"] == "host_or_token" with patch( - "plexapi.server.PlexServer", side_effect=requests.exceptions.SSLError, + "plexapi.server.PlexServer", + side_effect=requests.exceptions.SSLError, ): result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input=MANUAL_SERVER @@ -649,7 +662,8 @@ async def test_manual_config(hass): assert result["errors"]["base"] == "ssl_error" with patch( - "plexapi.server.PlexServer", side_effect=WrongCertValidaitionException, + "plexapi.server.PlexServer", + side_effect=WrongCertValidaitionException, ): result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input=MANUAL_SERVER diff --git a/tests/components/plex/test_init.py b/tests/components/plex/test_init.py index fa60f4dd7d2..666a819e8ca 100644 --- a/tests/components/plex/test_init.py +++ b/tests/components/plex/test_init.py @@ -30,7 +30,10 @@ async def test_set_config_entry_unique_id(hass): mock_plex_server = MockPlexServer() entry = MockConfigEntry( - domain=const.DOMAIN, data=DEFAULT_DATA, options=DEFAULT_OPTIONS, unique_id=None, + domain=const.DOMAIN, + data=DEFAULT_DATA, + options=DEFAULT_OPTIONS, + unique_id=None, ) with patch("plexapi.server.PlexServer", return_value=mock_plex_server), patch( diff --git a/tests/components/plugwise/test_config_flow.py b/tests/components/plugwise/test_config_flow.py index feb695aae81..4d8a78f11c8 100644 --- a/tests/components/plugwise/test_config_flow.py +++ b/tests/components/plugwise/test_config_flow.py @@ -11,7 +11,9 @@ from tests.async_mock import patch @pytest.fixture(name="mock_smile") def mock_smile(): """Create a Mock Smile for testing exceptions.""" - with patch("homeassistant.components.plugwise.config_flow.Smile",) as smile_mock: + with patch( + "homeassistant.components.plugwise.config_flow.Smile", + ) as smile_mock: smile_mock.PlugwiseError = Smile.PlugwiseError smile_mock.InvalidAuthentication = Smile.InvalidAuthentication smile_mock.ConnectionFailedError = Smile.ConnectionFailedError @@ -32,12 +34,15 @@ async def test_form(hass): "homeassistant.components.plugwise.config_flow.Smile.connect", return_value=True, ), patch( - "homeassistant.components.plugwise.async_setup", return_value=True, + "homeassistant.components.plugwise.async_setup", + return_value=True, ) as mock_setup, patch( - "homeassistant.components.plugwise.async_setup_entry", return_value=True, + "homeassistant.components.plugwise.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", "password": "test-password"}, + result["flow_id"], + {"host": "1.1.1.1", "password": "test-password"}, ) assert result2["type"] == "create_entry" @@ -60,7 +65,8 @@ async def test_form_invalid_auth(hass, mock_smile): mock_smile.gateway_id = "0a636a4fc1704ab4a24e4f7e37fb187a" result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": "1.1.1.1", "password": "test-password"}, + result["flow_id"], + {"host": "1.1.1.1", "password": "test-password"}, ) assert result2["type"] == "form" @@ -77,7 +83,8 @@ async def test_form_cannot_connect(hass, mock_smile): mock_smile.gateway_id = "0a636a4fc1704ab4a24e4f7e37fb187a" result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": "1.1.1.1", "password": "test-password"}, + result["flow_id"], + {"host": "1.1.1.1", "password": "test-password"}, ) assert result2["type"] == "form" diff --git a/tests/components/plum_lightpad/test_config_flow.py b/tests/components/plum_lightpad/test_config_flow.py index 9fc32f9872c..7f6196ef9b7 100644 --- a/tests/components/plum_lightpad/test_config_flow.py +++ b/tests/components/plum_lightpad/test_config_flow.py @@ -23,7 +23,8 @@ async def test_form(hass): ), patch( "homeassistant.components.plum_lightpad.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.plum_lightpad.async_setup_entry", return_value=True, + "homeassistant.components.plum_lightpad.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -99,7 +100,8 @@ async def test_import(hass): ), patch( "homeassistant.components.plum_lightpad.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.plum_lightpad.async_setup_entry", return_value=True, + "homeassistant.components.plum_lightpad.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, diff --git a/tests/components/plum_lightpad/test_init.py b/tests/components/plum_lightpad/test_init.py index b92dbaf1aa5..139ab786d1d 100644 --- a/tests/components/plum_lightpad/test_init.py +++ b/tests/components/plum_lightpad/test_init.py @@ -23,7 +23,8 @@ async def test_async_setup_imports_from_config(hass: HomeAssistant): with patch( "homeassistant.components.plum_lightpad.utils.Plum.loadCloudData" ) as mock_loadCloudData, patch( - "homeassistant.components.plum_lightpad.async_setup_entry", return_value=True, + "homeassistant.components.plum_lightpad.async_setup_entry", + return_value=True, ) as mock_async_setup_entry: result = await async_setup_component( hass, diff --git a/tests/components/poolsense/test_config_flow.py b/tests/components/poolsense/test_config_flow.py index b7499208121..c969ed9c416 100644 --- a/tests/components/poolsense/test_config_flow.py +++ b/tests/components/poolsense/test_config_flow.py @@ -20,7 +20,8 @@ async def test_show_form(hass): async def test_invalid_credentials(hass): """Test we handle invalid credentials.""" with patch( - "poolsense.PoolSense.test_poolsense_credentials", return_value=False, + "poolsense.PoolSense.test_poolsense_credentials", + return_value=False, ): result = await hass.config_entries.flow.async_init( DOMAIN, diff --git a/tests/components/powerwall/test_binary_sensor.py b/tests/components/powerwall/test_binary_sensor.py index 1cdda033c12..caf7519f598 100644 --- a/tests/components/powerwall/test_binary_sensor.py +++ b/tests/components/powerwall/test_binary_sensor.py @@ -18,7 +18,8 @@ async def test_sensors(hass): "homeassistant.components.powerwall.config_flow.Powerwall", return_value=mock_powerwall, ), patch( - "homeassistant.components.powerwall.Powerwall", return_value=mock_powerwall, + "homeassistant.components.powerwall.Powerwall", + return_value=mock_powerwall, ): assert await async_setup_component(hass, DOMAIN, _mock_get_config()) await hass.async_block_till_done() diff --git a/tests/components/powerwall/test_config_flow.py b/tests/components/powerwall/test_config_flow.py index eaf53f0beef..9f72f1900f0 100644 --- a/tests/components/powerwall/test_config_flow.py +++ b/tests/components/powerwall/test_config_flow.py @@ -28,10 +28,12 @@ async def test_form_source_user(hass): ), patch( "homeassistant.components.powerwall.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.powerwall.async_setup_entry", return_value=True, + "homeassistant.components.powerwall.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_IP_ADDRESS: "1.2.3.4"}, + result["flow_id"], + {CONF_IP_ADDRESS: "1.2.3.4"}, ) assert result2["type"] == "create_entry" @@ -53,7 +55,8 @@ async def test_form_source_import(hass): ), patch( "homeassistant.components.powerwall.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.powerwall.async_setup_entry", return_value=True, + "homeassistant.components.powerwall.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, @@ -82,7 +85,8 @@ async def test_form_cannot_connect(hass): return_value=mock_powerwall, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_IP_ADDRESS: "1.2.3.4"}, + result["flow_id"], + {CONF_IP_ADDRESS: "1.2.3.4"}, ) assert result2["type"] == "form" @@ -102,7 +106,8 @@ async def test_form_wrong_version(hass): return_value=mock_powerwall, ): result3 = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_IP_ADDRESS: "1.2.3.4"}, + result["flow_id"], + {CONF_IP_ADDRESS: "1.2.3.4"}, ) assert result3["type"] == "form" diff --git a/tests/components/powerwall/test_sensor.py b/tests/components/powerwall/test_sensor.py index af2835ea679..d007b664633 100644 --- a/tests/components/powerwall/test_sensor.py +++ b/tests/components/powerwall/test_sensor.py @@ -25,7 +25,8 @@ async def test_sensors(hass): device_registry = await hass.helpers.device_registry.async_get_registry() reg_device = device_registry.async_get_device( - identifiers={("powerwall", "TG0123456789AB_TG9876543210BA")}, connections=set(), + identifiers={("powerwall", "TG0123456789AB_TG9876543210BA")}, + connections=set(), ) assert reg_device.model == "PowerWall 2 (GW1)" assert reg_device.sw_version == "1.45.1" diff --git a/tests/components/ps4/test_config_flow.py b/tests/components/ps4/test_config_flow.py index c5e0623de5b..d7754cf1c8f 100644 --- a/tests/components/ps4/test_config_flow.py +++ b/tests/components/ps4/test_config_flow.py @@ -88,7 +88,8 @@ def location_info_fixture(): def ps4_setup_fixture(): """Patch ps4 setup entry.""" with patch( - "homeassistant.components.ps4.async_setup_entry", return_value=True, + "homeassistant.components.ps4.async_setup_entry", + return_value=True, ): yield @@ -329,7 +330,9 @@ async def test_0_pin(hass): """Test Pin with leading '0' is passed correctly.""" with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": "creds"}, data={}, + DOMAIN, + context={"source": "creds"}, + data={}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == "mode" diff --git a/tests/components/push/test_camera.py b/tests/components/push/test_camera.py index 74d975fc57c..644db2b9dd5 100644 --- a/tests/components/push/test_camera.py +++ b/tests/components/push/test_camera.py @@ -12,7 +12,8 @@ from tests.common import async_fire_time_changed async def test_bad_posting(hass, aiohttp_client): """Test that posting to wrong api endpoint fails.""" await async_process_ha_core_config( - hass, {"external_url": "http://example.com"}, + hass, + {"external_url": "http://example.com"}, ) await async_setup_component( @@ -42,7 +43,8 @@ async def test_bad_posting(hass, aiohttp_client): async def test_posting_url(hass, aiohttp_client): """Test that posting to api endpoint works.""" await async_process_ha_core_config( - hass, {"external_url": "http://example.com"}, + hass, + {"external_url": "http://example.com"}, ) await async_setup_component( diff --git a/tests/components/qwikswitch/test_init.py b/tests/components/qwikswitch/test_init.py index 6075174fa98..5a68a6e6e7b 100644 --- a/tests/components/qwikswitch/test_init.py +++ b/tests/components/qwikswitch/test_init.py @@ -270,7 +270,9 @@ async def test_button(hass, aioclient_mock, qs_devices): button_pressed = Mock() hass.bus.async_listen_once("qwikswitch.button.@a00002", button_pressed) - listen_mock.queue_response(json={"id": "@a00002", "cmd": "TOGGLE"},) + listen_mock.queue_response( + json={"id": "@a00002", "cmd": "TOGGLE"}, + ) await asyncio.sleep(0.01) await hass.async_block_till_done() button_pressed.assert_called_once() diff --git a/tests/components/rachio/test_config_flow.py b/tests/components/rachio/test_config_flow.py index 7cc3f272e7a..b107bd1514f 100644 --- a/tests/components/rachio/test_config_flow.py +++ b/tests/components/rachio/test_config_flow.py @@ -39,7 +39,8 @@ async def test_form(hass): ), patch( "homeassistant.components.rachio.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.rachio.async_setup_entry", return_value=True, + "homeassistant.components.rachio.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -76,7 +77,8 @@ async def test_form_invalid_auth(hass): "homeassistant.components.rachio.config_flow.Rachio", return_value=rachio_mock ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_API_KEY: "api_key"}, + result["flow_id"], + {CONF_API_KEY: "api_key"}, ) assert result2["type"] == "form" @@ -97,7 +99,8 @@ async def test_form_cannot_connect(hass): "homeassistant.components.rachio.config_flow.Rachio", return_value=rachio_mock ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_API_KEY: "api_key"}, + result["flow_id"], + {CONF_API_KEY: "api_key"}, ) assert result2["type"] == "form" diff --git a/tests/components/rainmachine/test_config_flow.py b/tests/components/rainmachine/test_config_flow.py index 7b27bdf2f39..be4a5fd20fe 100644 --- a/tests/components/rainmachine/test_config_flow.py +++ b/tests/components/rainmachine/test_config_flow.py @@ -50,7 +50,8 @@ async def test_invalid_password(hass): flow.context = {"source": SOURCE_USER} with patch( - "regenmaschine.client.Client.load_local", side_effect=RainMachineError, + "regenmaschine.client.Client.load_local", + side_effect=RainMachineError, ): result = await flow.async_step_user(user_input=conf) assert result["errors"] == {CONF_PASSWORD: "invalid_credentials"} @@ -83,7 +84,8 @@ async def test_step_import(hass): flow.context = {"source": SOURCE_USER} with patch( - "regenmaschine.client.Client.load_local", return_value=True, + "regenmaschine.client.Client.load_local", + return_value=True, ): result = await flow.async_step_import(import_config=conf) @@ -114,7 +116,8 @@ async def test_step_user(hass): flow.context = {"source": SOURCE_USER} with patch( - "regenmaschine.client.Client.load_local", return_value=True, + "regenmaschine.client.Client.load_local", + return_value=True, ): result = await flow.async_step_user(user_input=conf) diff --git a/tests/components/rest/test_sensor.py b/tests/components/rest/test_sensor.py index ef4ba7a2b55..4351239064a 100644 --- a/tests/components/rest/test_sensor.py +++ b/tests/components/rest/test_sensor.py @@ -631,7 +631,8 @@ class TestRestSensor(unittest.TestCase): value_template.hass = self.hass self.rest.update = Mock( - "rest.RestData.update", side_effect=self.update_side_effect(None, None), + "rest.RestData.update", + side_effect=self.update_side_effect(None, None), ) self.sensor = rest.RestSensor( self.hass, @@ -707,11 +708,16 @@ async def test_reload(hass, requests_mock): assert hass.states.get("sensor.mockrest") yaml_path = path.join( - _get_fixtures_base_path(), "fixtures", "rest/configuration.yaml", + _get_fixtures_base_path(), + "fixtures", + "rest/configuration.yaml", ) with patch.object(hass_config, "YAML_CONFIG_FILE", yaml_path): await hass.services.async_call( - "rest", SERVICE_RELOAD, {}, blocking=True, + "rest", + SERVICE_RELOAD, + {}, + blocking=True, ) await hass.async_block_till_done() diff --git a/tests/components/rfxtrx/conftest.py b/tests/components/rfxtrx/conftest.py index 94d440312b4..1eb39f00691 100644 --- a/tests/components/rfxtrx/conftest.py +++ b/tests/components/rfxtrx/conftest.py @@ -21,7 +21,8 @@ async def rfxtrx_fixture(hass): async def _signal_event(packet_id): event = rfxtrx.get_rfx_object(packet_id) await hass.async_add_executor_job( - rfx.event_callback, event, + rfx.event_callback, + event, ) await hass.async_block_till_done() @@ -38,7 +39,9 @@ async def rfxtrx_automatic_fixture(hass, rfxtrx): """Fixture that starts up with automatic additions.""" assert await async_setup_component( - hass, "rfxtrx", {"rfxtrx": {"device": "abcd", "automatic_add": True}}, + hass, + "rfxtrx", + {"rfxtrx": {"device": "abcd", "automatic_add": True}}, ) await hass.async_block_till_done() await hass.async_start() diff --git a/tests/components/ring/test_config_flow.py b/tests/components/ring/test_config_flow.py index 57723d1ede7..1be0a05fc5e 100644 --- a/tests/components/ring/test_config_flow.py +++ b/tests/components/ring/test_config_flow.py @@ -23,7 +23,8 @@ async def test_form(hass): ), patch( "homeassistant.components.ring.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.ring.async_setup_entry", return_value=True, + "homeassistant.components.ring.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/tests/components/risco/test_alarm_control_panel.py b/tests/components/risco/test_alarm_control_panel.py index 197ebfb8213..75038eef377 100644 --- a/tests/components/risco/test_alarm_control_panel.py +++ b/tests/components/risco/test_alarm_control_panel.py @@ -60,7 +60,8 @@ def two_part_alarm(): "partitions", new_callable=PropertyMock(return_value=partition_mocks), ), patch( - "homeassistant.components.risco.RiscoAPI.get_state", return_value=alarm_mock, + "homeassistant.components.risco.RiscoAPI.get_state", + return_value=alarm_mock, ): yield alarm_mock @@ -70,7 +71,8 @@ async def _setup_risco(hass, options={}): config_entry.add_to_hass(hass) with patch( - "homeassistant.components.risco.RiscoAPI.login", return_value=True, + "homeassistant.components.risco.RiscoAPI.login", + return_value=True, ), patch( "homeassistant.components.risco.RiscoAPI.site_uuid", new_callable=PropertyMock(return_value=TEST_SITE_UUID), @@ -90,7 +92,8 @@ async def test_cannot_connect(hass): """Test connection error.""" with patch( - "homeassistant.components.risco.RiscoAPI.login", side_effect=CannotConnectError, + "homeassistant.components.risco.RiscoAPI.login", + side_effect=CannotConnectError, ): config_entry = MockConfigEntry(domain=DOMAIN, data=TEST_CONFIG) config_entry.add_to_hass(hass) @@ -105,7 +108,8 @@ async def test_unauthorized(hass): """Test unauthorized error.""" with patch( - "homeassistant.components.risco.RiscoAPI.login", side_effect=UnauthorizedError, + "homeassistant.components.risco.RiscoAPI.login", + side_effect=UnauthorizedError, ): config_entry = MockConfigEntry(domain=DOMAIN, data=TEST_CONFIG) config_entry.add_to_hass(hass) diff --git a/tests/components/risco/test_binary_sensor.py b/tests/components/risco/test_binary_sensor.py index 46b3bae4c78..689b2e17c28 100644 --- a/tests/components/risco/test_binary_sensor.py +++ b/tests/components/risco/test_binary_sensor.py @@ -27,7 +27,10 @@ SECOND_ENTITY_ID = "binary_sensor.zone_1" def _zone_mock(): - return MagicMock(triggered=False, bypassed=False,) + return MagicMock( + triggered=False, + bypassed=False, + ) @pytest.fixture @@ -44,9 +47,12 @@ def two_zone_alarm(): ), patch.object( zone_mocks[1], "name", new_callable=PropertyMock(return_value="Zone 1") ), patch.object( - alarm_mock, "zones", new_callable=PropertyMock(return_value=zone_mocks), + alarm_mock, + "zones", + new_callable=PropertyMock(return_value=zone_mocks), ), patch( - "homeassistant.components.risco.RiscoAPI.get_state", return_value=alarm_mock, + "homeassistant.components.risco.RiscoAPI.get_state", + return_value=alarm_mock, ): yield alarm_mock @@ -56,7 +62,8 @@ async def _setup_risco(hass): config_entry.add_to_hass(hass) with patch( - "homeassistant.components.risco.RiscoAPI.login", return_value=True, + "homeassistant.components.risco.RiscoAPI.login", + return_value=True, ), patch( "homeassistant.components.risco.RiscoAPI.site_uuid", new_callable=PropertyMock(return_value=TEST_SITE_UUID), @@ -76,7 +83,8 @@ async def test_cannot_connect(hass): """Test connection error.""" with patch( - "homeassistant.components.risco.RiscoAPI.login", side_effect=CannotConnectError, + "homeassistant.components.risco.RiscoAPI.login", + side_effect=CannotConnectError, ): config_entry = MockConfigEntry(domain=DOMAIN, data=TEST_CONFIG) config_entry.add_to_hass(hass) @@ -91,7 +99,8 @@ async def test_unauthorized(hass): """Test unauthorized error.""" with patch( - "homeassistant.components.risco.RiscoAPI.login", side_effect=UnauthorizedError, + "homeassistant.components.risco.RiscoAPI.login", + side_effect=UnauthorizedError, ): config_entry = MockConfigEntry(domain=DOMAIN, data=TEST_CONFIG) config_entry.add_to_hass(hass) diff --git a/tests/components/risco/test_config_flow.py b/tests/components/risco/test_config_flow.py index 3a929c3ed3d..ae6e34e6f60 100644 --- a/tests/components/risco/test_config_flow.py +++ b/tests/components/risco/test_config_flow.py @@ -26,7 +26,8 @@ async def test_form(hass): assert result["errors"] == {} with patch( - "homeassistant.components.risco.config_flow.RiscoAPI.login", return_value=True, + "homeassistant.components.risco.config_flow.RiscoAPI.login", + return_value=True, ), patch( "homeassistant.components.risco.config_flow.RiscoAPI.site_name", new_callable=PropertyMock(return_value=TEST_SITE_NAME), @@ -35,7 +36,8 @@ async def test_form(hass): ) as mock_close, patch( "homeassistant.components.risco.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.risco.async_setup_entry", return_value=True, + "homeassistant.components.risco.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], TEST_DATA @@ -110,7 +112,9 @@ async def test_form_exception(hass): async def test_form_already_exists(hass): """Test that a flow with an existing username aborts.""" entry = MockConfigEntry( - domain=DOMAIN, unique_id=TEST_DATA["username"], data=TEST_DATA, + domain=DOMAIN, + unique_id=TEST_DATA["username"], + data=TEST_DATA, ) entry.add_to_hass(hass) @@ -136,7 +140,9 @@ async def test_options_flow(hass): } entry = MockConfigEntry( - domain=DOMAIN, unique_id=TEST_DATA["username"], data=TEST_DATA, + domain=DOMAIN, + unique_id=TEST_DATA["username"], + data=TEST_DATA, ) entry.add_to_hass(hass) @@ -148,7 +154,8 @@ async def test_options_flow(hass): assert result["step_id"] == "init" result = await hass.config_entries.options.async_configure( - result["flow_id"], user_input=conf, + result["flow_id"], + user_input=conf, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY diff --git a/tests/components/rmvtransport/test_sensor.py b/tests/components/rmvtransport/test_sensor.py index b576f385173..935368f03b1 100644 --- a/tests/components/rmvtransport/test_sensor.py +++ b/tests/components/rmvtransport/test_sensor.py @@ -160,7 +160,8 @@ def get_no_departures_mock(): async def test_rmvtransport_min_config(hass): """Test minimal rmvtransport configuration.""" with patch( - "RMVtransport.RMVtransport.get_departures", return_value=get_departures_mock(), + "RMVtransport.RMVtransport.get_departures", + return_value=get_departures_mock(), ): assert await async_setup_component(hass, "sensor", VALID_CONFIG_MINIMAL) is True await hass.async_block_till_done() @@ -180,7 +181,8 @@ async def test_rmvtransport_min_config(hass): async def test_rmvtransport_name_config(hass): """Test custom name configuration.""" with patch( - "RMVtransport.RMVtransport.get_departures", return_value=get_departures_mock(), + "RMVtransport.RMVtransport.get_departures", + return_value=get_departures_mock(), ): assert await async_setup_component(hass, "sensor", VALID_CONFIG_NAME) await hass.async_block_till_done() @@ -192,7 +194,8 @@ async def test_rmvtransport_name_config(hass): async def test_rmvtransport_misc_config(hass): """Test misc configuration.""" with patch( - "RMVtransport.RMVtransport.get_departures", return_value=get_departures_mock(), + "RMVtransport.RMVtransport.get_departures", + return_value=get_departures_mock(), ): assert await async_setup_component(hass, "sensor", VALID_CONFIG_MISC) await hass.async_block_till_done() @@ -205,7 +208,8 @@ async def test_rmvtransport_misc_config(hass): async def test_rmvtransport_dest_config(hass): """Test destination configuration.""" with patch( - "RMVtransport.RMVtransport.get_departures", return_value=get_departures_mock(), + "RMVtransport.RMVtransport.get_departures", + return_value=get_departures_mock(), ): assert await async_setup_component(hass, "sensor", VALID_CONFIG_DEST) await hass.async_block_till_done() diff --git a/tests/components/roku/__init__.py b/tests/components/roku/__init__.py index a73e1b7d5aa..f2da007b5e0 100644 --- a/tests/components/roku/__init__.py +++ b/tests/components/roku/__init__.py @@ -97,11 +97,13 @@ def mock_connection( ) aioclient_mock.post( - re.compile(f"{roku_url}/keypress/.*"), text="OK", + re.compile(f"{roku_url}/keypress/.*"), + text="OK", ) aioclient_mock.post( - re.compile(f"{roku_url}/launch/.*"), text="OK", + re.compile(f"{roku_url}/launch/.*"), + text="OK", ) aioclient_mock.post(f"{roku_url}/search", text="OK") diff --git a/tests/components/roku/test_config_flow.py b/tests/components/roku/test_config_flow.py index 403e25e46c6..58acc7a6bdf 100644 --- a/tests/components/roku/test_config_flow.py +++ b/tests/components/roku/test_config_flow.py @@ -70,7 +70,8 @@ async def test_form( with patch( "homeassistant.components.roku.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.roku.async_setup_entry", return_value=True, + "homeassistant.components.roku.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_configure( flow_id=result["flow_id"], user_input=user_input @@ -113,7 +114,8 @@ async def test_form_unknown_error(hass: HomeAssistantType) -> None: user_input = {CONF_HOST: HOST} with patch( - "homeassistant.components.roku.config_flow.Roku.update", side_effect=Exception, + "homeassistant.components.roku.config_flow.Roku.update", + side_effect=Exception, ) as mock_validate_input: result = await hass.config_entries.flow.async_configure( flow_id=result["flow_id"], user_input=user_input @@ -136,7 +138,8 @@ async def test_import( with patch( "homeassistant.components.roku.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.roku.async_setup_entry", return_value=True, + "homeassistant.components.roku.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, context={CONF_SOURCE: SOURCE_IMPORT}, data=user_input @@ -161,7 +164,9 @@ async def test_ssdp_cannot_connect( discovery_info = MOCK_SSDP_DISCOVERY_INFO.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info, + DOMAIN, + context={CONF_SOURCE: SOURCE_SSDP}, + data=discovery_info, ) assert result["type"] == RESULT_TYPE_ABORT @@ -174,10 +179,13 @@ async def test_ssdp_unknown_error( """Test we abort SSDP flow on unknown error.""" discovery_info = MOCK_SSDP_DISCOVERY_INFO.copy() with patch( - "homeassistant.components.roku.config_flow.Roku.update", side_effect=Exception, + "homeassistant.components.roku.config_flow.Roku.update", + side_effect=Exception, ): result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info, + DOMAIN, + context={CONF_SOURCE: SOURCE_SSDP}, + data=discovery_info, ) assert result["type"] == RESULT_TYPE_ABORT @@ -202,7 +210,8 @@ async def test_ssdp_discovery( with patch( "homeassistant.components.roku.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.roku.async_setup_entry", return_value=True, + "homeassistant.components.roku.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_configure( flow_id=result["flow_id"], user_input={} diff --git a/tests/components/roku/test_init.py b/tests/components/roku/test_init.py index 3a627db72a5..b929a48ee25 100644 --- a/tests/components/roku/test_init.py +++ b/tests/components/roku/test_init.py @@ -29,7 +29,8 @@ async def test_unload_config_entry( "homeassistant.components.roku.media_player.async_setup_entry", return_value=True, ), patch( - "homeassistant.components.roku.remote.async_setup_entry", return_value=True, + "homeassistant.components.roku.remote.async_setup_entry", + return_value=True, ): entry = await setup_integration(hass, aioclient_mock) diff --git a/tests/components/roomba/test_config_flow.py b/tests/components/roomba/test_config_flow.py index 197ad56f415..b2ad3a74235 100644 --- a/tests/components/roomba/test_config_flow.py +++ b/tests/components/roomba/test_config_flow.py @@ -55,10 +55,12 @@ async def test_form(hass): ), patch( "homeassistant.components.roomba.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.roomba.async_setup_entry", return_value=True, + "homeassistant.components.roomba.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], VALID_CONFIG, + result["flow_id"], + VALID_CONFIG, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY @@ -94,7 +96,8 @@ async def test_form_cannot_connect(hass): return_value=mocked_roomba, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], VALID_CONFIG, + result["flow_id"], + VALID_CONFIG, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -115,7 +118,8 @@ async def test_form_import(hass): ), patch( "homeassistant.components.roomba.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.roomba.async_setup_entry", return_value=True, + "homeassistant.components.roomba.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, diff --git a/tests/components/roon/test_config_flow.py b/tests/components/roon/test_config_flow.py index 8b6df6a35fd..aae655fb9c5 100644 --- a/tests/components/roon/test_config_flow.py +++ b/tests/components/roon/test_config_flow.py @@ -34,14 +34,16 @@ async def test_form_and_auth(hass): assert result["errors"] == {} with patch("homeassistant.components.roon.config_flow.TIMEOUT", 0,), patch( - "homeassistant.components.roon.const.AUTHENTICATE_TIMEOUT", 0, + "homeassistant.components.roon.const.AUTHENTICATE_TIMEOUT", + 0, ), patch( "homeassistant.components.roon.config_flow.RoonApi", return_value=RoonApiMock("good_token"), ), patch( "homeassistant.components.roon.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.roon.async_setup_entry", return_value=True, + "homeassistant.components.roon.async_setup_entry", + return_value=True, ) as mock_setup_entry: await hass.config_entries.flow.async_configure( result["flow_id"], {"host": "1.1.1.1"} @@ -64,7 +66,8 @@ async def test_form_no_token(hass): DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch("homeassistant.components.roon.config_flow.TIMEOUT", 0,), patch( - "homeassistant.components.roon.const.AUTHENTICATE_TIMEOUT", 0, + "homeassistant.components.roon.const.AUTHENTICATE_TIMEOUT", + 0, ), patch( "homeassistant.components.roon.config_flow.RoonApi", return_value=RoonApiMock(None), @@ -88,7 +91,8 @@ async def test_form_unknown_exception(hass): ) with patch( - "homeassistant.components.roon.config_flow.RoonApi", side_effect=Exception, + "homeassistant.components.roon.config_flow.RoonApi", + side_effect=Exception, ): await hass.config_entries.flow.async_configure( result["flow_id"], {"host": "1.1.1.1"} @@ -115,14 +119,16 @@ async def test_form_host_already_exists(hass): assert result["errors"] == {} with patch("homeassistant.components.roon.config_flow.TIMEOUT", 0,), patch( - "homeassistant.components.roon.const.AUTHENTICATE_TIMEOUT", 0, + "homeassistant.components.roon.const.AUTHENTICATE_TIMEOUT", + 0, ), patch( "homeassistant.components.roon.config_flow.RoonApi", return_value=RoonApiMock("good_token"), ), patch( "homeassistant.components.roon.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.roon.async_setup_entry", return_value=True, + "homeassistant.components.roon.async_setup_entry", + return_value=True, ) as mock_setup_entry: await hass.config_entries.flow.async_configure( result["flow_id"], {"host": "1.1.1.1"} diff --git a/tests/components/samsungtv/test_config_flow.py b/tests/components/samsungtv/test_config_flow.py index 2673ee56559..0e83255c6e3 100644 --- a/tests/components/samsungtv/test_config_flow.py +++ b/tests/components/samsungtv/test_config_flow.py @@ -180,7 +180,8 @@ async def test_user_legacy_not_supported(hass): async def test_user_websocket_not_supported(hass): """Test starting a flow by user for not supported device.""" with patch( - "homeassistant.components.samsungtv.bridge.Remote", side_effect=OSError("Boom"), + "homeassistant.components.samsungtv.bridge.Remote", + side_effect=OSError("Boom"), ), patch( "homeassistant.components.samsungtv.bridge.SamsungTVWS", side_effect=WebSocketProtocolException("Boom"), @@ -198,7 +199,8 @@ async def test_user_websocket_not_supported(hass): async def test_user_not_successful(hass): """Test starting a flow by user but no connection found.""" with patch( - "homeassistant.components.samsungtv.bridge.Remote", side_effect=OSError("Boom"), + "homeassistant.components.samsungtv.bridge.Remote", + side_effect=OSError("Boom"), ), patch( "homeassistant.components.samsungtv.bridge.SamsungTVWS", side_effect=OSError("Boom"), @@ -215,7 +217,8 @@ async def test_user_not_successful(hass): async def test_user_not_successful_2(hass): """Test starting a flow by user but no connection found.""" with patch( - "homeassistant.components.samsungtv.bridge.Remote", side_effect=OSError("Boom"), + "homeassistant.components.samsungtv.bridge.Remote", + side_effect=OSError("Boom"), ), patch( "homeassistant.components.samsungtv.bridge.SamsungTVWS", side_effect=ConnectionFailure("Boom"), @@ -339,7 +342,8 @@ async def test_ssdp_legacy_not_supported(hass): async def test_ssdp_websocket_not_supported(hass): """Test starting a flow from discovery for not supported device.""" with patch( - "homeassistant.components.samsungtv.bridge.Remote", side_effect=OSError("Boom"), + "homeassistant.components.samsungtv.bridge.Remote", + side_effect=OSError("Boom"), ), patch( "homeassistant.components.samsungtv.bridge.SamsungTVWS", side_effect=WebSocketProtocolException("Boom"), @@ -364,7 +368,8 @@ async def test_ssdp_websocket_not_supported(hass): async def test_ssdp_not_successful(hass): """Test starting a flow from discovery but no device found.""" with patch( - "homeassistant.components.samsungtv.bridge.Remote", side_effect=OSError("Boom"), + "homeassistant.components.samsungtv.bridge.Remote", + side_effect=OSError("Boom"), ), patch( "homeassistant.components.samsungtv.bridge.SamsungTVWS", side_effect=OSError("Boom"), @@ -390,7 +395,8 @@ async def test_ssdp_not_successful(hass): async def test_ssdp_not_successful_2(hass): """Test starting a flow from discovery but no device found.""" with patch( - "homeassistant.components.samsungtv.bridge.Remote", side_effect=OSError("Boom"), + "homeassistant.components.samsungtv.bridge.Remote", + side_effect=OSError("Boom"), ), patch( "homeassistant.components.samsungtv.bridge.SamsungTVWS", side_effect=ConnectionFailure("Boom"), @@ -460,7 +466,8 @@ async def test_ssdp_already_configured(hass, remote): async def test_autodetect_websocket(hass, remote, remotews): """Test for send key with autodetection of protocol.""" with patch( - "homeassistant.components.samsungtv.bridge.Remote", side_effect=OSError("Boom"), + "homeassistant.components.samsungtv.bridge.Remote", + side_effect=OSError("Boom"), ), patch("homeassistant.components.samsungtv.bridge.SamsungTVWS") as remotews: enter = Mock() type(enter).token = PropertyMock(return_value="123456789") @@ -482,7 +489,8 @@ async def test_autodetect_websocket(hass, remote, remotews): async def test_autodetect_websocket_ssl(hass, remote, remotews): """Test for send key with autodetection of protocol.""" with patch( - "homeassistant.components.samsungtv.bridge.Remote", side_effect=OSError("Boom"), + "homeassistant.components.samsungtv.bridge.Remote", + side_effect=OSError("Boom"), ), patch( "homeassistant.components.samsungtv.bridge.SamsungTVWS", side_effect=[WebSocketProtocolException("Boom"), DEFAULT_MOCK], @@ -552,7 +560,8 @@ async def test_autodetect_legacy(hass, remote): async def test_autodetect_none(hass, remote, remotews): """Test for send key with autodetection of protocol.""" with patch( - "homeassistant.components.samsungtv.bridge.Remote", side_effect=OSError("Boom"), + "homeassistant.components.samsungtv.bridge.Remote", + side_effect=OSError("Boom"), ) as remote, patch( "homeassistant.components.samsungtv.bridge.SamsungTVWS", side_effect=OSError("Boom"), diff --git a/tests/components/samsungtv/test_media_player.py b/tests/components/samsungtv/test_media_player.py index 840d5ac3f4e..cc9a0f37ec8 100644 --- a/tests/components/samsungtv/test_media_player.py +++ b/tests/components/samsungtv/test_media_player.py @@ -203,7 +203,9 @@ async def test_setup_websocket_2(hass, mock_now): entity_id = f"{DOMAIN}.fake" entry = MockConfigEntry( - domain=SAMSUNGTV_DOMAIN, data=MOCK_ENTRY_WS, unique_id=entity_id, + domain=SAMSUNGTV_DOMAIN, + data=MOCK_ENTRY_WS, + unique_id=entity_id, ) entry.add_to_hass(hass) diff --git a/tests/components/sense/test_config_flow.py b/tests/components/sense/test_config_flow.py index 5a38090b5c9..4cda15f7303 100644 --- a/tests/components/sense/test_config_flow.py +++ b/tests/components/sense/test_config_flow.py @@ -19,7 +19,8 @@ async def test_form(hass): with patch("sense_energy.ASyncSenseable.authenticate", return_value=True,), patch( "homeassistant.components.sense.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.sense.async_setup_entry", return_value=True, + "homeassistant.components.sense.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/tests/components/sentry/test_config_flow.py b/tests/components/sentry/test_config_flow.py index 9f060b58355..9ae572123b5 100644 --- a/tests/components/sentry/test_config_flow.py +++ b/tests/components/sentry/test_config_flow.py @@ -34,10 +34,12 @@ async def test_full_user_flow_implementation(hass): with patch("homeassistant.components.sentry.config_flow.Dsn"), patch( "homeassistant.components.sentry.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.sentry.async_setup_entry", return_value=True, + "homeassistant.components.sentry.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"dsn": "http://public@sentry.local/1"}, + result["flow_id"], + {"dsn": "http://public@sentry.local/1"}, ) assert result2["type"] == "create_entry" @@ -69,10 +71,12 @@ async def test_user_flow_bad_dsn(hass): ) with patch( - "homeassistant.components.sentry.config_flow.Dsn", side_effect=BadDsn, + "homeassistant.components.sentry.config_flow.Dsn", + side_effect=BadDsn, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"dsn": "foo"}, + result["flow_id"], + {"dsn": "foo"}, ) assert result2["type"] == RESULT_TYPE_FORM @@ -86,10 +90,12 @@ async def test_user_flow_unkown_exception(hass): ) with patch( - "homeassistant.components.sentry.config_flow.Dsn", side_effect=Exception, + "homeassistant.components.sentry.config_flow.Dsn", + side_effect=Exception, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"dsn": "foo"}, + result["flow_id"], + {"dsn": "foo"}, ) assert result2["type"] == RESULT_TYPE_FORM @@ -99,7 +105,8 @@ async def test_user_flow_unkown_exception(hass): async def test_options_flow(hass): """Test options config flow.""" entry = MockConfigEntry( - domain=DOMAIN, data={"dsn": "http://public@sentry.local/1"}, + domain=DOMAIN, + data={"dsn": "http://public@sentry.local/1"}, ) entry.add_to_hass(hass) diff --git a/tests/components/shelly/test_config_flow.py b/tests/components/shelly/test_config_flow.py index 8a3b7f48fcf..9acd52b6e8e 100644 --- a/tests/components/shelly/test_config_flow.py +++ b/tests/components/shelly/test_config_flow.py @@ -31,10 +31,12 @@ async def test_form(hass): ), patch( "homeassistant.components.shelly.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.shelly.async_setup_entry", return_value=True, + "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"}, + result["flow_id"], + {"host": "1.1.1.1"}, ) assert result2["type"] == "create_entry" @@ -60,7 +62,8 @@ async def test_form_auth(hass): return_value={"mac": "test-mac", "type": "SHSW-1", "auth": True}, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": "1.1.1.1"}, + result["flow_id"], + {"host": "1.1.1.1"}, ) assert result2["type"] == "abort" @@ -78,10 +81,12 @@ async def test_form_errors_get_info(hass, error): ) with patch( - "aioshelly.get_info", side_effect=exc, + "aioshelly.get_info", + side_effect=exc, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": "1.1.1.1"}, + result["flow_id"], + {"host": "1.1.1.1"}, ) assert result2["type"] == "form" @@ -99,10 +104,12 @@ async def test_form_errors_test_connection(hass, error): ) with patch("aioshelly.get_info", return_value={"auth": False}), patch( - "aioshelly.Device.create", side_effect=exc, + "aioshelly.Device.create", + side_effect=exc, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], {"host": "1.1.1.1"}, + result["flow_id"], + {"host": "1.1.1.1"}, ) assert result2["type"] == "form" @@ -134,9 +141,13 @@ async def test_zeroconf(hass): ), patch( "homeassistant.components.shelly.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.shelly.async_setup_entry", return_value=True, + "homeassistant.components.shelly.async_setup_entry", + return_value=True, ) as mock_setup_entry: - result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {},) + result2 = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) assert result2["type"] == "create_entry" assert result2["title"] == "Test name" @@ -169,9 +180,13 @@ async def test_zeroconf_confirm_error(hass, error): assert result["errors"] == {} with patch( - "aioshelly.Device.create", side_effect=exc, + "aioshelly.Device.create", + side_effect=exc, ): - result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {},) + result2 = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) assert result2["type"] == "form" assert result2["errors"] == {"base": base_error} @@ -204,7 +219,8 @@ async def test_zeroconf_already_configured(hass): async def test_zeroconf_cannot_connect(hass): """Test we get the form.""" with patch( - "aioshelly.get_info", side_effect=asyncio.TimeoutError, + "aioshelly.get_info", + side_effect=asyncio.TimeoutError, ): result = await hass.config_entries.flow.async_init( DOMAIN, diff --git a/tests/components/signal_messenger/test_notify.py b/tests/components/signal_messenger/test_notify.py index b4239dacfab..407068e6f3e 100644 --- a/tests/components/signal_messenger/test_notify.py +++ b/tests/components/signal_messenger/test_notify.py @@ -53,7 +53,9 @@ class TestSignalMesssenger(unittest.TestCase): """Test send message.""" message = "Testing Signal Messenger platform :)" mock.register_uri( - "POST", "http://127.0.0.1:8080/v2/send", status_code=201, + "POST", + "http://127.0.0.1:8080/v2/send", + status_code=201, ) mock.register_uri( "GET", @@ -74,7 +76,9 @@ class TestSignalMesssenger(unittest.TestCase): """Test send message.""" message = "Testing Signal Messenger platform with attachment :)" mock.register_uri( - "POST", "http://127.0.0.1:8080/v2/send", status_code=201, + "POST", + "http://127.0.0.1:8080/v2/send", + status_code=201, ) mock.register_uri( "GET", @@ -102,7 +106,9 @@ class TestSignalMesssenger(unittest.TestCase): """Test send message.""" message = "Testing Signal Messenger platform :)" mock.register_uri( - "POST", "http://127.0.0.1:8080/v2/send", status_code=201, + "POST", + "http://127.0.0.1:8080/v2/send", + status_code=201, ) mock.register_uri( "GET", diff --git a/tests/components/simplisafe/test_config_flow.py b/tests/components/simplisafe/test_config_flow.py index d94c431aa14..86cd0fc384c 100644 --- a/tests/components/simplisafe/test_config_flow.py +++ b/tests/components/simplisafe/test_config_flow.py @@ -48,7 +48,8 @@ async def test_invalid_credentials(hass): conf = {CONF_USERNAME: "user@email.com", CONF_PASSWORD: "password"} with patch( - "simplipy.API.login_via_credentials", side_effect=InvalidCredentialsError, + "simplipy.API.login_via_credentials", + side_effect=InvalidCredentialsError, ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=conf @@ -61,7 +62,10 @@ async def test_options_flow(hass): conf = {CONF_USERNAME: "user@email.com", CONF_PASSWORD: "password"} config_entry = MockConfigEntry( - domain=DOMAIN, unique_id="abcde12345", data=conf, options={CONF_CODE: "1234"}, + domain=DOMAIN, + unique_id="abcde12345", + data=conf, + options={CONF_CODE: "1234"}, ) config_entry.add_to_hass(hass) @@ -217,7 +221,8 @@ async def test_unknown_error(hass): conf = {CONF_USERNAME: "user@email.com", CONF_PASSWORD: "password"} with patch( - "simplipy.API.login_via_credentials", side_effect=SimplipyError, + "simplipy.API.login_via_credentials", + side_effect=SimplipyError, ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=conf diff --git a/tests/components/smappee/test_config_flow.py b/tests/components/smappee/test_config_flow.py index 92e5ebfb7e9..2200dd66490 100644 --- a/tests/components/smappee/test_config_flow.py +++ b/tests/components/smappee/test_config_flow.py @@ -22,7 +22,8 @@ CLIENT_SECRET = "5678" async def test_show_user_form(hass): """Test that the user set up form is served.""" result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, + DOMAIN, + context={"source": SOURCE_USER}, ) assert result["step_id"] == "environment" @@ -32,7 +33,8 @@ async def test_show_user_form(hass): async def test_show_user_host_form(hass): """Test that the host form is served after choosing the local option.""" result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, + DOMAIN, + context={"source": SOURCE_USER}, ) assert result["step_id"] == "environment" assert result["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -78,7 +80,8 @@ async def test_connection_error(hass): """Test we show user form on Smappee connection error.""" with patch("pysmappee.api.SmappeeLocalApi.logon", return_value=None): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, + DOMAIN, + context={"source": SOURCE_USER}, ) assert result["step_id"] == "environment" assert result["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -127,7 +130,8 @@ async def test_full_user_wrong_mdns(hass): return_value=[{"key": "phase0ActivePower", "value": 0}], ): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, + DOMAIN, + context={"source": SOURCE_USER}, ) assert result["step_id"] == "environment" assert result["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -166,7 +170,8 @@ async def test_user_device_exists_abort(hass): assert len(hass.config_entries.async_entries(DOMAIN)) == 1 result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, + DOMAIN, + context={"source": SOURCE_USER}, ) assert result["step_id"] == "environment" assert result["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -226,14 +231,17 @@ async def test_zeroconf_device_exists_abort(hass): async def test_cloud_device_exists_abort(hass): """Test we abort cloud flow if Smappee Cloud device already configured.""" config_entry = MockConfigEntry( - domain=DOMAIN, unique_id="smappeeCloud", source=SOURCE_USER, + domain=DOMAIN, + unique_id="smappeeCloud", + source=SOURCE_USER, ) config_entry.add_to_hass(hass) assert len(hass.config_entries.async_entries(DOMAIN)) == 1 result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, + DOMAIN, + context={"source": SOURCE_USER}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT @@ -244,7 +252,9 @@ async def test_cloud_device_exists_abort(hass): async def test_zeroconf_abort_if_cloud_device_exists(hass): """Test we abort zeroconf flow if Smappee Cloud device already configured.""" config_entry = MockConfigEntry( - domain=DOMAIN, unique_id="smappeeCloud", source=SOURCE_USER, + domain=DOMAIN, + unique_id="smappeeCloud", + source=SOURCE_USER, ) config_entry.add_to_hass(hass) @@ -283,7 +293,9 @@ async def test_zeroconf_confirm_abort_if_cloud_device_exists(hass): ) config_entry = MockConfigEntry( - domain=DOMAIN, unique_id="smappeeCloud", source=SOURCE_USER, + domain=DOMAIN, + unique_id="smappeeCloud", + source=SOURCE_USER, ) config_entry.add_to_hass(hass) @@ -309,7 +321,8 @@ async def test_abort_cloud_flow_if_local_device_exists(hass): assert len(hass.config_entries.async_entries(DOMAIN)) == 1 result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, + DOMAIN, + context={"source": SOURCE_USER}, ) result = await hass.config_entries.flow.async_configure( result["flow_id"], {"environment": ENV_CLOUD} @@ -332,7 +345,8 @@ async def test_full_user_flow(hass, aiohttp_client, aioclient_mock, current_requ ) result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, + DOMAIN, + context={"source": SOURCE_USER}, ) result = await hass.config_entries.flow.async_configure( result["flow_id"], {"environment": ENV_CLOUD} @@ -418,14 +432,16 @@ async def test_full_user_local_flow(hass): "homeassistant.components.smappee.async_setup_entry", return_value=True ): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, + DOMAIN, + context={"source": SOURCE_USER}, ) assert result["step_id"] == "environment" assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["description_placeholders"] is None result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"environment": ENV_LOCAL}, + result["flow_id"], + {"environment": ENV_LOCAL}, ) assert result["step_id"] == ENV_LOCAL assert result["type"] == data_entry_flow.RESULT_TYPE_FORM diff --git a/tests/components/smart_meter_texas/conftest.py b/tests/components/smart_meter_texas/conftest.py index 67e8472ae0b..8b089e5d31b 100644 --- a/tests/components/smart_meter_texas/conftest.py +++ b/tests/components/smart_meter_texas/conftest.py @@ -61,7 +61,8 @@ def mock_connection( auth_endpoint = f"{BASE_ENDPOINT}{AUTH_ENDPOINT}" if not auth_fail and not auth_timeout: aioclient_mock.post( - auth_endpoint, json={"token": "token123"}, + auth_endpoint, + json={"token": "token123"}, ) elif auth_fail: aioclient_mock.post( @@ -73,7 +74,8 @@ def mock_connection( aioclient_mock.post(auth_endpoint, exc=asyncio.TimeoutError) aioclient_mock.post( - f"{BASE_ENDPOINT}{METER_ENDPOINT}", json=load_smt_fixture("meter"), + f"{BASE_ENDPOINT}{METER_ENDPOINT}", + json=load_smt_fixture("meter"), ) aioclient_mock.post(f"{BASE_ENDPOINT}{OD_READ_ENDPOINT}", json={"data": None}) if not bad_reading: @@ -83,7 +85,8 @@ def mock_connection( ) else: aioclient_mock.post( - f"{BASE_ENDPOINT}{LATEST_OD_READ_ENDPOINT}", json={}, + f"{BASE_ENDPOINT}{LATEST_OD_READ_ENDPOINT}", + json={}, ) diff --git a/tests/components/smart_meter_texas/test_config_flow.py b/tests/components/smart_meter_texas/test_config_flow.py index d1e88df8a80..729cb0a90b2 100644 --- a/tests/components/smart_meter_texas/test_config_flow.py +++ b/tests/components/smart_meter_texas/test_config_flow.py @@ -52,10 +52,12 @@ async def test_form_invalid_auth(hass): ) with patch( - "smart_meter_texas.Client.authenticate", side_effect=SmartMeterTexasAuthError, + "smart_meter_texas.Client.authenticate", + side_effect=SmartMeterTexasAuthError, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], TEST_LOGIN, + result["flow_id"], + TEST_LOGIN, ) assert result2["type"] == "form" @@ -72,7 +74,8 @@ async def test_form_cannot_connect(hass, side_effect): ) with patch( - "smart_meter_texas.Client.authenticate", side_effect=side_effect, + "smart_meter_texas.Client.authenticate", + side_effect=side_effect, ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], TEST_LOGIN @@ -89,10 +92,12 @@ async def test_form_unknown_exception(hass): ) with patch( - "smart_meter_texas.Client.authenticate", side_effect=Exception, + "smart_meter_texas.Client.authenticate", + side_effect=Exception, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], TEST_LOGIN, + result["flow_id"], + TEST_LOGIN, ) assert result2["type"] == "form" @@ -108,7 +113,8 @@ async def test_form_duplicate_account(hass): ).add_to_hass(hass) with patch( - "smart_meter_texas.Client.authenticate", return_value=True, + "smart_meter_texas.Client.authenticate", + return_value=True, ): result = await hass.config_entries.flow.async_init( DOMAIN, diff --git a/tests/components/smarthab/test_config_flow.py b/tests/components/smarthab/test_config_flow.py index 8e6d87a53cc..6303fd44def 100644 --- a/tests/components/smarthab/test_config_flow.py +++ b/tests/components/smarthab/test_config_flow.py @@ -84,7 +84,8 @@ async def test_form_unknown_error(hass): ) with patch( - "pysmarthab.SmartHab.async_login", side_effect=Exception, + "pysmarthab.SmartHab.async_login", + side_effect=Exception, ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/tests/components/smartthings/conftest.py b/tests/components/smartthings/conftest.py index 643c084720a..ecab269c1a2 100644 --- a/tests/components/smartthings/conftest.py +++ b/tests/components/smartthings/conftest.py @@ -78,7 +78,8 @@ async def setup_component(hass, config_file, hass_storage): """Load the SmartThing component.""" hass_storage[STORAGE_KEY] = {"data": config_file, "version": STORAGE_VERSION} await async_process_ha_core_config( - hass, {"external_url": "https://test.local"}, + hass, + {"external_url": "https://test.local"}, ) await async_setup_component(hass, "smartthings", {}) diff --git a/tests/components/smartthings/test_config_flow.py b/tests/components/smartthings/test_config_flow.py index 91bba9ab405..b776959ea5b 100644 --- a/tests/components/smartthings/test_config_flow.py +++ b/tests/components/smartthings/test_config_flow.py @@ -100,7 +100,10 @@ async def test_entry_created(hass, app, app_oauth_client, location, smartthings_ assert result["data"][CONF_CLIENT_SECRET] == app_oauth_client.client_secret assert result["data"][CONF_CLIENT_ID] == app_oauth_client.client_id assert result["title"] == location.name - entry = next((entry for entry in hass.config_entries.async_entries(DOMAIN)), None,) + entry = next( + (entry for entry in hass.config_entries.async_entries(DOMAIN)), + None, + ) assert entry.unique_id == smartapp.format_unique_id( app.app_id, location.location_id ) @@ -168,7 +171,10 @@ async def test_entry_created_from_update_event( assert result["data"][CONF_CLIENT_SECRET] == app_oauth_client.client_secret assert result["data"][CONF_CLIENT_ID] == app_oauth_client.client_id assert result["title"] == location.name - entry = next((entry for entry in hass.config_entries.async_entries(DOMAIN)), None,) + entry = next( + (entry for entry in hass.config_entries.async_entries(DOMAIN)), + None, + ) assert entry.unique_id == smartapp.format_unique_id( app.app_id, location.location_id ) @@ -236,7 +242,10 @@ async def test_entry_created_existing_app_new_oauth_client( assert result["data"][CONF_CLIENT_SECRET] == app_oauth_client.client_secret assert result["data"][CONF_CLIENT_ID] == app_oauth_client.client_id assert result["title"] == location.name - entry = next((entry for entry in hass.config_entries.async_entries(DOMAIN)), None,) + entry = next( + (entry for entry in hass.config_entries.async_entries(DOMAIN)), + None, + ) assert entry.unique_id == smartapp.format_unique_id( app.app_id, location.location_id ) @@ -409,7 +418,8 @@ async def test_entry_created_with_cloudhook( assert result["data"][CONF_CLIENT_ID] == app_oauth_client.client_id assert result["title"] == location.name entry = next( - (entry for entry in hass.config_entries.async_entries(DOMAIN)), None, + (entry for entry in hass.config_entries.async_entries(DOMAIN)), + None, ) assert entry.unique_id == smartapp.format_unique_id( app.app_id, location.location_id @@ -420,7 +430,8 @@ async def test_invalid_webhook_aborts(hass): """Test flow aborts if webhook is invalid.""" # Webhook confirmation shown await async_process_ha_core_config( - hass, {"external_url": "http://example.local:8123"}, + hass, + {"external_url": "http://example.local:8123"}, ) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "user"} diff --git a/tests/components/smartthings/test_init.py b/tests/components/smartthings/test_init.py index 014b9a6673c..931e895cb65 100644 --- a/tests/components/smartthings/test_init.py +++ b/tests/components/smartthings/test_init.py @@ -118,7 +118,8 @@ async def test_base_url_no_longer_https_does_not_load( ): """Test base_url no longer valid creates a new flow.""" await async_process_ha_core_config( - hass, {"external_url": "http://example.local:8123"}, + hass, + {"external_url": "http://example.local:8123"}, ) config_entry.add_to_hass(hass) smartthings_mock.app.return_value = app diff --git a/tests/components/smhi/test_weather.py b/tests/components/smhi/test_weather.py index 2e0ad01e552..050dc663487 100644 --- a/tests/components/smhi/test_weather.py +++ b/tests/components/smhi/test_weather.py @@ -199,7 +199,9 @@ async def test_refresh_weather_forecast_exception() -> None: with patch.object( hass.helpers.event, "async_call_later" ) as call_later, patch.object( - weather, "get_weather_forecast", side_effect=SmhiForecastException(), + weather, + "get_weather_forecast", + side_effect=SmhiForecastException(), ): await weather.async_update() assert len(call_later.mock_calls) == 1 diff --git a/tests/components/solarlog/test_config_flow.py b/tests/components/solarlog/test_config_flow.py index 1474b8e13e7..9cf0e2932ec 100644 --- a/tests/components/solarlog/test_config_flow.py +++ b/tests/components/solarlog/test_config_flow.py @@ -28,7 +28,8 @@ async def test_form(hass): ), patch( "homeassistant.components.solarlog.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.solarlog.async_setup_entry", return_value=True, + "homeassistant.components.solarlog.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], {"host": HOST, "name": NAME} diff --git a/tests/components/sonarr/__init__.py b/tests/components/sonarr/__init__.py index 6a6f3f37283..b076f39d0d2 100644 --- a/tests/components/sonarr/__init__.py +++ b/tests/components/sonarr/__init__.py @@ -55,19 +55,28 @@ def mock_connection( """Mock Sonarr connection.""" if error: mock_connection_error( - aioclient_mock, host=host, port=port, base_path=base_path, + aioclient_mock, + host=host, + port=port, + base_path=base_path, ) return if invalid_auth: mock_connection_invalid_auth( - aioclient_mock, host=host, port=port, base_path=base_path, + aioclient_mock, + host=host, + port=port, + base_path=base_path, ) return if server_error: mock_connection_server_error( - aioclient_mock, host=host, port=port, base_path=base_path, + aioclient_mock, + host=host, + port=port, + base_path=base_path, ) return @@ -232,5 +241,6 @@ def _patch_async_setup(return_value=True): def _patch_async_setup_entry(return_value=True): """Patch the async entry setup of sonarr.""" return patch( - "homeassistant.components.sonarr.async_setup_entry", return_value=return_value, + "homeassistant.components.sonarr.async_setup_entry", + return_value=return_value, ) diff --git a/tests/components/sonarr/test_config_flow.py b/tests/components/sonarr/test_config_flow.py index e376cda04ee..15bd13b580d 100644 --- a/tests/components/sonarr/test_config_flow.py +++ b/tests/components/sonarr/test_config_flow.py @@ -32,7 +32,8 @@ from tests.test_util.aiohttp import AiohttpClientMocker async def test_show_user_form(hass: HomeAssistantType) -> None: """Test that the user set up form is served.""" result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_USER}, + DOMAIN, + context={CONF_SOURCE: SOURCE_USER}, ) assert result["step_id"] == "user" @@ -47,7 +48,9 @@ async def test_cannot_connect( user_input = MOCK_USER_INPUT.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=user_input, + DOMAIN, + context={CONF_SOURCE: SOURCE_USER}, + data=user_input, ) assert result["type"] == RESULT_TYPE_FORM @@ -63,7 +66,9 @@ async def test_invalid_auth( user_input = MOCK_USER_INPUT.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=user_input, + DOMAIN, + context={CONF_SOURCE: SOURCE_USER}, + data=user_input, ) assert result["type"] == RESULT_TYPE_FORM @@ -81,7 +86,9 @@ async def test_unknown_error( side_effect=Exception, ): result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=user_input, + DOMAIN, + context={CONF_SOURCE: SOURCE_USER}, + data=user_input, ) assert result["type"] == RESULT_TYPE_ABORT @@ -98,7 +105,9 @@ async def test_full_import_flow_implementation( with _patch_async_setup(), _patch_async_setup_entry(): result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_IMPORT}, data=user_input, + DOMAIN, + context={CONF_SOURCE: SOURCE_IMPORT}, + data=user_input, ) assert result["type"] == RESULT_TYPE_CREATE_ENTRY @@ -115,7 +124,8 @@ async def test_full_user_flow_implementation( mock_connection(aioclient_mock) result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_USER}, + DOMAIN, + context={CONF_SOURCE: SOURCE_USER}, ) assert result["type"] == RESULT_TYPE_FORM @@ -125,7 +135,8 @@ async def test_full_user_flow_implementation( with _patch_async_setup(), _patch_async_setup_entry(): result = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input=user_input, + result["flow_id"], + user_input=user_input, ) assert result["type"] == RESULT_TYPE_CREATE_ENTRY @@ -155,7 +166,8 @@ async def test_full_user_flow_advanced_options( with _patch_async_setup(), _patch_async_setup_entry(): result = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input=user_input, + result["flow_id"], + user_input=user_input, ) assert result["type"] == RESULT_TYPE_CREATE_ENTRY diff --git a/tests/components/sonarr/test_init.py b/tests/components/sonarr/test_init.py index 27361382e78..e9f01290461 100644 --- a/tests/components/sonarr/test_init.py +++ b/tests/components/sonarr/test_init.py @@ -25,7 +25,8 @@ async def test_unload_config_entry( ) -> None: """Test the configuration entry unloading.""" with patch( - "homeassistant.components.sonarr.sensor.async_setup_entry", return_value=True, + "homeassistant.components.sonarr.sensor.async_setup_entry", + return_value=True, ): entry = await setup_integration(hass, aioclient_mock) diff --git a/tests/components/songpal/test_config_flow.py b/tests/components/songpal/test_config_flow.py index e837ed0e032..155801dca03 100644 --- a/tests/components/songpal/test_config_flow.py +++ b/tests/components/songpal/test_config_flow.py @@ -49,14 +49,17 @@ def _flow_next(hass, flow_id): def _patch_setup(): return patch( - "homeassistant.components.songpal.async_setup_entry", return_value=True, + "homeassistant.components.songpal.async_setup_entry", + return_value=True, ) async def test_flow_ssdp(hass): """Test working ssdp flow.""" result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_SSDP}, data=SSDP_DATA, + DOMAIN, + context={"source": SOURCE_SSDP}, + data=SSDP_DATA, ) assert result["type"] == "form" assert result["step_id"] == "init" @@ -82,7 +85,8 @@ async def test_flow_user(hass): with _patch_config_flow_device(mocked_device), _patch_setup(): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, + DOMAIN, + context={"source": SOURCE_USER}, ) assert result["type"] == RESULT_TYPE_FORM assert result["step_id"] == "user" @@ -90,7 +94,8 @@ async def test_flow_user(hass): _flow_next(hass, result["flow_id"]) result = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input={CONF_ENDPOINT: ENDPOINT}, + result["flow_id"], + user_input={CONF_ENDPOINT: ENDPOINT}, ) assert result["type"] == RESULT_TYPE_CREATE_ENTRY assert result["title"] == MODEL @@ -136,9 +141,11 @@ async def test_flow_import_without_name(hass): def _create_mock_config_entry(hass): - MockConfigEntry(domain=DOMAIN, unique_id="uuid:0000", data=CONF_DATA,).add_to_hass( - hass - ) + MockConfigEntry( + domain=DOMAIN, + unique_id="uuid:0000", + data=CONF_DATA, + ).add_to_hass(hass) async def test_ssdp_bravia(hass): @@ -148,7 +155,9 @@ async def test_ssdp_bravia(hass): "X_ScalarWebAPI_ServiceType" ].append("videoScreen") result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_SSDP}, data=ssdp_data, + DOMAIN, + context={"source": SOURCE_SSDP}, + data=ssdp_data, ) assert result["type"] == RESULT_TYPE_ABORT assert result["reason"] == "not_songpal_device" @@ -158,7 +167,9 @@ async def test_sddp_exist(hass): """Test discovering existed device.""" _create_mock_config_entry(hass) result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_SSDP}, data=SSDP_DATA, + DOMAIN, + context={"source": SOURCE_SSDP}, + data=SSDP_DATA, ) assert result["type"] == RESULT_TYPE_ABORT assert result["reason"] == "already_configured" diff --git a/tests/components/sonos/test_media_player.py b/tests/components/sonos/test_media_player.py index 54d54e6ed5b..dd83aefba81 100644 --- a/tests/components/sonos/test_media_player.py +++ b/tests/components/sonos/test_media_player.py @@ -50,7 +50,8 @@ async def test_device_registry(hass, config_entry, config, soco): device_registry = await hass.helpers.device_registry.async_get_registry() reg_device = device_registry.async_get_device( - identifiers={("sonos", "RINCON_test")}, connections=set(), + identifiers={("sonos", "RINCON_test")}, + connections=set(), ) assert reg_device.model == "Model Name" assert reg_device.sw_version == "49.2-64250" diff --git a/tests/components/soundtouch/test_media_player.py b/tests/components/soundtouch/test_media_player.py index d351df32101..85089854c4d 100644 --- a/tests/components/soundtouch/test_media_player.py +++ b/tests/components/soundtouch/test_media_player.py @@ -503,7 +503,10 @@ async def test_should_turn_off( assert mocked_volume.call_count == 2 await hass.services.async_call( - "media_player", "turn_off", {"entity_id": "media_player.soundtouch_1"}, True, + "media_player", + "turn_off", + {"entity_id": "media_player.soundtouch_1"}, + True, ) assert mocked_status.call_count == 3 assert mocked_power_off.call_count == 1 @@ -522,7 +525,10 @@ async def test_should_turn_on( assert mocked_volume.call_count == 2 await hass.services.async_call( - "media_player", "turn_on", {"entity_id": "media_player.soundtouch_1"}, True, + "media_player", + "turn_on", + {"entity_id": "media_player.soundtouch_1"}, + True, ) assert mocked_status.call_count == 3 assert mocked_power_on.call_count == 1 @@ -540,7 +546,10 @@ async def test_volume_up( assert mocked_volume.call_count == 2 await hass.services.async_call( - "media_player", "volume_up", {"entity_id": "media_player.soundtouch_1"}, True, + "media_player", + "volume_up", + {"entity_id": "media_player.soundtouch_1"}, + True, ) assert mocked_volume.call_count == 3 assert mocked_volume_up.call_count == 1 @@ -558,7 +567,10 @@ async def test_volume_down( assert mocked_volume.call_count == 2 await hass.services.async_call( - "media_player", "volume_down", {"entity_id": "media_player.soundtouch_1"}, True, + "media_player", + "volume_down", + {"entity_id": "media_player.soundtouch_1"}, + True, ) assert mocked_volume.call_count == 3 assert mocked_volume_down.call_count == 1 @@ -614,7 +626,10 @@ async def test_play(mocked_play, mocked_status, mocked_volume, hass, one_device) assert mocked_volume.call_count == 2 await hass.services.async_call( - "media_player", "media_play", {"entity_id": "media_player.soundtouch_1"}, True, + "media_player", + "media_play", + {"entity_id": "media_player.soundtouch_1"}, + True, ) assert mocked_status.call_count == 3 assert mocked_play.call_count == 1 @@ -630,7 +645,10 @@ async def test_pause(mocked_pause, mocked_status, mocked_volume, hass, one_devic assert mocked_volume.call_count == 2 await hass.services.async_call( - "media_player", "media_pause", {"entity_id": "media_player.soundtouch_1"}, True, + "media_player", + "media_pause", + {"entity_id": "media_player.soundtouch_1"}, + True, ) assert mocked_status.call_count == 3 assert mocked_pause.call_count == 1 @@ -955,7 +973,11 @@ async def test_remove_zone_slave( @patch("libsoundtouch.device.SoundTouchDevice.add_zone_slave") async def test_add_zone_slave( - mocked_add_zone_slave, mocked_status, mocked_volume, hass, two_zones, + mocked_add_zone_slave, + mocked_status, + mocked_volume, + hass, + two_zones, ): """Test removing a slave from a zone.""" mocked_device = two_zones @@ -998,7 +1020,11 @@ async def test_add_zone_slave( @patch("libsoundtouch.device.SoundTouchDevice.create_zone") async def test_zone_attributes( - mocked_create_zone, mocked_status, mocked_volume, hass, two_zones, + mocked_create_zone, + mocked_status, + mocked_volume, + hass, + two_zones, ): """Test play everywhere.""" mocked_device = two_zones diff --git a/tests/components/speedtestdotnet/test_config_flow.py b/tests/components/speedtestdotnet/test_config_flow.py index 943da319aef..cfd79fb38f8 100644 --- a/tests/components/speedtestdotnet/test_config_flow.py +++ b/tests/components/speedtestdotnet/test_config_flow.py @@ -25,7 +25,8 @@ from tests.common import MockConfigEntry def mock_setup(): """Mock entry setup.""" with patch( - "homeassistant.components.speedtestdotnet.async_setup_entry", return_value=True, + "homeassistant.components.speedtestdotnet.async_setup_entry", + return_value=True, ): yield @@ -88,7 +89,12 @@ async def test_import_success(hass, mock_setup): async def test_options(hass): """Test updating options.""" - entry = MockConfigEntry(domain=DOMAIN, title="SpeedTest", data={}, options={},) + entry = MockConfigEntry( + domain=DOMAIN, + title="SpeedTest", + data={}, + options={}, + ) entry.add_to_hass(hass) with patch("speedtest.Speedtest") as mock_api: @@ -119,7 +125,11 @@ async def test_options(hass): async def test_integration_already_configured(hass): """Test integration is already configured.""" - entry = MockConfigEntry(domain=DOMAIN, data={}, options={},) + entry = MockConfigEntry( + domain=DOMAIN, + data={}, + options={}, + ) entry.add_to_hass(hass) result = await hass.config_entries.flow.async_init( speedtestdotnet.DOMAIN, context={"source": "user"} diff --git a/tests/components/speedtestdotnet/test_init.py b/tests/components/speedtestdotnet/test_init.py index 7b7eed67c0c..cadf97fc761 100644 --- a/tests/components/speedtestdotnet/test_init.py +++ b/tests/components/speedtestdotnet/test_init.py @@ -25,7 +25,10 @@ async def test_setup_with_config(hass): async def test_successful_config_entry(hass): """Test that SpeedTestDotNet is configured successfully.""" - entry = MockConfigEntry(domain=speedtestdotnet.DOMAIN, data={},) + entry = MockConfigEntry( + domain=speedtestdotnet.DOMAIN, + data={}, + ) entry.add_to_hass(hass) with patch("speedtest.Speedtest"), patch( @@ -35,13 +38,19 @@ async def test_successful_config_entry(hass): await hass.config_entries.async_setup(entry.entry_id) assert entry.state == config_entries.ENTRY_STATE_LOADED - assert forward_entry_setup.mock_calls[0][1] == (entry, "sensor",) + assert forward_entry_setup.mock_calls[0][1] == ( + entry, + "sensor", + ) async def test_setup_failed(hass): """Test SpeedTestDotNet failed due to an error.""" - entry = MockConfigEntry(domain=speedtestdotnet.DOMAIN, data={},) + entry = MockConfigEntry( + domain=speedtestdotnet.DOMAIN, + data={}, + ) entry.add_to_hass(hass) with patch("speedtest.Speedtest", side_effect=speedtest.ConfigRetrievalError): @@ -53,7 +62,10 @@ async def test_setup_failed(hass): async def test_unload_entry(hass): """Test removing SpeedTestDotNet.""" - entry = MockConfigEntry(domain=speedtestdotnet.DOMAIN, data={},) + entry = MockConfigEntry( + domain=speedtestdotnet.DOMAIN, + data={}, + ) entry.add_to_hass(hass) with patch("speedtest.Speedtest"): diff --git a/tests/components/spider/test_config_flow.py b/tests/components/spider/test_config_flow.py index 5c2c074027f..3bf7dd790b2 100644 --- a/tests/components/spider/test_config_flow.py +++ b/tests/components/spider/test_config_flow.py @@ -58,9 +58,11 @@ async def test_import(hass, spider): """Test import step.""" await setup.async_setup_component(hass, "persistent_notification", {}) with patch( - "homeassistant.components.spider.async_setup", return_value=True, + "homeassistant.components.spider.async_setup", + return_value=True, ) as mock_setup, patch( - "homeassistant.components.spider.async_setup_entry", return_value=True, + "homeassistant.components.spider.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, diff --git a/tests/components/squeezebox/test_config_flow.py b/tests/components/squeezebox/test_config_flow.py index e38188e4a0f..f325024cf00 100644 --- a/tests/components/squeezebox/test_config_flow.py +++ b/tests/components/squeezebox/test_config_flow.py @@ -46,7 +46,8 @@ async def test_user_form(hass): with patch("pysqueezebox.Server.async_query", return_value={"uuid": UUID},), patch( "homeassistant.components.squeezebox.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.squeezebox.async_setup_entry", return_value=True, + "homeassistant.components.squeezebox.async_setup_entry", + return_value=True, ) as mock_setup_entry, patch( "homeassistant.components.squeezebox.config_flow.async_discover", mock_discover ): @@ -106,11 +107,13 @@ async def test_user_form_timeout(hass): async def test_user_form_duplicate(hass): """Test duplicate discovered servers are skipped.""" with patch( - "homeassistant.components.squeezebox.config_flow.async_discover", mock_discover, + "homeassistant.components.squeezebox.config_flow.async_discover", + mock_discover, ), patch("homeassistant.components.squeezebox.config_flow.TIMEOUT", 0.1), patch( "homeassistant.components.squeezebox.async_setup", return_value=True ), patch( - "homeassistant.components.squeezebox.async_setup_entry", return_value=True, + "homeassistant.components.squeezebox.async_setup_entry", + return_value=True, ): entry = MockConfigEntry(domain=DOMAIN, unique_id=UUID) await hass.config_entries.async_add(entry) @@ -153,7 +156,8 @@ async def test_form_cannot_connect(hass): ) with patch( - "pysqueezebox.Server.async_query", return_value=False, + "pysqueezebox.Server.async_query", + return_value=False, ): result = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -172,7 +176,8 @@ async def test_form_cannot_connect(hass): async def test_discovery(hass): """Test handling of discovered server.""" with patch( - "pysqueezebox.Server.async_query", return_value={"uuid": UUID}, + "pysqueezebox.Server.async_query", + return_value={"uuid": UUID}, ): result = await hass.config_entries.flow.async_init( DOMAIN, @@ -200,7 +205,8 @@ async def test_import(hass): with patch("pysqueezebox.Server.async_query", return_value={"uuid": UUID},), patch( "homeassistant.components.squeezebox.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.squeezebox.async_setup_entry", return_value=True, + "homeassistant.components.squeezebox.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, @@ -248,9 +254,11 @@ async def test_import_existing(hass): with patch( "homeassistant.components.squeezebox.async_setup", return_value=True ), patch( - "homeassistant.components.squeezebox.async_setup_entry", return_value=True, + "homeassistant.components.squeezebox.async_setup_entry", + return_value=True, ), patch( - "pysqueezebox.Server.async_query", return_value={"ip": HOST, "uuid": UUID}, + "pysqueezebox.Server.async_query", + return_value={"ip": HOST, "uuid": UUID}, ): entry = MockConfigEntry(domain=DOMAIN, unique_id=UUID) await hass.config_entries.async_add(entry) diff --git a/tests/components/statistics/test_sensor.py b/tests/components/statistics/test_sensor.py index 7a96ec4e2a4..e60c5c2e9a5 100644 --- a/tests/components/statistics/test_sensor.py +++ b/tests/components/statistics/test_sensor.py @@ -479,11 +479,16 @@ async def test_reload(hass): assert hass.states.get("sensor.test") yaml_path = path.join( - _get_fixtures_base_path(), "fixtures", "statistics/configuration.yaml", + _get_fixtures_base_path(), + "fixtures", + "statistics/configuration.yaml", ) with patch.object(hass_config, "YAML_CONFIG_FILE", yaml_path): await hass.services.async_call( - DOMAIN, SERVICE_RELOAD, {}, blocking=True, + DOMAIN, + SERVICE_RELOAD, + {}, + blocking=True, ) await hass.async_block_till_done() diff --git a/tests/components/syncthru/test_config_flow.py b/tests/components/syncthru/test_config_flow.py index 8eb72ee264a..1df377ff0e8 100644 --- a/tests/components/syncthru/test_config_flow.py +++ b/tests/components/syncthru/test_config_flow.py @@ -58,7 +58,9 @@ async def test_already_configured_by_url(hass, aioclient_mock): mock_connection(aioclient_mock) result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_USER}, data=FIXTURE_USER_INPUT, + DOMAIN, + context={"source": config_entries.SOURCE_USER}, + data=FIXTURE_USER_INPUT, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY diff --git a/tests/components/synology_dsm/test_config_flow.py b/tests/components/synology_dsm/test_config_flow.py index f592ad90a88..64527c70964 100644 --- a/tests/components/synology_dsm/test_config_flow.py +++ b/tests/components/synology_dsm/test_config_flow.py @@ -421,7 +421,8 @@ async def test_options_flow(hass: HomeAssistantType, service: MagicMock): # Scan interval # Default result = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={}, + result["flow_id"], + user_input={}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert config_entry.options[CONF_SCAN_INTERVAL] == DEFAULT_SCAN_INTERVAL @@ -429,7 +430,8 @@ async def test_options_flow(hass: HomeAssistantType, service: MagicMock): # Manual result = await hass.config_entries.options.async_init(config_entry.entry_id) result = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={CONF_SCAN_INTERVAL: 2}, + result["flow_id"], + user_input={CONF_SCAN_INTERVAL: 2}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert config_entry.options[CONF_SCAN_INTERVAL] == 2 diff --git a/tests/components/tado/test_config_flow.py b/tests/components/tado/test_config_flow.py index 2e42a2bc1fb..9bd3db5e46b 100644 --- a/tests/components/tado/test_config_flow.py +++ b/tests/components/tado/test_config_flow.py @@ -30,11 +30,13 @@ async def test_form(hass): mock_tado_api = _get_mock_tado_api(getMe={"homes": [{"id": 1, "name": "myhome"}]}) with patch( - "homeassistant.components.tado.config_flow.Tado", return_value=mock_tado_api, + "homeassistant.components.tado.config_flow.Tado", + return_value=mock_tado_api, ), patch( "homeassistant.components.tado.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.tado.async_setup_entry", return_value=True, + "homeassistant.components.tado.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -59,11 +61,13 @@ async def test_import(hass): mock_tado_api = _get_mock_tado_api(getMe={"homes": [{"id": 1, "name": "myhome"}]}) with patch( - "homeassistant.components.tado.config_flow.Tado", return_value=mock_tado_api, + "homeassistant.components.tado.config_flow.Tado", + return_value=mock_tado_api, ), patch( "homeassistant.components.tado.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.tado.async_setup_entry", return_value=True, + "homeassistant.components.tado.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, @@ -93,7 +97,8 @@ async def test_form_invalid_auth(hass): mock_tado_api = _get_mock_tado_api(getMe=requests.HTTPError(response=response_mock)) with patch( - "homeassistant.components.tado.config_flow.Tado", return_value=mock_tado_api, + "homeassistant.components.tado.config_flow.Tado", + return_value=mock_tado_api, ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -115,7 +120,8 @@ async def test_form_cannot_connect(hass): mock_tado_api = _get_mock_tado_api(getMe=requests.HTTPError(response=response_mock)) with patch( - "homeassistant.components.tado.config_flow.Tado", return_value=mock_tado_api, + "homeassistant.components.tado.config_flow.Tado", + return_value=mock_tado_api, ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -135,7 +141,8 @@ async def test_no_homes(hass): mock_tado_api = _get_mock_tado_api(getMe={"homes": []}) with patch( - "homeassistant.components.tado.config_flow.Tado", return_value=mock_tado_api, + "homeassistant.components.tado.config_flow.Tado", + return_value=mock_tado_api, ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/tests/components/tado/util.py b/tests/components/tado/util.py index 5c060e76eec..7dc6a21faa7 100644 --- a/tests/components/tado/util.py +++ b/tests/components/tado/util.py @@ -10,7 +10,8 @@ from tests.common import MockConfigEntry, load_fixture async def async_init_integration( - hass: HomeAssistant, skip_setup: bool = False, + hass: HomeAssistant, + skip_setup: bool = False, ): """Set up the tado integration in Home Assistant.""" @@ -42,7 +43,8 @@ async def async_init_integration( with requests_mock.mock() as m: m.post("https://auth.tado.com/oauth/token", text=load_fixture(token_fixture)) m.get( - "https://my.tado.com/api/v2/me", text=load_fixture(me_fixture), + "https://my.tado.com/api/v2/me", + text=load_fixture(me_fixture), ) m.get( "https://my.tado.com/api/v2/homes/1/devices", diff --git a/tests/components/template/test_alarm_control_panel.py b/tests/components/template/test_alarm_control_panel.py index c6453ba31ac..d8d4b8fdcf2 100644 --- a/tests/components/template/test_alarm_control_panel.py +++ b/tests/components/template/test_alarm_control_panel.py @@ -346,7 +346,9 @@ async def test_invalid_panel_does_not_create(hass, caplog): async def test_no_panels_does_not_create(hass, caplog): """Test if there are no panels -> no creation.""" await setup.async_setup_component( - hass, "alarm_control_panel", {"alarm_control_panel": {"platform": "template"}}, + hass, + "alarm_control_panel", + {"alarm_control_panel": {"platform": "template"}}, ) await hass.async_block_till_done() diff --git a/tests/components/template/test_init.py b/tests/components/template/test_init.py index e655fd72987..2d14ec97574 100644 --- a/tests/components/template/test_init.py +++ b/tests/components/template/test_init.py @@ -34,11 +34,16 @@ async def test_reloadable(hass): assert len(hass.states.async_all()) == 2 yaml_path = path.join( - _get_fixtures_base_path(), "fixtures", "template/sensor_configuration.yaml", + _get_fixtures_base_path(), + "fixtures", + "template/sensor_configuration.yaml", ) with patch.object(config, "YAML_CONFIG_FILE", yaml_path): await hass.services.async_call( - DOMAIN, SERVICE_RELOAD, {}, blocking=True, + DOMAIN, + SERVICE_RELOAD, + {}, + blocking=True, ) await hass.async_block_till_done() @@ -76,11 +81,16 @@ async def test_reloadable_can_remove(hass): assert len(hass.states.async_all()) == 2 yaml_path = path.join( - _get_fixtures_base_path(), "fixtures", "template/empty_configuration.yaml", + _get_fixtures_base_path(), + "fixtures", + "template/empty_configuration.yaml", ) with patch.object(config, "YAML_CONFIG_FILE", yaml_path): await hass.services.async_call( - DOMAIN, SERVICE_RELOAD, {}, blocking=True, + DOMAIN, + SERVICE_RELOAD, + {}, + blocking=True, ) await hass.async_block_till_done() @@ -115,11 +125,16 @@ async def test_reloadable_stops_on_invalid_config(hass): assert len(hass.states.async_all()) == 2 yaml_path = path.join( - _get_fixtures_base_path(), "fixtures", "template/configuration.yaml.corrupt", + _get_fixtures_base_path(), + "fixtures", + "template/configuration.yaml.corrupt", ) with patch.object(config, "YAML_CONFIG_FILE", yaml_path): await hass.services.async_call( - DOMAIN, SERVICE_RELOAD, {}, blocking=True, + DOMAIN, + SERVICE_RELOAD, + {}, + blocking=True, ) await hass.async_block_till_done() @@ -155,11 +170,16 @@ async def test_reloadable_handles_partial_valid_config(hass): assert len(hass.states.async_all()) == 2 yaml_path = path.join( - _get_fixtures_base_path(), "fixtures", "template/broken_configuration.yaml", + _get_fixtures_base_path(), + "fixtures", + "template/broken_configuration.yaml", ) with patch.object(config, "YAML_CONFIG_FILE", yaml_path): await hass.services.async_call( - DOMAIN, SERVICE_RELOAD, {}, blocking=True, + DOMAIN, + SERVICE_RELOAD, + {}, + blocking=True, ) await hass.async_block_till_done() @@ -213,11 +233,16 @@ async def test_reloadable_multiple_platforms(hass): assert len(hass.states.async_all()) == 3 yaml_path = path.join( - _get_fixtures_base_path(), "fixtures", "template/sensor_configuration.yaml", + _get_fixtures_base_path(), + "fixtures", + "template/sensor_configuration.yaml", ) with patch.object(config, "YAML_CONFIG_FILE", yaml_path): await hass.services.async_call( - DOMAIN, SERVICE_RELOAD, {}, blocking=True, + DOMAIN, + SERVICE_RELOAD, + {}, + blocking=True, ) await hass.async_block_till_done() diff --git a/tests/components/template/test_sensor.py b/tests/components/template/test_sensor.py index 2b4a34e8c4a..31b298330e8 100644 --- a/tests/components/template/test_sensor.py +++ b/tests/components/template/test_sensor.py @@ -472,7 +472,8 @@ async def test_creating_sensor_loads_group(hass): hass.bus.async_listen(EVENT_COMPONENT_LOADED, set_after_dep_event) with patch( - "homeassistant.components.group.async_setup", new=async_setup_group, + "homeassistant.components.group.async_setup", + new=async_setup_group, ), patch( "homeassistant.components.template.sensor.async_setup_platform", new=async_setup_template, diff --git a/tests/components/template/test_switch.py b/tests/components/template/test_switch.py index 191e26a4266..6dab2569e59 100644 --- a/tests/components/template/test_switch.py +++ b/tests/components/template/test_switch.py @@ -541,7 +541,11 @@ async def test_off_action_optimistic(hass, calls): async def test_restore_state(hass): """Test state restoration.""" mock_restore_cache( - hass, (State("switch.s1", STATE_ON), State("switch.s2", STATE_OFF),), + hass, + ( + State("switch.s1", STATE_ON), + State("switch.s2", STATE_OFF), + ), ) hass.state = CoreState.starting diff --git a/tests/components/tibber/test_config_flow.py b/tests/components/tibber/test_config_flow.py index 6b2428fcff9..c92ec5bc5c7 100644 --- a/tests/components/tibber/test_config_flow.py +++ b/tests/components/tibber/test_config_flow.py @@ -52,7 +52,9 @@ async def test_create_entry(hass): async def test_flow_entry_already_exists(hass): """Test user input for config_entry that already exists.""" first_entry = MockConfigEntry( - domain="tibber", data={CONF_ACCESS_TOKEN: "valid"}, unique_id="tibber", + domain="tibber", + data={CONF_ACCESS_TOKEN: "valid"}, + unique_id="tibber", ) first_entry.add_to_hass(hass) diff --git a/tests/components/tile/test_config_flow.py b/tests/components/tile/test_config_flow.py index 7b9a80b427d..a1812d34a57 100644 --- a/tests/components/tile/test_config_flow.py +++ b/tests/components/tile/test_config_flow.py @@ -37,7 +37,8 @@ async def test_invalid_credentials(hass): } with patch( - "homeassistant.components.tile.config_flow.async_login", side_effect=TileError, + "homeassistant.components.tile.config_flow.async_login", + side_effect=TileError, ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=conf diff --git a/tests/components/toon/test_config_flow.py b/tests/components/toon/test_config_flow.py index 37e174b6dc4..6fb7a7b53dc 100644 --- a/tests/components/toon/test_config_flow.py +++ b/tests/components/toon/test_config_flow.py @@ -16,7 +16,8 @@ from tests.common import MockConfigEntry async def setup_component(hass): """Set up Toon component.""" await async_process_ha_core_config( - hass, {"external_url": "https://example.com"}, + hass, + {"external_url": "https://example.com"}, ) with patch("os.path.isfile", return_value=False): diff --git a/tests/components/tplink/test_init.py b/tests/components/tplink/test_init.py index 290151b10cc..8dbe7481339 100644 --- a/tests/components/tplink/test_init.py +++ b/tests/components/tplink/test_init.py @@ -68,7 +68,8 @@ async def test_configuring_device_types(hass, name, cls, platform, count): ) as discover, patch( "homeassistant.components.tplink.common.SmartDevice._query_helper" ), patch( - "homeassistant.components.tplink.light.async_setup_entry", return_value=True, + "homeassistant.components.tplink.light.async_setup_entry", + return_value=True, ): discovery_data = { f"123.123.123.{c}": cls("123.123.123.123") for c in range(count) diff --git a/tests/components/tplink/test_light.py b/tests/components/tplink/test_light.py index 241789270d7..cc9ecff896f 100644 --- a/tests/components/tplink/test_light.py +++ b/tests/components/tplink/test_light.py @@ -237,7 +237,10 @@ def dimmer_switch_mock_data_fixture() -> None: async def update_entity(hass: HomeAssistant, entity_id: str) -> None: """Run an update action for an entity.""" await hass.services.async_call( - HA_DOMAIN, SERVICE_UPDATE_ENTITY, {ATTR_ENTITY_ID: entity_id}, blocking=True, + HA_DOMAIN, + SERVICE_UPDATE_ENTITY, + {ATTR_ENTITY_ID: entity_id}, + blocking=True, ) await hass.async_block_till_done() @@ -321,7 +324,10 @@ async def test_smartswitch( assert state.state == "off" await hass.services.async_call( - LIGHT_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: "light.dimmer1"}, blocking=True, + LIGHT_DOMAIN, + SERVICE_TURN_ON, + {ATTR_ENTITY_ID: "light.dimmer1"}, + blocking=True, ) await hass.async_block_till_done() await update_entity(hass, "light.dimmer1") @@ -355,7 +361,10 @@ async def test_light(hass: HomeAssistant, light_mock_data: LightMockData) -> Non assert hass.states.get("light.light1") await hass.services.async_call( - LIGHT_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: "light.light1"}, blocking=True, + LIGHT_DOMAIN, + SERVICE_TURN_OFF, + {ATTR_ENTITY_ID: "light.light1"}, + blocking=True, ) await hass.async_block_till_done() await update_entity(hass, "light.light1") @@ -408,7 +417,10 @@ async def test_light(hass: HomeAssistant, light_mock_data: LightMockData) -> Non light_state["dft_on_state"]["saturation"] = 78 await hass.services.async_call( - LIGHT_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: "light.light1"}, blocking=True, + LIGHT_DOMAIN, + SERVICE_TURN_OFF, + {ATTR_ENTITY_ID: "light.light1"}, + blocking=True, ) await hass.async_block_till_done() await update_entity(hass, "light.light1") @@ -417,7 +429,10 @@ async def test_light(hass: HomeAssistant, light_mock_data: LightMockData) -> Non assert state.state == "off" await hass.services.async_call( - LIGHT_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: "light.light1"}, blocking=True, + LIGHT_DOMAIN, + SERVICE_TURN_ON, + {ATTR_ENTITY_ID: "light.light1"}, + blocking=True, ) await hass.async_block_till_done() await update_entity(hass, "light.light1") @@ -504,7 +519,10 @@ async def test_get_light_state_retry( await hass.async_block_till_done() await hass.services.async_call( - LIGHT_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: "light.light1"}, blocking=True, + LIGHT_DOMAIN, + SERVICE_TURN_OFF, + {ATTR_ENTITY_ID: "light.light1"}, + blocking=True, ) await hass.async_block_till_done() await update_entity(hass, "light.light1") diff --git a/tests/components/traccar/test_init.py b/tests/components/traccar/test_init.py index 942fd4b01d5..12e1ff5562a 100644 --- a/tests/components/traccar/test_init.py +++ b/tests/components/traccar/test_init.py @@ -61,7 +61,8 @@ async def setup_zones(loop, hass): async def webhook_id_fixture(hass, client): """Initialize the Traccar component and get the webhook_id.""" await async_process_ha_core_config( - hass, {"external_url": "http://example.com"}, + hass, + {"external_url": "http://example.com"}, ) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "user"} diff --git a/tests/components/tradfri/test_config_flow.py b/tests/components/tradfri/test_config_flow.py index 43e33706bf6..c9f72b7a9df 100644 --- a/tests/components/tradfri/test_config_flow.py +++ b/tests/components/tradfri/test_config_flow.py @@ -272,7 +272,10 @@ async def test_duplicate_discovery(hass, mock_auth, mock_entry_setup): async def test_discovery_updates_unique_id(hass): """Test a duplicate discovery host aborts and updates existing entry.""" - entry = MockConfigEntry(domain="tradfri", data={"host": "some-host"},) + entry = MockConfigEntry( + domain="tradfri", + data={"host": "some-host"}, + ) entry.add_to_hass(hass) flow = await hass.config_entries.flow.async_init( diff --git a/tests/components/tts/test_init.py b/tests/components/tts/test_init.py index a100ef22c65..d5f099175b1 100644 --- a/tests/components/tts/test_init.py +++ b/tests/components/tts/test_init.py @@ -87,7 +87,8 @@ def mutagen_mock(): async def internal_url_mock(hass): """Mock internal URL of the instance.""" await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) diff --git a/tests/components/tuya/test_config_flow.py b/tests/components/tuya/test_config_flow.py index eeda68cd2d3..2ce298640de 100644 --- a/tests/components/tuya/test_config_flow.py +++ b/tests/components/tuya/test_config_flow.py @@ -65,9 +65,11 @@ async def test_import(hass, tuya): """Test import step.""" await setup.async_setup_component(hass, "persistent_notification", {}) with patch( - "homeassistant.components.tuya.async_setup", return_value=True, + "homeassistant.components.tuya.async_setup", + return_value=True, ) as mock_setup, patch( - "homeassistant.components.tuya.async_setup_entry", return_value=True, + "homeassistant.components.tuya.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, diff --git a/tests/components/twitch/test_twitch.py b/tests/components/twitch/test_twitch.py index f66014d6557..33afde2a076 100644 --- a/tests/components/twitch/test_twitch.py +++ b/tests/components/twitch/test_twitch.py @@ -75,7 +75,8 @@ async def test_offline(hass): twitch_mock.streams.get_stream_by_user.return_value = None with patch( - "homeassistant.components.twitch.sensor.TwitchClient", return_value=twitch_mock, + "homeassistant.components.twitch.sensor.TwitchClient", + return_value=twitch_mock, ): assert await async_setup_component(hass, sensor.DOMAIN, CONFIG) is True await hass.async_block_till_done() @@ -94,7 +95,8 @@ async def test_streaming(hass): twitch_mock.streams.get_stream_by_user.return_value = STREAM_OBJECT_ONLINE with patch( - "homeassistant.components.twitch.sensor.TwitchClient", return_value=twitch_mock, + "homeassistant.components.twitch.sensor.TwitchClient", + return_value=twitch_mock, ): assert await async_setup_component(hass, sensor.DOMAIN, CONFIG) is True await hass.async_block_till_done() @@ -118,7 +120,8 @@ async def test_oauth_without_sub_and_follow(hass): twitch_mock.users.check_follows_channel.side_effect = HTTPError() with patch( - "homeassistant.components.twitch.sensor.TwitchClient", return_value=twitch_mock, + "homeassistant.components.twitch.sensor.TwitchClient", + return_value=twitch_mock, ): assert await async_setup_component(hass, sensor.DOMAIN, CONFIG_WITH_OAUTH) await hass.async_block_till_done() @@ -140,7 +143,8 @@ async def test_oauth_with_sub(hass): twitch_mock.users.check_follows_channel.side_effect = HTTPError() with patch( - "homeassistant.components.twitch.sensor.TwitchClient", return_value=twitch_mock, + "homeassistant.components.twitch.sensor.TwitchClient", + return_value=twitch_mock, ): assert await async_setup_component(hass, sensor.DOMAIN, CONFIG_WITH_OAUTH) await hass.async_block_till_done() @@ -164,7 +168,8 @@ async def test_oauth_with_follow(hass): twitch_mock.users.check_follows_channel.return_value = FOLLOW_ACTIVE with patch( - "homeassistant.components.twitch.sensor.TwitchClient", return_value=twitch_mock, + "homeassistant.components.twitch.sensor.TwitchClient", + return_value=twitch_mock, ): assert await async_setup_component(hass, sensor.DOMAIN, CONFIG_WITH_OAUTH) await hass.async_block_till_done() diff --git a/tests/components/unifi/test_controller.py b/tests/components/unifi/test_controller.py index 55483d135b6..5600f454336 100644 --- a/tests/components/unifi/test_controller.py +++ b/tests/components/unifi/test_controller.py @@ -130,7 +130,8 @@ async def setup_unifi_integration( return {} with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch( - "aiounifi.Controller.login", return_value=True, + "aiounifi.Controller.login", + return_value=True, ), patch("aiounifi.Controller.sites", return_value=sites), patch( "aiounifi.Controller.site_description", return_value=site_description ), patch( diff --git a/tests/components/unifi/test_device_tracker.py b/tests/components/unifi/test_device_tracker.py index 8f0df236c75..3fef8a16d68 100644 --- a/tests/components/unifi/test_device_tracker.py +++ b/tests/components/unifi/test_device_tracker.py @@ -265,7 +265,8 @@ async def test_tracked_clients(hass): async def test_tracked_devices(hass): """Test the update_items function with some devices.""" controller = await setup_unifi_integration( - hass, devices_response=[DEVICE_1, DEVICE_2], + hass, + devices_response=[DEVICE_1, DEVICE_2], ) assert len(hass.states.async_entity_ids(TRACKER_DOMAIN)) == 2 @@ -360,7 +361,9 @@ async def test_remove_clients(hass): async def test_controller_state_change(hass): """Verify entities state reflect on controller becoming unavailable.""" controller = await setup_unifi_integration( - hass, clients_response=[CLIENT_1], devices_response=[DEVICE_1], + hass, + clients_response=[CLIENT_1], + devices_response=[DEVICE_1], ) assert len(hass.states.async_entity_ids(TRACKER_DOMAIN)) == 2 @@ -390,7 +393,9 @@ async def test_controller_state_change(hass): async def test_option_track_clients(hass): """Test the tracking of clients can be turned off.""" controller = await setup_unifi_integration( - hass, clients_response=[CLIENT_1, CLIENT_2], devices_response=[DEVICE_1], + hass, + clients_response=[CLIENT_1, CLIENT_2], + devices_response=[DEVICE_1], ) assert len(hass.states.async_entity_ids(TRACKER_DOMAIN)) == 3 @@ -404,7 +409,8 @@ async def test_option_track_clients(hass): assert device_1 is not None hass.config_entries.async_update_entry( - controller.config_entry, options={CONF_TRACK_CLIENTS: False}, + controller.config_entry, + options={CONF_TRACK_CLIENTS: False}, ) await hass.async_block_till_done() @@ -418,7 +424,8 @@ async def test_option_track_clients(hass): assert device_1 is not None hass.config_entries.async_update_entry( - controller.config_entry, options={CONF_TRACK_CLIENTS: True}, + controller.config_entry, + options={CONF_TRACK_CLIENTS: True}, ) await hass.async_block_till_done() @@ -435,7 +442,9 @@ async def test_option_track_clients(hass): async def test_option_track_wired_clients(hass): """Test the tracking of wired clients can be turned off.""" controller = await setup_unifi_integration( - hass, clients_response=[CLIENT_1, CLIENT_2], devices_response=[DEVICE_1], + hass, + clients_response=[CLIENT_1, CLIENT_2], + devices_response=[DEVICE_1], ) assert len(hass.states.async_entity_ids(TRACKER_DOMAIN)) == 3 @@ -449,7 +458,8 @@ async def test_option_track_wired_clients(hass): assert device_1 is not None hass.config_entries.async_update_entry( - controller.config_entry, options={CONF_TRACK_WIRED_CLIENTS: False}, + controller.config_entry, + options={CONF_TRACK_WIRED_CLIENTS: False}, ) await hass.async_block_till_done() @@ -463,7 +473,8 @@ async def test_option_track_wired_clients(hass): assert device_1 is not None hass.config_entries.async_update_entry( - controller.config_entry, options={CONF_TRACK_WIRED_CLIENTS: True}, + controller.config_entry, + options={CONF_TRACK_WIRED_CLIENTS: True}, ) await hass.async_block_till_done() @@ -480,7 +491,9 @@ async def test_option_track_wired_clients(hass): async def test_option_track_devices(hass): """Test the tracking of devices can be turned off.""" controller = await setup_unifi_integration( - hass, clients_response=[CLIENT_1, CLIENT_2], devices_response=[DEVICE_1], + hass, + clients_response=[CLIENT_1, CLIENT_2], + devices_response=[DEVICE_1], ) assert len(hass.states.async_entity_ids(TRACKER_DOMAIN)) == 3 @@ -494,7 +507,8 @@ async def test_option_track_devices(hass): assert device_1 is not None hass.config_entries.async_update_entry( - controller.config_entry, options={CONF_TRACK_DEVICES: False}, + controller.config_entry, + options={CONF_TRACK_DEVICES: False}, ) await hass.async_block_till_done() @@ -508,7 +522,8 @@ async def test_option_track_devices(hass): assert device_1 is None hass.config_entries.async_update_entry( - controller.config_entry, options={CONF_TRACK_DEVICES: True}, + controller.config_entry, + options={CONF_TRACK_DEVICES: True}, ) await hass.async_block_till_done() @@ -544,7 +559,8 @@ async def test_option_ssid_filter(hass): # Setting SSID filter will remove clients outside of filter hass.config_entries.async_update_entry( - controller.config_entry, options={CONF_SSID_FILTER: ["ssid"]}, + controller.config_entry, + options={CONF_SSID_FILTER: ["ssid"]}, ) await hass.async_block_till_done() @@ -578,7 +594,8 @@ async def test_option_ssid_filter(hass): # Remove SSID filter hass.config_entries.async_update_entry( - controller.config_entry, options={CONF_SSID_FILTER: []}, + controller.config_entry, + options={CONF_SSID_FILTER: []}, ) event = {"meta": {"message": MESSAGE_CLIENT}, "data": [client_1_copy]} controller.api.message_handler(event) @@ -788,7 +805,8 @@ async def test_dont_track_clients(hass): assert device_1 is not None hass.config_entries.async_update_entry( - controller.config_entry, options={CONF_TRACK_CLIENTS: True}, + controller.config_entry, + options={CONF_TRACK_CLIENTS: True}, ) await hass.async_block_till_done() @@ -818,7 +836,8 @@ async def test_dont_track_devices(hass): assert device_1 is None hass.config_entries.async_update_entry( - controller.config_entry, options={CONF_TRACK_DEVICES: True}, + controller.config_entry, + options={CONF_TRACK_DEVICES: True}, ) await hass.async_block_till_done() @@ -847,7 +866,8 @@ async def test_dont_track_wired_clients(hass): assert client_2 is None hass.config_entries.async_update_entry( - controller.config_entry, options={CONF_TRACK_WIRED_CLIENTS: True}, + controller.config_entry, + options={CONF_TRACK_WIRED_CLIENTS: True}, ) await hass.async_block_till_done() diff --git a/tests/components/unifi/test_sensor.py b/tests/components/unifi/test_sensor.py index a768e61468d..2d5fbe96e0f 100644 --- a/tests/components/unifi/test_sensor.py +++ b/tests/components/unifi/test_sensor.py @@ -60,7 +60,8 @@ async def test_platform_manually_configured(hass): async def test_no_clients(hass): """Test the update_clients function when no clients are found.""" controller = await setup_unifi_integration( - hass, options={CONF_ALLOW_BANDWIDTH_SENSORS: True}, + hass, + options={CONF_ALLOW_BANDWIDTH_SENSORS: True}, ) assert len(controller.mock_requests) == 4 @@ -110,7 +111,8 @@ async def test_sensors(hass): assert wireless_client_tx.state == "6789.0" hass.config_entries.async_update_entry( - controller.config_entry, options={CONF_ALLOW_BANDWIDTH_SENSORS: False}, + controller.config_entry, + options={CONF_ALLOW_BANDWIDTH_SENSORS: False}, ) await hass.async_block_till_done() @@ -121,7 +123,8 @@ async def test_sensors(hass): assert wireless_client_tx is None hass.config_entries.async_update_entry( - controller.config_entry, options={CONF_ALLOW_BANDWIDTH_SENSORS: True}, + controller.config_entry, + options={CONF_ALLOW_BANDWIDTH_SENSORS: True}, ) await hass.async_block_till_done() @@ -135,7 +138,9 @@ async def test_sensors(hass): async def test_remove_sensors(hass): """Test the remove_items function with some clients.""" controller = await setup_unifi_integration( - hass, options={CONF_ALLOW_BANDWIDTH_SENSORS: True}, clients_response=CLIENTS, + hass, + options={CONF_ALLOW_BANDWIDTH_SENSORS: True}, + clients_response=CLIENTS, ) assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 4 assert len(hass.states.async_entity_ids(TRACKER_DOMAIN)) == 2 diff --git a/tests/components/unifi/test_switch.py b/tests/components/unifi/test_switch.py index ea198c6d8f4..6c4fc25d828 100644 --- a/tests/components/unifi/test_switch.py +++ b/tests/components/unifi/test_switch.py @@ -265,7 +265,8 @@ async def test_platform_manually_configured(hass): async def test_no_clients(hass): """Test the update_clients function when no clients are found.""" controller = await setup_unifi_integration( - hass, options={CONF_TRACK_CLIENTS: False, CONF_TRACK_DEVICES: False}, + hass, + options={CONF_TRACK_CLIENTS: False, CONF_TRACK_DEVICES: False}, ) assert len(controller.mock_requests) == 4 @@ -517,21 +518,24 @@ async def test_option_block_clients(hass): # Remove the second switch again hass.config_entries.async_update_entry( - controller.config_entry, options={CONF_BLOCK_CLIENT: [BLOCKED["mac"]]}, + controller.config_entry, + options={CONF_BLOCK_CLIENT: [BLOCKED["mac"]]}, ) await hass.async_block_till_done() assert len(hass.states.async_entity_ids(SWITCH_DOMAIN)) == 1 # Enable one and remove another one hass.config_entries.async_update_entry( - controller.config_entry, options={CONF_BLOCK_CLIENT: [UNBLOCKED["mac"]]}, + controller.config_entry, + options={CONF_BLOCK_CLIENT: [UNBLOCKED["mac"]]}, ) await hass.async_block_till_done() assert len(hass.states.async_entity_ids(SWITCH_DOMAIN)) == 0 # Remove one hass.config_entries.async_update_entry( - controller.config_entry, options={CONF_BLOCK_CLIENT: []}, + controller.config_entry, + options={CONF_BLOCK_CLIENT: []}, ) await hass.async_block_till_done() assert len(hass.states.async_entity_ids(SWITCH_DOMAIN)) == 0 @@ -604,7 +608,9 @@ async def test_ignore_multiple_poe_clients_on_same_port(hass): clients will be transparently marked as having POE as well. """ controller = await setup_unifi_integration( - hass, clients_response=POE_SWITCH_CLIENTS, devices_response=[DEVICE_1], + hass, + clients_response=POE_SWITCH_CLIENTS, + devices_response=[DEVICE_1], ) assert len(controller.mock_requests) == 4 diff --git a/tests/components/universal/test_media_player.py b/tests/components/universal/test_media_player.py index 52fbab19539..5333f72b2a9 100644 --- a/tests/components/universal/test_media_player.py +++ b/tests/components/universal/test_media_player.py @@ -860,11 +860,16 @@ async def test_reload(hass): ) yaml_path = path.join( - _get_fixtures_base_path(), "fixtures", "universal/configuration.yaml", + _get_fixtures_base_path(), + "fixtures", + "universal/configuration.yaml", ) with patch.object(hass_config, "YAML_CONFIG_FILE", yaml_path): await hass.services.async_call( - "universal", SERVICE_RELOAD, {}, blocking=True, + "universal", + SERVICE_RELOAD, + {}, + blocking=True, ) await hass.async_block_till_done() diff --git a/tests/components/upnp/test_config_flow.py b/tests/components/upnp/test_config_flow.py index 870aa13fc41..98df710d8fe 100644 --- a/tests/components/upnp/test_config_flow.py +++ b/tests/components/upnp/test_config_flow.py @@ -54,7 +54,8 @@ async def test_flow_ssdp_discovery(hass: HomeAssistantType): # Confirm via step ssdp_confirm. result = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input={}, + result["flow_id"], + user_input={}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY @@ -119,7 +120,8 @@ async def test_flow_user(hass: HomeAssistantType): # Confirmed via step user. result = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input={"usn": usn}, + result["flow_id"], + user_input={"usn": usn}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY @@ -198,12 +200,15 @@ async def test_options_flow(hass: HomeAssistantType): assert coordinator.update_interval == timedelta(seconds=DEFAULT_SCAN_INTERVAL) # Options flow with no input results in form. - result = await hass.config_entries.options.async_init(config_entry.entry_id,) + result = await hass.config_entries.options.async_init( + config_entry.entry_id, + ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM # Options flow with input results in update to entry. result2 = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={CONFIG_ENTRY_SCAN_INTERVAL: 60}, + result["flow_id"], + user_input={CONFIG_ENTRY_SCAN_INTERVAL: 60}, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert config_entry.options == { diff --git a/tests/components/vera/test_climate.py b/tests/components/vera/test_climate.py index f52bf375d8e..f11f3ea5a3b 100644 --- a/tests/components/vera/test_climate.py +++ b/tests/components/vera/test_climate.py @@ -87,7 +87,9 @@ async def test_climate( assert hass.states.get(entity_id).state == HVAC_MODE_OFF await hass.services.async_call( - "climate", "set_fan_mode", {"entity_id": entity_id, "fan_mode": "on"}, + "climate", + "set_fan_mode", + {"entity_id": entity_id, "fan_mode": "on"}, ) await hass.async_block_till_done() vera_device.turn_auto_on.assert_called() @@ -97,7 +99,9 @@ async def test_climate( assert hass.states.get(entity_id).attributes["fan_mode"] == FAN_ON await hass.services.async_call( - "climate", "set_fan_mode", {"entity_id": entity_id, "fan_mode": "off"}, + "climate", + "set_fan_mode", + {"entity_id": entity_id, "fan_mode": "off"}, ) await hass.async_block_till_done() vera_device.turn_auto_on.assert_called() @@ -107,7 +111,9 @@ async def test_climate( assert hass.states.get(entity_id).attributes["fan_mode"] == FAN_AUTO await hass.services.async_call( - "climate", "set_temperature", {"entity_id": entity_id, "temperature": 30}, + "climate", + "set_temperature", + {"entity_id": entity_id, "temperature": 30}, ) await hass.async_block_till_done() vera_device.set_temperature.assert_called_with(30) @@ -145,7 +151,9 @@ async def test_climate_f( update_callback = component_data.controller_data.update_callback await hass.services.async_call( - "climate", "set_temperature", {"entity_id": entity_id, "temperature": 30}, + "climate", + "set_temperature", + {"entity_id": entity_id, "temperature": 30}, ) await hass.async_block_till_done() vera_device.set_temperature.assert_called_with(86) diff --git a/tests/components/vera/test_cover.py b/tests/components/vera/test_cover.py index a2dae2bd7f8..311c8013d86 100644 --- a/tests/components/vera/test_cover.py +++ b/tests/components/vera/test_cover.py @@ -30,7 +30,9 @@ async def test_cover( assert hass.states.get(entity_id).attributes["current_position"] == 0 await hass.services.async_call( - "cover", "open_cover", {"entity_id": entity_id}, + "cover", + "open_cover", + {"entity_id": entity_id}, ) await hass.async_block_till_done() vera_device.open.assert_called() @@ -42,7 +44,9 @@ async def test_cover( assert hass.states.get(entity_id).attributes["current_position"] == 100 await hass.services.async_call( - "cover", "set_cover_position", {"entity_id": entity_id, "position": 50}, + "cover", + "set_cover_position", + {"entity_id": entity_id, "position": 50}, ) await hass.async_block_till_done() vera_device.set_level.assert_called_with(50) @@ -54,7 +58,9 @@ async def test_cover( assert hass.states.get(entity_id).attributes["current_position"] == 50 await hass.services.async_call( - "cover", "stop_cover", {"entity_id": entity_id}, + "cover", + "stop_cover", + {"entity_id": entity_id}, ) await hass.async_block_till_done() vera_device.stop.assert_called() @@ -64,7 +70,9 @@ async def test_cover( assert hass.states.get(entity_id).attributes["current_position"] == 50 await hass.services.async_call( - "cover", "close_cover", {"entity_id": entity_id}, + "cover", + "close_cover", + {"entity_id": entity_id}, ) await hass.async_block_till_done() vera_device.close.assert_called() diff --git a/tests/components/vera/test_light.py b/tests/components/vera/test_light.py index 14194d0af52..99391d8d82a 100644 --- a/tests/components/vera/test_light.py +++ b/tests/components/vera/test_light.py @@ -32,7 +32,9 @@ async def test_light( assert hass.states.get(entity_id).state == "off" await hass.services.async_call( - "light", "turn_on", {"entity_id": entity_id}, + "light", + "turn_on", + {"entity_id": entity_id}, ) await hass.async_block_till_done() vera_device.switch_on.assert_called() @@ -42,7 +44,9 @@ async def test_light( assert hass.states.get(entity_id).state == "on" await hass.services.async_call( - "light", "turn_on", {"entity_id": entity_id, ATTR_HS_COLOR: [300, 70]}, + "light", + "turn_on", + {"entity_id": entity_id, ATTR_HS_COLOR: [300, 70]}, ) await hass.async_block_till_done() vera_device.set_color.assert_called_with((255, 76, 255)) @@ -54,7 +58,9 @@ async def test_light( assert hass.states.get(entity_id).attributes["hs_color"] == (300.0, 70.196) await hass.services.async_call( - "light", "turn_on", {"entity_id": entity_id, ATTR_BRIGHTNESS: 55}, + "light", + "turn_on", + {"entity_id": entity_id, ATTR_BRIGHTNESS: 55}, ) await hass.async_block_till_done() vera_device.set_brightness.assert_called_with(55) @@ -66,7 +72,9 @@ async def test_light( assert hass.states.get(entity_id).attributes["brightness"] == 55 await hass.services.async_call( - "light", "turn_off", {"entity_id": entity_id}, + "light", + "turn_off", + {"entity_id": entity_id}, ) await hass.async_block_till_done() vera_device.switch_off.assert_called() diff --git a/tests/components/vera/test_lock.py b/tests/components/vera/test_lock.py index 901e09040e9..11af1f5a7b7 100644 --- a/tests/components/vera/test_lock.py +++ b/tests/components/vera/test_lock.py @@ -29,7 +29,9 @@ async def test_lock( assert hass.states.get(entity_id).state == STATE_UNLOCKED await hass.services.async_call( - "lock", "lock", {"entity_id": entity_id}, + "lock", + "lock", + {"entity_id": entity_id}, ) await hass.async_block_till_done() vera_device.lock.assert_called() @@ -39,7 +41,9 @@ async def test_lock( assert hass.states.get(entity_id).state == STATE_LOCKED await hass.services.async_call( - "lock", "unlock", {"entity_id": entity_id}, + "lock", + "unlock", + {"entity_id": entity_id}, ) await hass.async_block_till_done() vera_device.unlock.assert_called() diff --git a/tests/components/vera/test_scene.py b/tests/components/vera/test_scene.py index 8f96b7a133a..29ef338b9f1 100644 --- a/tests/components/vera/test_scene.py +++ b/tests/components/vera/test_scene.py @@ -18,10 +18,13 @@ async def test_scene( entity_id = "scene.dev1_1" await vera_component_factory.configure_component( - hass=hass, controller_config=new_simple_controller_config(scenes=(vera_scene,)), + hass=hass, + controller_config=new_simple_controller_config(scenes=(vera_scene,)), ) await hass.services.async_call( - "scene", "turn_on", {"entity_id": entity_id}, + "scene", + "turn_on", + {"entity_id": entity_id}, ) await hass.async_block_till_done() diff --git a/tests/components/vera/test_switch.py b/tests/components/vera/test_switch.py index 2a8bfe68185..60e31add4bd 100644 --- a/tests/components/vera/test_switch.py +++ b/tests/components/vera/test_switch.py @@ -28,7 +28,9 @@ async def test_switch( assert hass.states.get(entity_id).state == "off" await hass.services.async_call( - "switch", "turn_on", {"entity_id": entity_id}, + "switch", + "turn_on", + {"entity_id": entity_id}, ) await hass.async_block_till_done() vera_device.switch_on.assert_called() @@ -38,7 +40,9 @@ async def test_switch( assert hass.states.get(entity_id).state == "on" await hass.services.async_call( - "switch", "turn_off", {"entity_id": entity_id}, + "switch", + "turn_off", + {"entity_id": entity_id}, ) await hass.async_block_till_done() vera_device.switch_off.assert_called() diff --git a/tests/components/vilfo/test_config_flow.py b/tests/components/vilfo/test_config_flow.py index d9e8a2ffd24..167fc71a78a 100644 --- a/tests/components/vilfo/test_config_flow.py +++ b/tests/components/vilfo/test_config_flow.py @@ -110,7 +110,8 @@ async def test_form_already_configured(hass): ) with patch("vilfo.Client.ping", return_value=None), patch( - "vilfo.Client.get_board_information", return_value=None, + "vilfo.Client.get_board_information", + return_value=None, ), patch("vilfo.Client.resolve_mac_address", return_value=None): first_flow_result2 = await hass.config_entries.flow.async_configure( first_flow_result1["flow_id"], @@ -122,7 +123,8 @@ async def test_form_already_configured(hass): ) with patch("vilfo.Client.ping", return_value=None), patch( - "vilfo.Client.get_board_information", return_value=None, + "vilfo.Client.get_board_information", + return_value=None, ), patch("vilfo.Client.resolve_mac_address", return_value=None): second_flow_result2 = await hass.config_entries.flow.async_configure( second_flow_result1["flow_id"], diff --git a/tests/components/vizio/conftest.py b/tests/components/vizio/conftest.py index 5daedf6fa57..492494fc75e 100644 --- a/tests/components/vizio/conftest.py +++ b/tests/components/vizio/conftest.py @@ -107,7 +107,8 @@ def vizio_invalid_pin_failure_fixture(): "homeassistant.components.vizio.config_flow.VizioAsync.start_pair", return_value=MockStartPairingResponse(CH_TYPE, RESPONSE_TOKEN), ), patch( - "homeassistant.components.vizio.config_flow.VizioAsync.pair", return_value=None, + "homeassistant.components.vizio.config_flow.VizioAsync.pair", + return_value=None, ): yield diff --git a/tests/components/vizio/test_media_player.py b/tests/components/vizio/test_media_player.py index c0d780ed7ba..6b19089057b 100644 --- a/tests/components/vizio/test_media_player.py +++ b/tests/components/vizio/test_media_player.py @@ -182,7 +182,8 @@ async def _test_setup_speaker( } async with _cm_for_test_setup_without_apps( - audio_settings, vizio_power_state, + audio_settings, + vizio_power_state, ): with patch( "homeassistant.components.vizio.media_player.VizioAsync.get_current_app_config", @@ -208,7 +209,8 @@ async def _cm_for_test_setup_tv_with_apps( ) async with _cm_for_test_setup_without_apps( - {"volume": int(MAX_VOLUME[VIZIO_DEVICE_CLASS_TV] / 2), "mute": "Off"}, True, + {"volume": int(MAX_VOLUME[VIZIO_DEVICE_CLASS_TV] / 2), "mute": "Off"}, + True, ): with patch( "homeassistant.components.vizio.media_player.VizioAsync.get_current_app_config", @@ -266,7 +268,10 @@ async def _test_service( f"homeassistant.components.vizio.media_player.VizioAsync.{vizio_func_name}" ) as service_call: await hass.services.async_call( - domain, ha_service_name, service_data=service_data, blocking=True, + domain, + ha_service_name, + service_data=service_data, + blocking=True, ) assert service_call.called @@ -423,7 +428,8 @@ async def test_options_update( updated_options = {CONF_VOLUME_STEP: VOLUME_STEP} new_options.update(updated_options) hass.config_entries.async_update_entry( - entry=config_entry, options=new_options, + entry=config_entry, + options=new_options, ) assert config_entry.options == updated_options await _test_service( @@ -565,7 +571,9 @@ async def test_setup_with_apps_additional_apps_config( ) -> None: """Test device setup with apps and apps["additional_configs"] in config.""" async with _cm_for_test_setup_tv_with_apps( - hass, MOCK_TV_WITH_ADDITIONAL_APPS_CONFIG, ADDITIONAL_APP_CONFIG["config"], + hass, + MOCK_TV_WITH_ADDITIONAL_APPS_CONFIG, + ADDITIONAL_APP_CONFIG["config"], ): attr = hass.states.get(ENTITY_ID).attributes assert attr["source_list"].count(CURRENT_APP) == 1 @@ -677,7 +685,8 @@ async def test_setup_tv_without_mute( ) async with _cm_for_test_setup_without_apps( - {"volume": int(MAX_VOLUME[VIZIO_DEVICE_CLASS_TV] / 2)}, STATE_ON, + {"volume": int(MAX_VOLUME[VIZIO_DEVICE_CLASS_TV] / 2)}, + STATE_ON, ): await _add_config_entry_to_hass(hass, config_entry) diff --git a/tests/components/volumio/test_config_flow.py b/tests/components/volumio/test_config_flow.py index b0532ce55d8..a80d527b3f8 100644 --- a/tests/components/volumio/test_config_flow.py +++ b/tests/components/volumio/test_config_flow.py @@ -43,10 +43,12 @@ async def test_form(hass): ), patch( "homeassistant.components.volumio.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.volumio.async_setup_entry", return_value=True, + "homeassistant.components.volumio.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], TEST_CONNECTION, + result["flow_id"], + TEST_CONNECTION, ) assert result2["type"] == "create_entry" @@ -80,10 +82,12 @@ async def test_form_updates_unique_id(hass): "homeassistant.components.volumio.config_flow.Volumio.get_system_info", return_value=TEST_SYSTEM_INFO, ), patch("homeassistant.components.volumio.async_setup", return_value=True), patch( - "homeassistant.components.volumio.async_setup_entry", return_value=True, + "homeassistant.components.volumio.async_setup_entry", + return_value=True, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], TEST_CONNECTION, + result["flow_id"], + TEST_CONNECTION, ) await hass.async_block_till_done() @@ -107,10 +111,12 @@ async def test_empty_system_info(hass): ), patch( "homeassistant.components.volumio.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.volumio.async_setup_entry", return_value=True, + "homeassistant.components.volumio.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], TEST_CONNECTION, + result["flow_id"], + TEST_CONNECTION, ) assert result2["type"] == "create_entry" @@ -138,7 +144,8 @@ async def test_form_cannot_connect(hass): side_effect=CannotConnectError, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], TEST_CONNECTION, + result["flow_id"], + TEST_CONNECTION, ) assert result2["type"] == "form" @@ -156,7 +163,8 @@ async def test_form_exception(hass): side_effect=Exception, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], TEST_CONNECTION, + result["flow_id"], + TEST_CONNECTION, ) assert result2["type"] == "form" @@ -176,10 +184,12 @@ async def test_discovery(hass): ), patch( "homeassistant.components.volumio.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.volumio.async_setup_entry", return_value=True, + "homeassistant.components.volumio.async_setup_entry", + return_value=True, ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input={}, + result["flow_id"], + user_input={}, ) assert result2["type"] == "create_entry" @@ -206,7 +216,8 @@ async def test_discovery_cannot_connect(hass): side_effect=CannotConnectError, ): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input={}, + result["flow_id"], + user_input={}, ) assert result2["type"] == "abort" @@ -247,7 +258,8 @@ async def test_discovery_updates_unique_id(hass): with patch( "homeassistant.components.volumio.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.volumio.async_setup_entry", return_value=True, + "homeassistant.components.volumio.async_setup_entry", + return_value=True, ) as mock_setup_entry: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "zeroconf"}, data=TEST_DISCOVERY diff --git a/tests/components/webhook/test_init.py b/tests/components/webhook/test_init.py index 9051b6325bf..44c45c1e9d8 100644 --- a/tests/components/webhook/test_init.py +++ b/tests/components/webhook/test_init.py @@ -37,7 +37,8 @@ async def test_unregistering_webhook(hass, mock_client): async def test_generate_webhook_url(hass): """Test we generate a webhook url correctly.""" await async_process_ha_core_config( - hass, {"external_url": "https://example.com"}, + hass, + {"external_url": "https://example.com"}, ) url = hass.components.webhook.async_generate_url("some_id") diff --git a/tests/components/webostv/test_media_player.py b/tests/components/webostv/test_media_player.py index 3b213303281..1b85daa1922 100644 --- a/tests/components/webostv/test_media_player.py +++ b/tests/components/webostv/test_media_player.py @@ -50,7 +50,9 @@ def client_fixture(): async def setup_webostv(hass): """Initialize webostv and media_player for tests.""" assert await async_setup_component( - hass, DOMAIN, {DOMAIN: {CONF_HOST: "fake", CONF_NAME: NAME}}, + hass, + DOMAIN, + {DOMAIN: {CONF_HOST: "fake", CONF_NAME: NAME}}, ) await hass.async_block_till_done() diff --git a/tests/components/wiffi/test_config_flow.py b/tests/components/wiffi/test_config_flow.py index 87e119d2c6a..cd129d112bc 100644 --- a/tests/components/wiffi/test_config_flow.py +++ b/tests/components/wiffi/test_config_flow.py @@ -82,7 +82,8 @@ async def test_form(hass, dummy_tcp_server): assert result["step_id"] == config_entries.SOURCE_USER result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input=MOCK_CONFIG, + result["flow_id"], + user_input=MOCK_CONFIG, ) assert result2["type"] == RESULT_TYPE_CREATE_ENTRY @@ -94,7 +95,8 @@ async def test_form_addr_in_use(hass, addr_in_use): ) result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input=MOCK_CONFIG, + result["flow_id"], + user_input=MOCK_CONFIG, ) assert result2["type"] == RESULT_TYPE_ABORT assert result2["reason"] == "addr_in_use" @@ -107,7 +109,8 @@ async def test_form_start_server_failed(hass, start_server_failed): ) result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input=MOCK_CONFIG, + result["flow_id"], + user_input=MOCK_CONFIG, ) assert result2["type"] == RESULT_TYPE_ABORT assert result2["reason"] == "start_server_failed" diff --git a/tests/components/wilight/__init__.py b/tests/components/wilight/__init__.py index 9c7ba13fc7c..e1c31345235 100644 --- a/tests/components/wilight/__init__.py +++ b/tests/components/wilight/__init__.py @@ -62,7 +62,9 @@ MOCK_SSDP_DISCOVERY_INFO_LIGHT_FAN = { } -async def setup_integration(hass: HomeAssistantType,) -> MockConfigEntry: +async def setup_integration( + hass: HomeAssistantType, +) -> MockConfigEntry: """Mock ConfigEntry in Home Assistant.""" entry = MockConfigEntry( diff --git a/tests/components/wilight/test_config_flow.py b/tests/components/wilight/test_config_flow.py index 1de190c51d9..7ca6b3241ff 100644 --- a/tests/components/wilight/test_config_flow.py +++ b/tests/components/wilight/test_config_flow.py @@ -35,7 +35,8 @@ def mock_dummy_get_components_from_model(): """Mock a clear components list.""" components = [] with patch( - "pywilight.get_components_from_model", return_value=components, + "pywilight.get_components_from_model", + return_value=components, ): yield components @@ -122,7 +123,9 @@ async def test_ssdp_device_exists_abort(hass: HomeAssistantType) -> None: discovery_info = MOCK_SSDP_DISCOVERY_INFO_P_B.copy() result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info, + DOMAIN, + context={CONF_SOURCE: SOURCE_SSDP}, + data=discovery_info, ) assert result["type"] == RESULT_TYPE_ABORT diff --git a/tests/components/wilight/test_init.py b/tests/components/wilight/test_init.py index 11b86d0c367..01ed57fdcd1 100644 --- a/tests/components/wilight/test_init.py +++ b/tests/components/wilight/test_init.py @@ -36,7 +36,8 @@ def mock_dummy_device_from_host(): device.set_dummy(True) with patch( - "pywilight.device_from_host", return_value=device, + "pywilight.device_from_host", + return_value=device, ): yield device diff --git a/tests/components/wilight/test_light.py b/tests/components/wilight/test_light.py index 555c1487bec..4d4a32604ad 100644 --- a/tests/components/wilight/test_light.py +++ b/tests/components/wilight/test_light.py @@ -36,7 +36,8 @@ def mock_dummy_get_components_from_model_light(): """Mock a components list with light.""" components = ["light"] with patch( - "pywilight.get_components_from_model", return_value=components, + "pywilight.get_components_from_model", + return_value=components, ): yield components @@ -56,7 +57,8 @@ def mock_dummy_device_from_host_light_fan(): device.set_dummy(True) with patch( - "pywilight.device_from_host", return_value=device, + "pywilight.device_from_host", + return_value=device, ): yield device @@ -76,7 +78,8 @@ def mock_dummy_device_from_host_pb(): device.set_dummy(True) with patch( - "pywilight.device_from_host", return_value=device, + "pywilight.device_from_host", + return_value=device, ): yield device @@ -96,7 +99,8 @@ def mock_dummy_device_from_host_dimmer(): device.set_dummy(True) with patch( - "pywilight.device_from_host", return_value=device, + "pywilight.device_from_host", + return_value=device, ): yield device @@ -116,7 +120,8 @@ def mock_dummy_device_from_host_color(): device.set_dummy(True) with patch( - "pywilight.device_from_host", return_value=device, + "pywilight.device_from_host", + return_value=device, ): yield device diff --git a/tests/components/withings/common.py b/tests/components/withings/common.py index 3ed3b39daee..a09876868a7 100644 --- a/tests/components/withings/common.py +++ b/tests/components/withings/common.py @@ -252,7 +252,8 @@ class ComponentFactory: data_manager = get_data_manager_by_user_id(self._hass, user_id) self._aioclient_mock.clear_requests() self._aioclient_mock.request( - "HEAD", data_manager.webhook_config.url, + "HEAD", + data_manager.webhook_config.url, ) return self._api_class_mock.return_value diff --git a/tests/components/withings/test_binary_sensor.py b/tests/components/withings/test_binary_sensor.py index 8f3347c8867..3477671ea79 100644 --- a/tests/components/withings/test_binary_sensor.py +++ b/tests/components/withings/test_binary_sensor.py @@ -21,7 +21,9 @@ async def test_binary_sensor( person0 = new_profile_config("person0", 0) person1 = new_profile_config("person1", 1) - entity_registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry() + entity_registry: EntityRegistry = ( + await hass.helpers.entity_registry.async_get_registry() + ) await component_factory.configure_component(profile_configs=(person0, person1)) assert not await async_get_entity_id(hass, in_bed_attribute, person0.user_id) diff --git a/tests/components/withings/test_common.py b/tests/components/withings/test_common.py index 1e9711a71a6..2bf71ab7aa5 100644 --- a/tests/components/withings/test_common.py +++ b/tests/components/withings/test_common.py @@ -104,7 +104,9 @@ async def test_webhook_post( async def test_webhook_head( - hass: HomeAssistant, component_factory: ComponentFactory, aiohttp_client, + hass: HomeAssistant, + component_factory: ComponentFactory, + aiohttp_client, ) -> None: """Test head method on webhook view.""" person0 = new_profile_config("person0", 0) @@ -119,7 +121,9 @@ async def test_webhook_head( async def test_webhook_put( - hass: HomeAssistant, component_factory: ComponentFactory, aiohttp_client, + hass: HomeAssistant, + component_factory: ComponentFactory, + aiohttp_client, ) -> None: """Test webhook callback.""" person0 = new_profile_config("person0", 0) @@ -187,7 +191,9 @@ async def test_data_manager_webhook_subscription( aioclient_mock.clear_requests() aioclient_mock.request( - "HEAD", data_manager.webhook_config.url, status=200, + "HEAD", + data_manager.webhook_config.url, + status=200, ) # Test subscribing diff --git a/tests/components/withings/test_config_flow.py b/tests/components/withings/test_config_flow.py index f47a8f95e53..2b4776c0ca5 100644 --- a/tests/components/withings/test_config_flow.py +++ b/tests/components/withings/test_config_flow.py @@ -65,7 +65,10 @@ async def test_config_reauth_profile( assert result["step_id"] == "reauth" assert result["description_placeholders"] == {const.PROFILE: "person0"} - result = await hass.config_entries.flow.async_configure(result["flow_id"], {},) + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) # pylint: disable=protected-access state = config_entry_oauth2_flow._encode_jwt(hass, {"flow_id": result["flow_id"]}) diff --git a/tests/components/withings/test_sensor.py b/tests/components/withings/test_sensor.py index 3370c23e3d8..16b83a585aa 100644 --- a/tests/components/withings/test_sensor.py +++ b/tests/components/withings/test_sensor.py @@ -304,7 +304,9 @@ async def test_sensor_default_enabled_entities( hass: HomeAssistant, component_factory: ComponentFactory ) -> None: """Test entities enabled by default.""" - entity_registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry() + entity_registry: EntityRegistry = ( + await hass.helpers.entity_registry.async_get_registry() + ) await component_factory.configure_component(profile_configs=(PERSON0,)) @@ -345,7 +347,9 @@ async def test_all_entities( hass: HomeAssistant, component_factory: ComponentFactory ) -> None: """Test all entities.""" - entity_registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry() + entity_registry: EntityRegistry = ( + await hass.helpers.entity_registry.async_get_registry() + ) with patch( "homeassistant.components.withings.sensor.BaseWithingsSensor.entity_registry_enabled_default" diff --git a/tests/components/wled/test_config_flow.py b/tests/components/wled/test_config_flow.py index f5f1ec3099c..a0c5c11e7ce 100644 --- a/tests/components/wled/test_config_flow.py +++ b/tests/components/wled/test_config_flow.py @@ -18,7 +18,8 @@ from tests.test_util.aiohttp import AiohttpClientMocker async def test_show_user_form(hass: HomeAssistant) -> None: """Test that the user set up form is served.""" result = await hass.config_entries.flow.async_init( - config_flow.DOMAIN, context={"source": SOURCE_USER}, + config_flow.DOMAIN, + context={"source": SOURCE_USER}, ) assert result["step_id"] == "user" @@ -193,7 +194,8 @@ async def test_full_user_flow_implementation( ) result = await hass.config_entries.flow.async_init( - config_flow.DOMAIN, context={"source": SOURCE_USER}, + config_flow.DOMAIN, + context={"source": SOURCE_USER}, ) assert result["step_id"] == "user" diff --git a/tests/components/wled/test_light.py b/tests/components/wled/test_light.py index 35e8ea0f7ef..66aa50cb71b 100644 --- a/tests/components/wled/test_light.py +++ b/tests/components/wled/test_light.py @@ -114,7 +114,9 @@ async def test_segment_change_state( ) await hass.async_block_till_done() light_mock.assert_called_once_with( - on=False, segment_id=0, transition=50, + on=False, + segment_id=0, + transition=50, ) with patch("wled.WLED.segment") as light_mock: @@ -149,7 +151,9 @@ async def test_segment_change_state( ) await hass.async_block_till_done() light_mock.assert_called_once_with( - color_primary=(255, 159, 70), on=True, segment_id=0, + color_primary=(255, 159, 70), + on=True, + segment_id=0, ) @@ -168,7 +172,8 @@ async def test_master_change_state( ) await hass.async_block_till_done() light_mock.assert_called_once_with( - on=False, transition=50, + on=False, + transition=50, ) with patch("wled.WLED.master") as light_mock: @@ -184,7 +189,9 @@ async def test_master_change_state( ) await hass.async_block_till_done() light_mock.assert_called_once_with( - brightness=42, on=True, transition=50, + brightness=42, + on=True, + transition=50, ) with patch("wled.WLED.master") as light_mock: @@ -196,7 +203,8 @@ async def test_master_change_state( ) await hass.async_block_till_done() light_mock.assert_called_once_with( - on=False, transition=50, + on=False, + transition=50, ) with patch("wled.WLED.master") as light_mock: @@ -212,7 +220,9 @@ async def test_master_change_state( ) await hass.async_block_till_done() light_mock.assert_called_once_with( - brightness=42, on=True, transition=50, + brightness=42, + on=True, + transition=50, ) @@ -231,7 +241,8 @@ async def test_dynamically_handle_segments( # Test removal if segment went missing, including the master entity with patch( - "homeassistant.components.wled.WLED.update", return_value=device, + "homeassistant.components.wled.WLED.update", + return_value=device, ): async_fire_time_changed(hass, dt_util.utcnow() + SCAN_INTERVAL) await hass.async_block_till_done() @@ -259,7 +270,8 @@ async def test_single_segment_behavior( # Test absent master with patch( - "homeassistant.components.wled.WLED.update", return_value=device, + "homeassistant.components.wled.WLED.update", + return_value=device, ): async_fire_time_changed(hass, dt_util.utcnow() + SCAN_INTERVAL) await hass.async_block_till_done() @@ -274,7 +286,8 @@ async def test_single_segment_behavior( device.state.brightness = 100 device.state.segments[0].brightness = 255 with patch( - "homeassistant.components.wled.WLED.update", return_value=device, + "homeassistant.components.wled.WLED.update", + return_value=device, ): async_fire_time_changed(hass, dt_util.utcnow() + SCAN_INTERVAL) await hass.async_block_till_done() @@ -286,7 +299,8 @@ async def test_single_segment_behavior( # Test segment is off when master is off device.state.on = False with patch( - "homeassistant.components.wled.WLED.update", return_value=device, + "homeassistant.components.wled.WLED.update", + return_value=device, ): async_fire_time_changed(hass, dt_util.utcnow() + SCAN_INTERVAL) await hass.async_block_till_done() @@ -304,7 +318,8 @@ async def test_single_segment_behavior( ) await hass.async_block_till_done() master_mock.assert_called_once_with( - on=False, transition=50, + on=False, + transition=50, ) # Test master is turned on when turning on a single segment, and segment @@ -389,7 +404,9 @@ async def test_rgbw_light( ) await hass.async_block_till_done() light_mock.assert_called_once_with( - on=True, segment_id=0, color_primary=(255, 159, 70, 139), + on=True, + segment_id=0, + color_primary=(255, 159, 70, 139), ) with patch("wled.WLED.segment") as light_mock: @@ -401,7 +418,9 @@ async def test_rgbw_light( ) await hass.async_block_till_done() light_mock.assert_called_once_with( - color_primary=(255, 0, 0, 100), on=True, segment_id=0, + color_primary=(255, 0, 0, 100), + on=True, + segment_id=0, ) with patch("wled.WLED.segment") as light_mock: @@ -417,7 +436,9 @@ async def test_rgbw_light( ) await hass.async_block_till_done() light_mock.assert_called_once_with( - color_primary=(0, 0, 0, 100), on=True, segment_id=0, + color_primary=(0, 0, 0, 100), + on=True, + segment_id=0, ) @@ -442,7 +463,11 @@ async def test_effect_service( ) await hass.async_block_till_done() light_mock.assert_called_once_with( - effect="Rainbow", intensity=200, reverse=True, segment_id=0, speed=100, + effect="Rainbow", + intensity=200, + reverse=True, + segment_id=0, + speed=100, ) with patch("wled.WLED.segment") as light_mock: @@ -454,7 +479,8 @@ async def test_effect_service( ) await hass.async_block_till_done() light_mock.assert_called_once_with( - segment_id=0, effect=9, + segment_id=0, + effect=9, ) with patch("wled.WLED.segment") as light_mock: @@ -471,7 +497,10 @@ async def test_effect_service( ) await hass.async_block_till_done() light_mock.assert_called_once_with( - intensity=200, reverse=True, segment_id=0, speed=100, + intensity=200, + reverse=True, + segment_id=0, + speed=100, ) with patch("wled.WLED.segment") as light_mock: @@ -488,7 +517,10 @@ async def test_effect_service( ) await hass.async_block_till_done() light_mock.assert_called_once_with( - effect="Rainbow", reverse=True, segment_id=0, speed=100, + effect="Rainbow", + reverse=True, + segment_id=0, + speed=100, ) with patch("wled.WLED.segment") as light_mock: @@ -505,7 +537,10 @@ async def test_effect_service( ) await hass.async_block_till_done() light_mock.assert_called_once_with( - effect="Rainbow", intensity=200, segment_id=0, speed=100, + effect="Rainbow", + intensity=200, + segment_id=0, + speed=100, ) with patch("wled.WLED.segment") as light_mock: @@ -522,7 +557,10 @@ async def test_effect_service( ) await hass.async_block_till_done() light_mock.assert_called_once_with( - effect="Rainbow", intensity=200, reverse=True, segment_id=0, + effect="Rainbow", + intensity=200, + reverse=True, + segment_id=0, ) diff --git a/tests/components/wolflink/test_config_flow.py b/tests/components/wolflink/test_config_flow.py index f2074f482eb..897650b48e8 100644 --- a/tests/components/wolflink/test_config_flow.py +++ b/tests/components/wolflink/test_config_flow.py @@ -66,7 +66,8 @@ async def test_create_entry(hass): ) result_create_entry = await hass.config_entries.flow.async_configure( - result["flow_id"], {"device_name": CONFIG[DEVICE_NAME]}, + result["flow_id"], + {"device_name": CONFIG[DEVICE_NAME]}, ) assert result_create_entry["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY @@ -132,7 +133,8 @@ async def test_already_configured_error(hass): ) result_create_entry = await hass.config_entries.flow.async_configure( - result["flow_id"], {"device_name": CONFIG[DEVICE_NAME]}, + result["flow_id"], + {"device_name": CONFIG[DEVICE_NAME]}, ) assert result_create_entry["type"] == data_entry_flow.RESULT_TYPE_ABORT diff --git a/tests/components/xiaomi_aqara/test_config_flow.py b/tests/components/xiaomi_aqara/test_config_flow.py index 06fda84c934..c84758f8b63 100644 --- a/tests/components/xiaomi_aqara/test_config_flow.py +++ b/tests/components/xiaomi_aqara/test_config_flow.py @@ -88,7 +88,8 @@ async def test_config_flow_user_success(hass): assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( - result["flow_id"], {const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE}, + result["flow_id"], + {const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE}, ) assert result["type"] == "form" @@ -96,7 +97,8 @@ async def test_config_flow_user_success(hass): assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( - result["flow_id"], {const.CONF_KEY: TEST_KEY, CONF_NAME: TEST_NAME}, + result["flow_id"], + {const.CONF_KEY: TEST_KEY, CONF_NAME: TEST_NAME}, ) assert result["type"] == "create_entry" @@ -129,7 +131,8 @@ async def test_config_flow_user_multiple_success(hass): return_value=mock_gateway_discovery, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE}, + result["flow_id"], + {const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE}, ) assert result["type"] == "form" @@ -137,7 +140,8 @@ async def test_config_flow_user_multiple_success(hass): assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"select_ip": TEST_HOST_2}, + result["flow_id"], + {"select_ip": TEST_HOST_2}, ) assert result["type"] == "form" @@ -145,7 +149,8 @@ async def test_config_flow_user_multiple_success(hass): assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( - result["flow_id"], {const.CONF_KEY: TEST_KEY, CONF_NAME: TEST_NAME}, + result["flow_id"], + {const.CONF_KEY: TEST_KEY, CONF_NAME: TEST_NAME}, ) assert result["type"] == "create_entry" @@ -172,7 +177,8 @@ async def test_config_flow_user_no_key_success(hass): assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( - result["flow_id"], {const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE}, + result["flow_id"], + {const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE}, ) assert result["type"] == "form" @@ -180,7 +186,8 @@ async def test_config_flow_user_no_key_success(hass): assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_NAME: TEST_NAME}, + result["flow_id"], + {CONF_NAME: TEST_NAME}, ) assert result["type"] == "create_entry" @@ -226,7 +233,8 @@ async def test_config_flow_user_host_mac_success(hass): assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_NAME: TEST_NAME}, + result["flow_id"], + {CONF_NAME: TEST_NAME}, ) assert result["type"] == "create_entry" @@ -259,7 +267,8 @@ async def test_config_flow_user_discovery_error(hass): return_value=mock_gateway_discovery, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE}, + result["flow_id"], + {const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE}, ) assert result["type"] == "form" @@ -284,7 +293,8 @@ async def test_config_flow_user_invalid_interface(hass): return_value=mock_gateway_discovery, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE}, + result["flow_id"], + {const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE}, ) assert result["type"] == "form" @@ -369,7 +379,8 @@ async def test_config_flow_user_invalid_key(hass): return_value=mock_gateway_discovery, ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE}, + result["flow_id"], + {const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE}, ) assert result["type"] == "form" @@ -377,7 +388,8 @@ async def test_config_flow_user_invalid_key(hass): assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( - result["flow_id"], {const.CONF_KEY: TEST_KEY, CONF_NAME: TEST_NAME}, + result["flow_id"], + {const.CONF_KEY: TEST_KEY, CONF_NAME: TEST_NAME}, ) assert result["type"] == "form" @@ -402,7 +414,8 @@ async def test_zeroconf_success(hass): assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( - result["flow_id"], {const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE}, + result["flow_id"], + {const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE}, ) assert result["type"] == "form" @@ -410,7 +423,8 @@ async def test_zeroconf_success(hass): assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( - result["flow_id"], {const.CONF_KEY: TEST_KEY, CONF_NAME: TEST_NAME}, + result["flow_id"], + {const.CONF_KEY: TEST_KEY, CONF_NAME: TEST_NAME}, ) assert result["type"] == "create_entry" diff --git a/tests/components/xiaomi_miio/test_config_flow.py b/tests/components/xiaomi_miio/test_config_flow.py index 01ae690bc25..d620e739e18 100644 --- a/tests/components/xiaomi_miio/test_config_flow.py +++ b/tests/components/xiaomi_miio/test_config_flow.py @@ -50,7 +50,10 @@ async def test_config_flow_step_user_no_device(hass): assert result["step_id"] == "user" assert result["errors"] == {} - result = await hass.config_entries.flow.async_configure(result["flow_id"], {},) + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) assert result["type"] == "form" assert result["step_id"] == "user" @@ -68,7 +71,8 @@ async def test_config_flow_step_gateway_connect_error(hass): assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( - result["flow_id"], {config_flow.CONF_GATEWAY: True}, + result["flow_id"], + {config_flow.CONF_GATEWAY: True}, ) assert result["type"] == "form" @@ -100,7 +104,8 @@ async def test_config_flow_gateway_success(hass): assert result["errors"] == {} result = await hass.config_entries.flow.async_configure( - result["flow_id"], {config_flow.CONF_GATEWAY: True}, + result["flow_id"], + {config_flow.CONF_GATEWAY: True}, ) assert result["type"] == "form" @@ -162,7 +167,8 @@ async def test_zeroconf_gateway_success(hass): "homeassistant.components.xiaomi_miio.async_setup_entry", return_value=True ): result = await hass.config_entries.flow.async_configure( - result["flow_id"], {CONF_NAME: TEST_NAME, CONF_TOKEN: TEST_TOKEN}, + result["flow_id"], + {CONF_NAME: TEST_NAME, CONF_TOKEN: TEST_TOKEN}, ) assert result["type"] == "create_entry" diff --git a/tests/components/zeroconf/test_usage.py b/tests/components/zeroconf/test_usage.py index 0a2095daa6a..e45a93a38b3 100644 --- a/tests/components/zeroconf/test_usage.py +++ b/tests/components/zeroconf/test_usage.py @@ -46,7 +46,11 @@ async def test_multiple_zeroconf_instances_gives_shared(hass, mock_zeroconf, cap lineno="23", line="self.light.is_on", ), - Mock(filename="/home/dev/mdns/lights.py", lineno="2", line="something()",), + Mock( + filename="/home/dev/mdns/lights.py", + lineno="2", + line="something()", + ), ], ): assert zeroconf.Zeroconf() == zeroconf_instance diff --git a/tests/components/zerproc/test_config_flow.py b/tests/components/zerproc/test_config_flow.py index 4e9c380910e..9ffafca76db 100644 --- a/tests/components/zerproc/test_config_flow.py +++ b/tests/components/zerproc/test_config_flow.py @@ -22,9 +22,13 @@ async def test_flow_success(hass): ), patch( "homeassistant.components.zerproc.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.zerproc.async_setup_entry", return_value=True, + "homeassistant.components.zerproc.async_setup_entry", + return_value=True, ) as mock_setup_entry: - result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {},) + result2 = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) assert result2["type"] == "create_entry" assert result2["title"] == "Zerproc" @@ -50,9 +54,13 @@ async def test_flow_no_devices_found(hass): ), patch( "homeassistant.components.zerproc.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.zerproc.async_setup_entry", return_value=True, + "homeassistant.components.zerproc.async_setup_entry", + return_value=True, ) as mock_setup_entry: - result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {},) + result2 = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) assert result2["type"] == "abort" assert result2["reason"] == "no_devices_found" @@ -76,9 +84,13 @@ async def test_flow_exceptions_caught(hass): ), patch( "homeassistant.components.zerproc.async_setup", return_value=True ) as mock_setup, patch( - "homeassistant.components.zerproc.async_setup_entry", return_value=True, + "homeassistant.components.zerproc.async_setup_entry", + return_value=True, ) as mock_setup_entry: - result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {},) + result2 = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) assert result2["type"] == "abort" assert result2["reason"] == "no_devices_found" diff --git a/tests/components/zha/test_climate.py b/tests/components/zha/test_climate.py index 8ca949cd44e..fe69e6536d3 100644 --- a/tests/components/zha/test_climate.py +++ b/tests/components/zha/test_climate.py @@ -466,7 +466,11 @@ async def test_target_temperature( @pytest.mark.parametrize( "preset, unoccupied, target_temp", - ((None, 1800, 17), (PRESET_AWAY, 1800, 18), (PRESET_AWAY, None, None),), + ( + (None, 1800, 17), + (PRESET_AWAY, 1800, 18), + (PRESET_AWAY, None, None), + ), ) async def test_target_temperature_high( hass, device_climate_mock, preset, unoccupied, target_temp @@ -502,7 +506,11 @@ async def test_target_temperature_high( @pytest.mark.parametrize( "preset, unoccupied, target_temp", - ((None, 1600, 21), (PRESET_AWAY, 1600, 16), (PRESET_AWAY, None, None),), + ( + (None, 1600, 21), + (PRESET_AWAY, 1600, 16), + (PRESET_AWAY, None, None), + ), ) async def test_target_temperature_low( hass, device_climate_mock, preset, unoccupied, target_temp diff --git a/tests/components/zha/test_config_flow.py b/tests/components/zha/test_config_flow.py index 9894360da46..709b9a0ff22 100644 --- a/tests/components/zha/test_config_flow.py +++ b/tests/components/zha/test_config_flow.py @@ -53,7 +53,8 @@ async def test_user_flow(detect_mock, hass): @patch("serial.tools.list_ports.comports", MagicMock(return_value=[com_port()])) @patch( - "homeassistant.components.zha.config_flow.detect_radios", return_value=None, + "homeassistant.components.zha.config_flow.detect_radios", + return_value=None, ) async def test_user_flow_not_detected(detect_mock, hass): """Test user flow, radio not detected.""" @@ -76,7 +77,8 @@ async def test_user_flow_not_detected(detect_mock, hass): async def test_user_flow_show_form(hass): """Test user step form.""" result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_USER}, + DOMAIN, + context={CONF_SOURCE: SOURCE_USER}, ) assert result["type"] == RESULT_TYPE_FORM @@ -163,7 +165,8 @@ async def test_user_port_config_fail(probe_mock, hass): ) result = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input={zigpy.config.CONF_DEVICE_PATH: "/dev/ttyUSB33"}, + result["flow_id"], + user_input={zigpy.config.CONF_DEVICE_PATH: "/dev/ttyUSB33"}, ) assert result["type"] == RESULT_TYPE_FORM assert result["step_id"] == "port_config" @@ -184,7 +187,8 @@ async def test_user_port_config(probe_mock, hass): ) result = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input={zigpy.config.CONF_DEVICE_PATH: "/dev/ttyUSB33"}, + result["flow_id"], + user_input={zigpy.config.CONF_DEVICE_PATH: "/dev/ttyUSB33"}, ) assert result["type"] == "create_entry" diff --git a/tests/components/zha/test_cover.py b/tests/components/zha/test_cover.py index d32eac130b0..c6c0e74050d 100644 --- a/tests/components/zha/test_cover.py +++ b/tests/components/zha/test_cover.py @@ -314,7 +314,10 @@ async def test_shade(hass, zha_device_joined_restored, zigpy_shade_device): # test cover stop with patch("zigpy.zcl.Cluster.request", side_effect=asyncio.TimeoutError): await hass.services.async_call( - DOMAIN, SERVICE_STOP_COVER, {"entity_id": entity_id}, blocking=True, + DOMAIN, + SERVICE_STOP_COVER, + {"entity_id": entity_id}, + blocking=True, ) assert cluster_level.request.call_count == 1 assert cluster_level.request.call_args[0][0] is False diff --git a/tests/components/zha/test_device.py b/tests/components/zha/test_device.py index a408f655ea3..83a57f1fabf 100644 --- a/tests/components/zha/test_device.py +++ b/tests/components/zha/test_device.py @@ -235,12 +235,32 @@ async def test_ota_sw_version(hass, ota_zha_device): "device, last_seen_delta, is_available", ( ("zigpy_device", 0, True), - ("zigpy_device", zha_core_device.CONSIDER_UNAVAILABLE_MAINS + 2, True,), - ("zigpy_device", zha_core_device.CONSIDER_UNAVAILABLE_BATTERY - 2, True,), - ("zigpy_device", zha_core_device.CONSIDER_UNAVAILABLE_BATTERY + 2, False,), + ( + "zigpy_device", + zha_core_device.CONSIDER_UNAVAILABLE_MAINS + 2, + True, + ), + ( + "zigpy_device", + zha_core_device.CONSIDER_UNAVAILABLE_BATTERY - 2, + True, + ), + ( + "zigpy_device", + zha_core_device.CONSIDER_UNAVAILABLE_BATTERY + 2, + False, + ), ("zigpy_device_mains", 0, True), - ("zigpy_device_mains", zha_core_device.CONSIDER_UNAVAILABLE_MAINS - 2, True,), - ("zigpy_device_mains", zha_core_device.CONSIDER_UNAVAILABLE_MAINS + 2, False,), + ( + "zigpy_device_mains", + zha_core_device.CONSIDER_UNAVAILABLE_MAINS - 2, + True, + ), + ( + "zigpy_device_mains", + zha_core_device.CONSIDER_UNAVAILABLE_MAINS + 2, + False, + ), ( "zigpy_device_mains", zha_core_device.CONSIDER_UNAVAILABLE_BATTERY - 2, diff --git a/tests/components/zha/test_discover.py b/tests/components/zha/test_discover.py index 9fd01f1de8d..0cd8c58e49f 100644 --- a/tests/components/zha/test_discover.py +++ b/tests/components/zha/test_discover.py @@ -61,7 +61,10 @@ def channels_mock(zha_device_mock): ) @pytest.mark.parametrize("device", DEVICES) async def test_devices( - device, hass_disable_services, zigpy_device_mock, zha_device_joined_restored, + device, + hass_disable_services, + zigpy_device_mock, + zha_device_joined_restored, ): """Test device discovery.""" entity_registry = await homeassistant.helpers.entity_registry.async_get_registry( diff --git a/tests/components/zha/test_sensor.py b/tests/components/zha/test_sensor.py index 25fecd2d82c..89d3d270322 100644 --- a/tests/components/zha/test_sensor.py +++ b/tests/components/zha/test_sensor.py @@ -268,7 +268,9 @@ async def test_temp_uom( async def test_electrical_measurement_init( - hass, zigpy_device_mock, zha_device_joined, + hass, + zigpy_device_mock, + zha_device_joined, ): """Test proper initialization of the electrical measurement cluster.""" diff --git a/tests/components/zwave/test_init.py b/tests/components/zwave/test_init.py index 12b2c59ca81..4cf639e7faf 100644 --- a/tests/components/zwave/test_init.py +++ b/tests/components/zwave/test_init.py @@ -1762,12 +1762,15 @@ class TestZWaveServices(unittest.TestCase): assert node.refresh_value.called assert len(node.refresh_value.mock_calls) == 2 - assert sorted( - [ - node.refresh_value.mock_calls[0][1][0], - node.refresh_value.mock_calls[1][1][0], - ] - ) == sorted([value.value_id, power_value.value_id]) + assert ( + sorted( + [ + node.refresh_value.mock_calls[0][1][0], + node.refresh_value.mock_calls[1][1][0], + ] + ) + == sorted([value.value_id, power_value.value_id]) + ) def test_refresh_node(self): """Test zwave refresh_node service.""" diff --git a/tests/helpers/test_condition.py b/tests/helpers/test_condition.py index 0ce1b786d54..4b02faec573 100644 --- a/tests/helpers/test_condition.py +++ b/tests/helpers/test_condition.py @@ -600,50 +600,53 @@ async def test_extract_entities(): async def test_extract_devices(): """Test extracting devices.""" - assert condition.async_extract_devices( - { - "condition": "and", - "conditions": [ - {"condition": "device", "device_id": "abcd", "domain": "light"}, - {"condition": "device", "device_id": "qwer", "domain": "switch"}, - { - "condition": "state", - "entity_id": "sensor.not_a_device", - "state": "100", - }, - { - "condition": "not", - "conditions": [ - { - "condition": "device", - "device_id": "abcd_not", - "domain": "light", - }, - { - "condition": "device", - "device_id": "qwer_not", - "domain": "switch", - }, - ], - }, - { - "condition": "or", - "conditions": [ - { - "condition": "device", - "device_id": "abcd_or", - "domain": "light", - }, - { - "condition": "device", - "device_id": "qwer_or", - "domain": "switch", - }, - ], - }, - ], - } - ) == {"abcd", "qwer", "abcd_not", "qwer_not", "abcd_or", "qwer_or"} + assert ( + condition.async_extract_devices( + { + "condition": "and", + "conditions": [ + {"condition": "device", "device_id": "abcd", "domain": "light"}, + {"condition": "device", "device_id": "qwer", "domain": "switch"}, + { + "condition": "state", + "entity_id": "sensor.not_a_device", + "state": "100", + }, + { + "condition": "not", + "conditions": [ + { + "condition": "device", + "device_id": "abcd_not", + "domain": "light", + }, + { + "condition": "device", + "device_id": "qwer_not", + "domain": "switch", + }, + ], + }, + { + "condition": "or", + "conditions": [ + { + "condition": "device", + "device_id": "abcd_or", + "domain": "light", + }, + { + "condition": "device", + "device_id": "qwer_or", + "domain": "switch", + }, + ], + }, + ], + } + ) + == {"abcd", "qwer", "abcd_not", "qwer_not", "abcd_or", "qwer_or"} + ) async def test_condition_template_error(hass, caplog): diff --git a/tests/helpers/test_config_entry_flow.py b/tests/helpers/test_config_entry_flow.py index 7893650d420..adbcca63990 100644 --- a/tests/helpers/test_config_entry_flow.py +++ b/tests/helpers/test_config_entry_flow.py @@ -259,7 +259,8 @@ async def test_webhook_config_flow_registers_webhook(hass, webhook_flow_conf): flow.hass = hass await async_process_ha_core_config( - hass, {"external_url": "https://example.com"}, + hass, + {"external_url": "https://example.com"}, ) result = await flow.async_step_user(user_input={}) diff --git a/tests/helpers/test_config_entry_oauth2_flow.py b/tests/helpers/test_config_entry_oauth2_flow.py index 37b8ea5b3fd..227f3e366f3 100644 --- a/tests/helpers/test_config_entry_oauth2_flow.py +++ b/tests/helpers/test_config_entry_oauth2_flow.py @@ -131,7 +131,8 @@ async def test_abort_if_authorization_timeout(hass, flow_handler, local_impl): async def test_step_discovery(hass, flow_handler, local_impl): """Check flow triggers from discovery.""" await async_process_ha_core_config( - hass, {"external_url": "https://example.com"}, + hass, + {"external_url": "https://example.com"}, ) flow_handler.async_register_implementation(hass, local_impl) config_entry_oauth2_flow.async_register_implementation( @@ -149,7 +150,8 @@ async def test_step_discovery(hass, flow_handler, local_impl): async def test_abort_discovered_multiple(hass, flow_handler, local_impl): """Test if aborts when discovered multiple times.""" await async_process_ha_core_config( - hass, {"external_url": "https://example.com"}, + hass, + {"external_url": "https://example.com"}, ) flow_handler.async_register_implementation(hass, local_impl) @@ -175,14 +177,18 @@ async def test_abort_discovered_multiple(hass, flow_handler, local_impl): async def test_abort_discovered_existing_entries(hass, flow_handler, local_impl): """Test if abort discovery when entries exists.""" await async_process_ha_core_config( - hass, {"external_url": "https://example.com"}, + hass, + {"external_url": "https://example.com"}, ) flow_handler.async_register_implementation(hass, local_impl) config_entry_oauth2_flow.async_register_implementation( hass, TEST_DOMAIN, MockOAuth2Implementation() ) - entry = MockConfigEntry(domain=TEST_DOMAIN, data={},) + entry = MockConfigEntry( + domain=TEST_DOMAIN, + data={}, + ) entry.add_to_hass(hass) result = await hass.config_entries.flow.async_init( @@ -198,7 +204,8 @@ async def test_full_flow( ): """Check full flow.""" await async_process_ha_core_config( - hass, {"external_url": "https://example.com"}, + hass, + {"external_url": "https://example.com"}, ) flow_handler.async_register_implementation(hass, local_impl) diff --git a/tests/helpers/test_entity_component.py b/tests/helpers/test_entity_component.py index 05361fe2006..0373705186f 100644 --- a/tests/helpers/test_entity_component.py +++ b/tests/helpers/test_entity_component.py @@ -80,7 +80,9 @@ async def test_setup_recovers_when_setup_raises(hass): assert platform2_setup.called -@patch("homeassistant.helpers.entity_component.EntityComponent.async_setup_platform",) +@patch( + "homeassistant.helpers.entity_component.EntityComponent.async_setup_platform", +) @patch("homeassistant.setup.async_setup_component", return_value=True) async def test_setup_does_discovery(mock_setup_component, mock_setup, hass): """Test setup for discovery.""" diff --git a/tests/helpers/test_entity_registry.py b/tests/helpers/test_entity_registry.py index 97d8af7d0ee..8f5f8fc501b 100644 --- a/tests/helpers/test_entity_registry.py +++ b/tests/helpers/test_entity_registry.py @@ -526,7 +526,10 @@ async def test_restore_states(hass): registry = await entity_registry.async_get_registry(hass) registry.async_get_or_create( - "light", "hue", "1234", suggested_object_id="simple", + "light", + "hue", + "1234", + suggested_object_id="simple", ) # Should not be created registry.async_get_or_create( diff --git a/tests/helpers/test_frame.py b/tests/helpers/test_frame.py index 9f68ecdefb2..6daae51403c 100644 --- a/tests/helpers/test_frame.py +++ b/tests/helpers/test_frame.py @@ -57,7 +57,11 @@ async def test_extract_frame_integration_with_excluded_intergration(caplog): lineno="23", line="self.light.is_on", ), - Mock(filename="/home/dev/mdns/lights.py", lineno="2", line="something()",), + Mock( + filename="/home/dev/mdns/lights.py", + lineno="2", + line="something()", + ), ], ): found_frame, integration, path = frame.get_integration_frame( diff --git a/tests/helpers/test_location.py b/tests/helpers/test_location.py index 2f99d42616f..219d015bdf7 100644 --- a/tests/helpers/test_location.py +++ b/tests/helpers/test_location.py @@ -62,7 +62,9 @@ async def test_coordinates_function_as_state(hass): async def test_coordinates_function_device_tracker_in_zone(hass): """Test coordinates function.""" hass.states.async_set( - "zone.home", "zoning", {"latitude": 32.87336, "longitude": -117.22943}, + "zone.home", + "zoning", + {"latitude": 32.87336, "longitude": -117.22943}, ) hass.states.async_set("device_tracker.device", "home") assert ( @@ -87,7 +89,8 @@ async def test_coordinates_function_device_tracker_from_input_select(hass): def test_coordinates_function_returns_none_on_recursion(hass): """Test coordinates function.""" hass.states.async_set( - "test.first", "test.second", + "test.first", + "test.second", ) hass.states.async_set("test.second", "test.first") assert location.find_coordinates(hass, "test.first") is None @@ -96,7 +99,8 @@ def test_coordinates_function_returns_none_on_recursion(hass): async def test_coordinates_function_returns_none_if_invalid_coord(hass): """Test test_coordinates function.""" hass.states.async_set( - "test.object", "abc", + "test.object", + "abc", ) assert location.find_coordinates(hass, "test.object") is None diff --git a/tests/helpers/test_network.py b/tests/helpers/test_network.py index 1754511d95c..f51ee2090dc 100644 --- a/tests/helpers/test_network.py +++ b/tests/helpers/test_network.py @@ -26,7 +26,8 @@ async def test_get_url_internal(hass: HomeAssistant): # Test with internal URL: http://example.local:8123 await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:8123"}, + hass, + {"internal_url": "http://example.local:8123"}, ) assert hass.config.internal_url == "http://example.local:8123" @@ -66,7 +67,8 @@ async def test_get_url_internal(hass: HomeAssistant): # Test with internal URL: https://example.local:8123 await async_process_ha_core_config( - hass, {"internal_url": "https://example.local:8123"}, + hass, + {"internal_url": "https://example.local:8123"}, ) assert hass.config.internal_url == "https://example.local:8123" @@ -79,7 +81,8 @@ async def test_get_url_internal(hass: HomeAssistant): # Test with internal URL: http://example.local:80/ await async_process_ha_core_config( - hass, {"internal_url": "http://example.local:80/"}, + hass, + {"internal_url": "http://example.local:80/"}, ) assert hass.config.internal_url == "http://example.local:80/" @@ -92,7 +95,8 @@ async def test_get_url_internal(hass: HomeAssistant): # Test with internal URL: https://example.local:443 await async_process_ha_core_config( - hass, {"internal_url": "https://example.local:443"}, + hass, + {"internal_url": "https://example.local:443"}, ) assert hass.config.internal_url == "https://example.local:443" @@ -105,7 +109,8 @@ async def test_get_url_internal(hass: HomeAssistant): # Test with internal URL: https://192.168.0.1 await async_process_ha_core_config( - hass, {"internal_url": "https://192.168.0.1"}, + hass, + {"internal_url": "https://192.168.0.1"}, ) assert hass.config.internal_url == "https://192.168.0.1" @@ -118,7 +123,8 @@ async def test_get_url_internal(hass: HomeAssistant): # Test with internal URL: http://192.168.0.1:8123 await async_process_ha_core_config( - hass, {"internal_url": "http://192.168.0.1:8123"}, + hass, + {"internal_url": "http://192.168.0.1:8123"}, ) assert hass.config.internal_url == "http://192.168.0.1:8123" @@ -224,7 +230,8 @@ async def test_get_url_external(hass: HomeAssistant): # Test with external URL: http://example.com:8123 await async_process_ha_core_config( - hass, {"external_url": "http://example.com:8123"}, + hass, + {"external_url": "http://example.com:8123"}, ) assert hass.config.external_url == "http://example.com:8123" @@ -266,7 +273,8 @@ async def test_get_url_external(hass: HomeAssistant): # Test with external URL: http://example.com:80/ await async_process_ha_core_config( - hass, {"external_url": "http://example.com:80/"}, + hass, + {"external_url": "http://example.com:80/"}, ) assert hass.config.external_url == "http://example.com:80/" @@ -281,7 +289,8 @@ async def test_get_url_external(hass: HomeAssistant): # Test with external url: https://example.com:443/ await async_process_ha_core_config( - hass, {"external_url": "https://example.com:443/"}, + hass, + {"external_url": "https://example.com:443/"}, ) assert hass.config.external_url == "https://example.com:443/" assert _get_external_url(hass) == "https://example.com" @@ -293,7 +302,8 @@ async def test_get_url_external(hass: HomeAssistant): # Test with external URL: https://example.com:80 await async_process_ha_core_config( - hass, {"external_url": "https://example.com:80"}, + hass, + {"external_url": "https://example.com:80"}, ) assert hass.config.external_url == "https://example.com:80" assert _get_external_url(hass) == "https://example.com:80" @@ -307,7 +317,8 @@ async def test_get_url_external(hass: HomeAssistant): # Test with external URL: https://192.168.0.1 await async_process_ha_core_config( - hass, {"external_url": "https://192.168.0.1"}, + hass, + {"external_url": "https://192.168.0.1"}, ) assert hass.config.external_url == "https://192.168.0.1" assert _get_external_url(hass) == "https://192.168.0.1" @@ -381,7 +392,8 @@ async def test_get_external_url_cloud_fallback(hass: HomeAssistant): # Test with external URL: http://1.1.1.1:8123 await async_process_ha_core_config( - hass, {"external_url": "http://1.1.1.1:8123"}, + hass, + {"external_url": "http://1.1.1.1:8123"}, ) assert hass.config.external_url == "http://1.1.1.1:8123" @@ -406,7 +418,8 @@ async def test_get_external_url_cloud_fallback(hass: HomeAssistant): # Test with external URL: https://example.com await async_process_ha_core_config( - hass, {"external_url": "https://example.com"}, + hass, + {"external_url": "https://example.com"}, ) assert hass.config.external_url == "https://example.com" @@ -453,7 +466,8 @@ async def test_get_url(hass: HomeAssistant): # Test only external hass.config.api = None await async_process_ha_core_config( - hass, {"external_url": "https://example.com"}, + hass, + {"external_url": "https://example.com"}, ) assert hass.config.external_url == "https://example.com" assert hass.config.internal_url is None @@ -703,7 +717,8 @@ async def test_get_internal_url_with_base_url_fallback(hass: HomeAssistant): # Add internal URL await async_process_ha_core_config( - hass, {"internal_url": "https://internal.local"}, + hass, + {"internal_url": "https://internal.local"}, ) assert _get_internal_url(hass) == "https://internal.local" assert _get_internal_url(hass, allow_ip=False) == "https://internal.local" @@ -714,7 +729,8 @@ async def test_get_internal_url_with_base_url_fallback(hass: HomeAssistant): # Add internal URL, mixed results await async_process_ha_core_config( - hass, {"internal_url": "http://internal.local:8123"}, + hass, + {"internal_url": "http://internal.local:8123"}, ) assert _get_internal_url(hass) == "http://internal.local:8123" assert _get_internal_url(hass, allow_ip=False) == "http://internal.local:8123" @@ -725,7 +741,8 @@ async def test_get_internal_url_with_base_url_fallback(hass: HomeAssistant): # Add internal URL set to an IP await async_process_ha_core_config( - hass, {"internal_url": "http://10.10.10.10:8123"}, + hass, + {"internal_url": "http://10.10.10.10:8123"}, ) assert _get_internal_url(hass) == "http://10.10.10.10:8123" assert _get_internal_url(hass, allow_ip=False) == "https://example.local" @@ -752,7 +769,8 @@ async def test_get_external_url_with_base_url_fallback(hass: HomeAssistant): # Add external URL await async_process_ha_core_config( - hass, {"external_url": "https://external.example.com"}, + hass, + {"external_url": "https://external.example.com"}, ) assert _get_external_url(hass) == "https://external.example.com" assert _get_external_url(hass, allow_ip=False) == "https://external.example.com" @@ -764,7 +782,8 @@ async def test_get_external_url_with_base_url_fallback(hass: HomeAssistant): # Add external URL, mixed results await async_process_ha_core_config( - hass, {"external_url": "http://external.example.com:8123"}, + hass, + {"external_url": "http://external.example.com:8123"}, ) assert _get_external_url(hass) == "http://external.example.com:8123" assert _get_external_url(hass, allow_ip=False) == "http://external.example.com:8123" @@ -773,7 +792,8 @@ async def test_get_external_url_with_base_url_fallback(hass: HomeAssistant): # Add external URL set to an IP await async_process_ha_core_config( - hass, {"external_url": "http://1.1.1.1:8123"}, + hass, + {"external_url": "http://1.1.1.1:8123"}, ) assert _get_external_url(hass) == "http://1.1.1.1:8123" assert _get_external_url(hass, allow_ip=False) == "https://example.com" diff --git a/tests/helpers/test_reload.py b/tests/helpers/test_reload.py index c1062a488ee..255d3cde40a 100644 --- a/tests/helpers/test_reload.py +++ b/tests/helpers/test_reload.py @@ -53,7 +53,9 @@ async def test_reload_platform(hass): assert platform.domain == DOMAIN yaml_path = path.join( - _get_fixtures_base_path(), "fixtures", "helpers/reload_configuration.yaml", + _get_fixtures_base_path(), + "fixtures", + "helpers/reload_configuration.yaml", ) with patch.object(config, "YAML_CONFIG_FILE", yaml_path): await async_reload_integration_platforms(hass, PLATFORM, [DOMAIN]) @@ -88,11 +90,16 @@ async def test_setup_reload_service(hass): await async_setup_reload_service(hass, PLATFORM, [DOMAIN]) yaml_path = path.join( - _get_fixtures_base_path(), "fixtures", "helpers/reload_configuration.yaml", + _get_fixtures_base_path(), + "fixtures", + "helpers/reload_configuration.yaml", ) with patch.object(config, "YAML_CONFIG_FILE", yaml_path): await hass.services.async_call( - PLATFORM, SERVICE_RELOAD, {}, blocking=True, + PLATFORM, + SERVICE_RELOAD, + {}, + blocking=True, ) await hass.async_block_till_done() diff --git a/tests/helpers/test_service.py b/tests/helpers/test_service.py index e3736aadceb..1a0cdb79bbc 100644 --- a/tests/helpers/test_service.py +++ b/tests/helpers/test_service.py @@ -44,7 +44,8 @@ SUPPORT_C = 4 def mock_handle_entity_call(): """Mock service platform call.""" with patch( - "homeassistant.helpers.service._handle_entity_call", return_value=None, + "homeassistant.helpers.service._handle_entity_call", + return_value=None, ) as mock_call: yield mock_call @@ -701,7 +702,9 @@ async def test_domain_control_unauthorized(hass, hass_read_only_user): hass, { "light.kitchen": ent_reg.RegistryEntry( - entity_id="light.kitchen", unique_id="kitchen", platform="test_domain", + entity_id="light.kitchen", + unique_id="kitchen", + platform="test_domain", ) }, ) @@ -738,7 +741,9 @@ async def test_domain_control_admin(hass, hass_admin_user): hass, { "light.kitchen": ent_reg.RegistryEntry( - entity_id="light.kitchen", unique_id="kitchen", platform="test_domain", + entity_id="light.kitchen", + unique_id="kitchen", + platform="test_domain", ) }, ) @@ -774,7 +779,9 @@ async def test_domain_control_no_user(hass): hass, { "light.kitchen": ent_reg.RegistryEntry( - entity_id="light.kitchen", unique_id="kitchen", platform="test_domain", + entity_id="light.kitchen", + unique_id="kitchen", + platform="test_domain", ) }, ) @@ -835,7 +842,11 @@ async def test_extract_from_service_available_device(hass): await service.async_extract_entities( hass, entities, - ha.ServiceCall("test", "service", data={"entity_id": ENTITY_MATCH_NONE},), + ha.ServiceCall( + "test", + "service", + data={"entity_id": ENTITY_MATCH_NONE}, + ), ) == [] ) diff --git a/tests/helpers/test_state.py b/tests/helpers/test_state.py index b19669d13f4..626f8a83744 100644 --- a/tests/helpers/test_state.py +++ b/tests/helpers/test_state.py @@ -68,7 +68,9 @@ async def test_call_to_component(hass): context = "dummy_context" await state.async_reproduce_state( - hass, [state_media_player, state_climate], context=context, + hass, + [state_media_player, state_climate], + context=context, ) media_player_fun.assert_called_once_with( diff --git a/tests/helpers/test_template.py b/tests/helpers/test_template.py index 9d8b763c275..3b293c106f9 100644 --- a/tests/helpers/test_template.py +++ b/tests/helpers/test_template.py @@ -872,7 +872,10 @@ def test_relative_time(mock_is_safe, hass): ) assert ( "string" - == template.Template('{{relative_time("string")}}', hass,).async_render() + == template.Template( + '{{relative_time("string")}}', + hass, + ).async_render() ) @@ -2076,13 +2079,16 @@ def test_extract_entities_domain_states_inner(hass, allow_extract_entities): hass.states.async_set("light.switch2", "on") hass.states.async_set("light.switch3", "off") - assert set( - template.extract_entities( - hass, - "{{ states['light'] | selectattr('state','eq','on') | list | count > 0 }}", - {}, + assert ( + set( + template.extract_entities( + hass, + "{{ states['light'] | selectattr('state','eq','on') | list | count > 0 }}", + {}, + ) ) - ) == {"light.switch", "light.switch2", "light.switch3"} + == {"light.switch", "light.switch2", "light.switch3"} + ) def test_extract_entities_domain_states_outer(hass, allow_extract_entities): @@ -2091,13 +2097,16 @@ def test_extract_entities_domain_states_outer(hass, allow_extract_entities): hass.states.async_set("light.switch2", "on") hass.states.async_set("light.switch3", "off") - assert set( - template.extract_entities( - hass, - "{{ states.light | selectattr('state','eq','off') | list | count > 0 }}", - {}, + assert ( + set( + template.extract_entities( + hass, + "{{ states.light | selectattr('state','eq','off') | list | count > 0 }}", + {}, + ) ) - ) == {"light.switch", "light.switch2", "light.switch3"} + == {"light.switch", "light.switch2", "light.switch3"} + ) def test_extract_entities_domain_states_outer_with_group(hass, allow_extract_entities): @@ -2108,20 +2117,25 @@ def test_extract_entities_domain_states_outer_with_group(hass, allow_extract_ent hass.states.async_set("switch.pool_light", "off") hass.states.async_set("group.lights", "off", {"entity_id": ["switch.pool_light"]}) - assert set( - template.extract_entities( - hass, - "{{ states.light | selectattr('entity_id', 'in', state_attr('group.lights', 'entity_id')) }}", - {}, + assert ( + set( + template.extract_entities( + hass, + "{{ states.light | selectattr('entity_id', 'in', state_attr('group.lights', 'entity_id')) }}", + {}, + ) ) - ) == {"light.switch", "light.switch2", "light.switch3", "group.lights"} + == {"light.switch", "light.switch2", "light.switch3", "group.lights"} + ) def test_extract_entities_blocked_from_core_code(hass): """Test extract entities is blocked from core code.""" with pytest.raises(RuntimeError): template.extract_entities( - hass, "{{ states.light }}", {}, + hass, + "{{ states.light }}", + {}, ) @@ -2142,11 +2156,17 @@ def test_extract_entities_warns_and_logs_from_an_integration(hass, caplog): line="do_something()", ), correct_frame, - Mock(filename="/home/dev/mdns/lights.py", lineno="2", line="something()",), + Mock( + filename="/home/dev/mdns/lights.py", + lineno="2", + line="something()", + ), ], ): template.extract_entities( - hass, "{{ states.light }}", {}, + hass, + "{{ states.light }}", + {}, ) assert "custom_components/burncpu/light.py" in caplog.text @@ -2219,7 +2239,8 @@ def test_render_complex_handling_non_template_values(hass): def test_urlencode(hass): """Test the urlencode method.""" tpl = template.Template( - ("{% set dict = {'foo': 'x&y', 'bar': 42} %}" "{{ dict | urlencode }}"), hass, + ("{% set dict = {'foo': 'x&y', 'bar': 42} %}" "{{ dict | urlencode }}"), + hass, ) assert tpl.async_render() == "foo=x%26y&bar=42" tpl = template.Template( @@ -2234,13 +2255,17 @@ async def test_cache_garbage_collection(): template_string = ( "{% set dict = {'foo': 'x&y', 'bar': 42} %} {{ dict | urlencode }}" ) - tpl = template.Template((template_string),) + tpl = template.Template( + (template_string), + ) tpl.ensure_valid() assert template._NO_HASS_ENV.template_cache.get( template_string ) # pylint: disable=protected-access - tpl2 = template.Template((template_string),) + tpl2 = template.Template( + (template_string), + ) tpl2.ensure_valid() assert template._NO_HASS_ENV.template_cache.get( template_string diff --git a/tests/ignore_uncaught_exceptions.py b/tests/ignore_uncaught_exceptions.py index 20d32202a1a..e68131d689b 100644 --- a/tests/ignore_uncaught_exceptions.py +++ b/tests/ignore_uncaught_exceptions.py @@ -1,6 +1,9 @@ """List of tests that have uncaught exceptions today. Will be shrunk over time.""" IGNORE_UNCAUGHT_EXCEPTIONS = [ - ("test_homeassistant_bridge", "test_homeassistant_bridge_fan_setup",), + ( + "test_homeassistant_bridge", + "test_homeassistant_bridge_fan_setup", + ), ( "tests.components.owntracks.test_device_tracker", "test_mobile_multiple_async_enter_exit", diff --git a/tests/test_bootstrap.py b/tests/test_bootstrap.py index 03c5ba68e59..59e77dc1388 100644 --- a/tests/test_bootstrap.py +++ b/tests/test_bootstrap.py @@ -172,7 +172,8 @@ async def test_setup_after_deps_in_stage_1_ignored(hass): mock_integration( hass, MockModule( - domain="an_after_dep", async_setup=gen_domain_setup("an_after_dep"), + domain="an_after_dep", + async_setup=gen_domain_setup("an_after_dep"), ), ) mock_integration( diff --git a/tests/test_config.py b/tests/test_config.py index 22b5987f69c..9ec0c166850 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -958,20 +958,23 @@ async def test_component_config_exceptions(hass, caplog): # component.PLATFORM_SCHEMA caplog.clear() - assert await config_util.async_process_component_config( - hass, - {"test_domain": {"platform": "test_platform"}}, - integration=Mock( - domain="test_domain", - get_platform=Mock(return_value=None), - get_component=Mock( - return_value=Mock( - spec=["PLATFORM_SCHEMA_BASE"], - PLATFORM_SCHEMA_BASE=Mock(side_effect=ValueError("broken")), - ) + assert ( + await config_util.async_process_component_config( + hass, + {"test_domain": {"platform": "test_platform"}}, + integration=Mock( + domain="test_domain", + get_platform=Mock(return_value=None), + get_component=Mock( + return_value=Mock( + spec=["PLATFORM_SCHEMA_BASE"], + PLATFORM_SCHEMA_BASE=Mock(side_effect=ValueError("broken")), + ) + ), ), - ), - ) == {"test_domain": []} + ) + == {"test_domain": []} + ) assert "ValueError: broken" in caplog.text assert ( "Unknown error validating test_platform platform config with test_domain component platform schema" @@ -990,15 +993,20 @@ async def test_component_config_exceptions(hass, caplog): ) ), ): - assert await config_util.async_process_component_config( - hass, - {"test_domain": {"platform": "test_platform"}}, - integration=Mock( - domain="test_domain", - get_platform=Mock(return_value=None), - get_component=Mock(return_value=Mock(spec=["PLATFORM_SCHEMA_BASE"])), - ), - ) == {"test_domain": []} + assert ( + await config_util.async_process_component_config( + hass, + {"test_domain": {"platform": "test_platform"}}, + integration=Mock( + domain="test_domain", + get_platform=Mock(return_value=None), + get_component=Mock( + return_value=Mock(spec=["PLATFORM_SCHEMA_BASE"]) + ), + ), + ) + == {"test_domain": []} + ) assert "ValueError: broken" in caplog.text assert ( "Unknown error validating config for test_platform platform for test_domain component with PLATFORM_SCHEMA" @@ -1025,7 +1033,11 @@ async def test_component_config_exceptions(hass, caplog): ), ("zone", vol.Schema({vol.Optional("zone"): int}), None), ("zone", vol.Schema({"zone": int}), None), - ("not_existing", vol.Schema({vol.Optional("zone", default=dict): dict}), None,), + ( + "not_existing", + vol.Schema({vol.Optional("zone", default=dict): dict}), + None, + ), ("non_existing", vol.Schema({"zone": int}), None), ("zone", vol.Schema({}), None), ("plex", vol.Schema(vol.All({"plex": {"host": str}})), "dict"), diff --git a/tests/test_config_entries.py b/tests/test_config_entries.py index 816530befea..f13fac02850 100644 --- a/tests/test_config_entries.py +++ b/tests/test_config_entries.py @@ -1003,7 +1003,8 @@ async def test_init_custom_integration(hass): ) with pytest.raises(data_entry_flow.UnknownHandler): with patch( - "homeassistant.loader.async_get_integration", return_value=integration, + "homeassistant.loader.async_get_integration", + return_value=integration, ): await hass.config_entries.flow.async_init("bla") @@ -1178,7 +1179,8 @@ async def test_unique_id_update_existing_entry_without_reload(hass, manager): entry.add_to_hass(hass) mock_integration( - hass, MockModule("comp"), + hass, + MockModule("comp"), ) mock_entity_platform(hass, "config_flow.comp", None) @@ -1221,7 +1223,8 @@ async def test_unique_id_update_existing_entry_with_reload(hass, manager): entry.add_to_hass(hass) mock_integration( - hass, MockModule("comp"), + hass, + MockModule("comp"), ) mock_entity_platform(hass, "config_flow.comp", None) updates = {"host": "1.1.1.1"} @@ -1281,7 +1284,8 @@ async def test_unique_id_not_update_existing_entry(hass, manager): entry.add_to_hass(hass) mock_integration( - hass, MockModule("comp"), + hass, + MockModule("comp"), ) mock_entity_platform(hass, "config_flow.comp", None) @@ -1346,7 +1350,8 @@ async def test_unique_id_in_progress(hass, manager): async def test_finish_flow_aborts_progress(hass, manager): """Test that when finishing a flow, we abort other flows in progress with unique ID.""" mock_integration( - hass, MockModule("comp", async_setup_entry=AsyncMock(return_value=True)), + hass, + MockModule("comp", async_setup_entry=AsyncMock(return_value=True)), ) mock_entity_platform(hass, "config_flow.comp", None) @@ -1611,7 +1616,9 @@ async def test_async_setup_init_entry(hass): """Mock setup.""" hass.async_create_task( hass.config_entries.flow.async_init( - "comp", context={"source": config_entries.SOURCE_IMPORT}, data={}, + "comp", + context={"source": config_entries.SOURCE_IMPORT}, + data={}, ) ) return True @@ -1656,7 +1663,9 @@ async def test_async_setup_update_entry(hass): """Mock setup.""" hass.async_create_task( hass.config_entries.flow.async_init( - "comp", context={"source": config_entries.SOURCE_IMPORT}, data={}, + "comp", + context={"source": config_entries.SOURCE_IMPORT}, + data={}, ) ) return True @@ -1714,7 +1723,8 @@ async def test_async_setup_update_entry(hass): async def test_flow_with_default_discovery(hass, manager, discovery_source): """Test that finishing a default discovery flow removes the unique ID in the entry.""" mock_integration( - hass, MockModule("comp", async_setup_entry=AsyncMock(return_value=True)), + hass, + MockModule("comp", async_setup_entry=AsyncMock(return_value=True)), ) mock_entity_platform(hass, "config_flow.comp", None) diff --git a/tests/test_requirements.py b/tests/test_requirements.py index fcc2d571331..6297da0c2d5 100644 --- a/tests/test_requirements.py +++ b/tests/test_requirements.py @@ -216,7 +216,8 @@ async def test_discovery_requirements_zeroconf(hass, partial_manifest): zeroconf = await loader.async_get_integration(hass, "zeroconf") mock_integration( - hass, MockModule("comp", partial_manifest=partial_manifest), + hass, + MockModule("comp", partial_manifest=partial_manifest), ) with patch( diff --git a/tests/test_setup.py b/tests/test_setup.py index 8651308572a..3d34d1e1383 100644 --- a/tests/test_setup.py +++ b/tests/test_setup.py @@ -577,7 +577,11 @@ async def test_parallel_entry_setup(hass): return True mock_integration( - hass, MockModule("comp", async_setup_entry=mock_async_setup_entry,), + hass, + MockModule( + "comp", + async_setup_entry=mock_async_setup_entry, + ), ) mock_entity_platform(hass, "config_flow.comp", None) await setup.async_setup_component(hass, "comp", {}) diff --git a/tests/util/test_json.py b/tests/util/test_json.py index c2b6a428515..af858967150 100644 --- a/tests/util/test_json.py +++ b/tests/util/test_json.py @@ -149,12 +149,18 @@ def test_find_unserializable_data(): bad_data = object() - assert find_paths_unserializable_data( - [State("mock_domain.mock_entity", "on", {"bad": bad_data})], - dump=partial(dumps, cls=MockJSONEncoder), - ) == {"$[0](state: mock_domain.mock_entity).attributes.bad": bad_data} + assert ( + find_paths_unserializable_data( + [State("mock_domain.mock_entity", "on", {"bad": bad_data})], + dump=partial(dumps, cls=MockJSONEncoder), + ) + == {"$[0](state: mock_domain.mock_entity).attributes.bad": bad_data} + ) - assert find_paths_unserializable_data( - [Event("bad_event", {"bad_attribute": bad_data})], - dump=partial(dumps, cls=MockJSONEncoder), - ) == {"$[0](event: bad_event).data.bad_attribute": bad_data} + assert ( + find_paths_unserializable_data( + [Event("bad_event", {"bad_attribute": bad_data})], + dump=partial(dumps, cls=MockJSONEncoder), + ) + == {"$[0](event: bad_event).data.bad_attribute": bad_data} + )