From e6388e186ce97b48853f1f196193018cc4c4e109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Thu, 2 Jan 2020 21:17:10 +0200 Subject: [PATCH] Remove unnecessary string literal concatenations (#30360) --- homeassistant/__main__.py | 8 +-- homeassistant/auth/providers/command_line.py | 2 +- homeassistant/bootstrap.py | 4 +- homeassistant/components/alexa/auth.py | 2 +- .../components/arest/binary_sensor.py | 2 +- homeassistant/components/arest/sensor.py | 2 +- homeassistant/components/arest/switch.py | 2 +- homeassistant/components/august/__init__.py | 8 +-- .../components/aurora/binary_sensor.py | 2 +- homeassistant/components/auth/indieauth.py | 2 +- .../components/automatic/device_tracker.py | 2 +- .../components/automation/__init__.py | 2 +- homeassistant/components/buienradar/camera.py | 2 +- homeassistant/components/buienradar/util.py | 4 +- homeassistant/components/camera/__init__.py | 2 +- .../cisco_mobility_express/device_tracker.py | 2 +- .../components/cisco_webex_teams/notify.py | 2 +- homeassistant/components/citybikes/sensor.py | 6 +- homeassistant/components/cloud/http_api.py | 2 +- homeassistant/components/coinbase/__init__.py | 2 +- homeassistant/components/decora/light.py | 3 +- homeassistant/components/demo/media_player.py | 2 +- .../components/directv/media_player.py | 4 +- homeassistant/components/dyson/__init__.py | 2 +- .../components/ecoal_boiler/__init__.py | 2 +- homeassistant/components/ecobee/climate.py | 2 +- .../components/egardia/alarm_control_panel.py | 2 +- homeassistant/components/esphome/__init__.py | 2 +- .../components/feedreader/__init__.py | 2 +- homeassistant/components/fibaro/__init__.py | 6 +- homeassistant/components/flux/switch.py | 2 +- .../components/foursquare/__init__.py | 2 +- .../components/fritz/device_tracker.py | 2 +- .../components/generic_thermostat/climate.py | 2 +- homeassistant/components/harmony/remote.py | 2 +- .../components/haveibeenpwned/sensor.py | 2 +- .../components/history_stats/sensor.py | 6 +- homeassistant/components/homekit/__init__.py | 2 +- .../components/homekit/type_media_players.py | 2 +- homeassistant/components/homekit/util.py | 2 +- homeassistant/components/html5/notify.py | 6 +- homeassistant/components/http/ban.py | 4 +- homeassistant/components/http/view.py | 8 ++- homeassistant/components/hue/__init__.py | 4 +- homeassistant/components/hue/light.py | 2 +- homeassistant/components/imap/sensor.py | 2 +- homeassistant/components/influxdb/sensor.py | 5 +- .../components/input_datetime/__init__.py | 2 +- homeassistant/components/ios/notify.py | 6 +- .../components/isy994/binary_sensor.py | 6 +- homeassistant/components/knx/__init__.py | 2 +- homeassistant/components/kodi/media_player.py | 2 +- homeassistant/components/lametric/notify.py | 2 +- homeassistant/components/lcn/helpers.py | 2 +- homeassistant/components/lcn/services.py | 4 +- .../components/logi_circle/config_flow.py | 2 +- homeassistant/components/min_max/sensor.py | 2 +- homeassistant/components/mobile_app/notify.py | 6 +- homeassistant/components/modbus/sensor.py | 4 +- homeassistant/components/modbus/switch.py | 2 +- .../components/mold_indicator/sensor.py | 10 ++-- homeassistant/components/mqtt/__init__.py | 8 +-- homeassistant/components/nest/__init__.py | 2 +- .../components/nissan_leaf/__init__.py | 6 +- homeassistant/components/nut/sensor.py | 2 +- homeassistant/components/ohmconnect/sensor.py | 4 +- homeassistant/components/opensky/sensor.py | 2 +- .../components/openweathermap/weather.py | 2 +- homeassistant/components/owlet/__init__.py | 2 +- .../components/owntracks/__init__.py | 2 +- homeassistant/components/prowl/notify.py | 2 +- .../components/proximity/__init__.py | 2 +- .../components/python_script/__init__.py | 2 +- .../quantum_gateway/device_tracker.py | 2 +- homeassistant/components/recorder/__init__.py | 2 +- .../components/remember_the_milk/__init__.py | 10 ++-- .../components/satel_integra/__init__.py | 4 +- .../components/satel_integra/switch.py | 4 +- homeassistant/components/slide/__init__.py | 5 +- .../components/smartthings/smartapp.py | 2 +- .../components/spotify/media_player.py | 2 +- .../swiss_hydrological_data/sensor.py | 2 +- .../components/tado/device_tracker.py | 4 +- .../components/telegram_bot/__init__.py | 2 +- .../components/template/binary_sensor.py | 4 +- homeassistant/components/template/cover.py | 5 +- homeassistant/components/template/light.py | 2 +- homeassistant/components/template/sensor.py | 4 +- homeassistant/components/template/switch.py | 2 +- .../components/tomato/device_tracker.py | 2 +- .../totalconnect/alarm_control_panel.py | 2 +- homeassistant/components/uscis/sensor.py | 2 +- homeassistant/components/wink/__init__.py | 5 +- .../components/wirelesstag/__init__.py | 2 +- .../components/wunderground/sensor.py | 2 +- .../components/xfinity/device_tracker.py | 4 +- homeassistant/components/xiaomi_miio/light.py | 12 ++-- .../components/xiaomi_miio/vacuum.py | 2 +- homeassistant/components/xmpp/notify.py | 2 +- homeassistant/components/xs1/__init__.py | 3 +- homeassistant/components/yeelight/light.py | 4 +- homeassistant/components/yr/sensor.py | 2 +- homeassistant/components/zigbee/__init__.py | 2 +- homeassistant/components/zwave/__init__.py | 16 ++--- homeassistant/components/zwave/lock.py | 4 +- homeassistant/config.py | 2 +- homeassistant/helpers/condition.py | 2 +- homeassistant/helpers/config_validation.py | 2 +- homeassistant/helpers/entity_platform.py | 2 +- homeassistant/helpers/template.py | 2 +- homeassistant/loader.py | 2 +- homeassistant/scripts/ensure_config.py | 4 +- homeassistant/setup.py | 6 +- homeassistant/util/dt.py | 2 +- homeassistant/util/yaml/loader.py | 4 +- script/hassfest/codeowners.py | 2 +- script/hassfest/ssdp.py | 2 +- script/hassfest/zeroconf.py | 2 +- tests/components/aprs/test_device_tracker.py | 2 +- tests/components/automation/test_time.py | 2 +- tests/components/binary_sensor/test_init.py | 5 +- tests/components/buienradar/test_camera.py | 2 +- tests/components/camera/test_init.py | 2 +- tests/components/cloud/test_http_api.py | 6 +- tests/components/demo/test_media_player.py | 2 +- tests/components/device_tracker/test_init.py | 4 +- tests/components/emulated_hue/test_hue_api.py | 2 +- tests/components/emulated_hue/test_init.py | 6 +- tests/components/emulated_hue/test_upnp.py | 2 +- .../facebox/test_image_processing.py | 2 +- tests/components/feedreader/test_init.py | 10 ++-- tests/components/filter/test_sensor.py | 8 +-- tests/components/hassio/conftest.py | 2 +- tests/components/hassio/test_discovery.py | 8 +-- .../here_travel_time/test_sensor.py | 2 +- tests/components/history_stats/test_sensor.py | 6 +- tests/components/homekit/test_accessories.py | 6 +- tests/components/honeywell/test_climate.py | 12 ++-- .../ign_sismologia/test_geo_location.py | 4 +- .../islamic_prayer_times/test_sensor.py | 2 +- tests/components/logentries/test_init.py | 2 +- tests/components/mailbox/test_init.py | 6 +- .../manual/test_alarm_control_panel.py | 60 +++++++++---------- tests/components/microsoft_face/test_init.py | 14 ++--- .../test_image_processing.py | 4 +- .../test_image_processing.py | 4 +- tests/components/mqtt/test_binary_sensor.py | 4 +- tests/components/mqtt/test_climate.py | 2 +- tests/components/mqtt/test_device_tracker.py | 2 +- tests/components/mqtt/test_discovery.py | 8 +-- tests/components/mqtt/test_light.py | 2 +- tests/components/mqtt/test_light_json.py | 2 +- tests/components/mqtt/test_light_template.py | 2 +- tests/components/mqtt/test_sensor.py | 4 +- tests/components/mqtt/test_switch.py | 2 +- .../mqtt_json/test_device_tracker.py | 2 +- .../components/owntracks/test_config_flow.py | 4 +- .../owntracks/test_device_tracker.py | 6 +- .../qld_bushfire/test_geo_location.py | 4 +- tests/components/radarr/test_sensor.py | 2 +- tests/components/rflink/test_binary_sensor.py | 8 +-- tests/components/shell_command/test_init.py | 2 +- tests/components/shopping_list/conftest.py | 2 +- tests/components/startca/test_sensor.py | 10 ++-- .../components/tomato/test_device_tracker.py | 6 +- tests/components/tplink/test_init.py | 2 +- tests/components/tradfri/conftest.py | 2 +- tests/components/tradfri/test_config_flow.py | 4 +- tests/components/tts/test_init.py | 20 +++---- tests/components/websocket_api/test_auth.py | 2 +- tests/components/wunderground/test_sensor.py | 6 +- tests/components/yr/test_sensor.py | 6 +- tests/components/zha/test_config_flow.py | 4 +- tests/conftest.py | 2 +- tests/helpers/test_check_config.py | 5 +- tests/helpers/test_device_registry.py | 2 +- tests/helpers/test_entity_component.py | 6 +- tests/helpers/test_entity_platform.py | 2 +- tests/helpers/test_event.py | 4 +- tests/helpers/test_service.py | 2 +- tests/helpers/test_template.py | 22 +++---- tests/scripts/test_check_config.py | 9 ++- tests/util/test_yaml.py | 8 +-- 183 files changed, 362 insertions(+), 393 deletions(-) diff --git a/homeassistant/__main__.py b/homeassistant/__main__.py index bcc97252255..a0243e2dd8c 100644 --- a/homeassistant/__main__.py +++ b/homeassistant/__main__.py @@ -78,11 +78,7 @@ def ensure_config_path(config_dir: str) -> None: try: os.mkdir(lib_dir) except OSError: - print( - ("Fatal Error: Unable to create library " "directory {} ").format( - lib_dir - ) - ) + print("Fatal Error: Unable to create library directory {}".format(lib_dir)) sys.exit(1) @@ -147,7 +143,7 @@ def get_arguments() -> argparse.Namespace: "--log-file", type=str, default=None, - help="Log file to write to. If not set, CONFIG/home-assistant.log " "is used", + help="Log file to write to. If not set, CONFIG/home-assistant.log is used", ) parser.add_argument( "--log-no-color", action="store_true", help="Disable color logs" diff --git a/homeassistant/auth/providers/command_line.py b/homeassistant/auth/providers/command_line.py index 203bc191193..12e27c01504 100644 --- a/homeassistant/auth/providers/command_line.py +++ b/homeassistant/auth/providers/command_line.py @@ -76,7 +76,7 @@ class CommandLineAuthProvider(AuthProvider): if process.returncode != 0: _LOGGER.error( - "User %r failed to authenticate, command exited " "with code %d.", + "User %r failed to authenticate, command exited with code %d.", username, process.returncode, ) diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index 12fbc6f232f..48ca96c7254 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -66,7 +66,7 @@ async def async_from_config_dict( hass.config.skip_pip = skip_pip if skip_pip: _LOGGER.warning( - "Skipping pip installation of required modules. " "This may cause issues" + "Skipping pip installation of required modules. This may cause issues" ) core_config = config.get(core.DOMAIN, {}) @@ -168,7 +168,7 @@ def async_enable_logging( This method must be run in the event loop. """ - fmt = "%(asctime)s %(levelname)s (%(threadName)s) " "[%(name)s] %(message)s" + fmt = "%(asctime)s %(levelname)s (%(threadName)s) [%(name)s] %(message)s" datefmt = "%Y-%m-%d %H:%M:%S" if not log_no_color: diff --git a/homeassistant/components/alexa/auth.py b/homeassistant/components/alexa/auth.py index 33c25b73d7e..94789c33305 100644 --- a/homeassistant/components/alexa/auth.py +++ b/homeassistant/components/alexa/auth.py @@ -51,7 +51,7 @@ class Auth: "client_secret": self.client_secret, } _LOGGER.debug( - "Calling LWA to get the access token (first time), " "with: %s", + "Calling LWA to get the access token (first time), with: %s", json.dumps(lwa_params), ) diff --git a/homeassistant/components/arest/binary_sensor.py b/homeassistant/components/arest/binary_sensor.py index caabe3333f8..3bd0a85c6f0 100644 --- a/homeassistant/components/arest/binary_sensor.py +++ b/homeassistant/components/arest/binary_sensor.py @@ -38,7 +38,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): response = requests.get(resource, timeout=10).json() except requests.exceptions.MissingSchema: _LOGGER.error( - "Missing resource or schema in configuration. " "Add http:// to your URL" + "Missing resource or schema in configuration. Add http:// to your URL" ) return False except requests.exceptions.ConnectionError: diff --git a/homeassistant/components/arest/sensor.py b/homeassistant/components/arest/sensor.py index 270a3cda269..2533ce3619e 100644 --- a/homeassistant/components/arest/sensor.py +++ b/homeassistant/components/arest/sensor.py @@ -59,7 +59,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): response = requests.get(resource, timeout=10).json() except requests.exceptions.MissingSchema: _LOGGER.error( - "Missing resource or schema in configuration. " "Add http:// to your URL" + "Missing resource or schema in configuration. Add http:// to your URL" ) return False except requests.exceptions.ConnectionError: diff --git a/homeassistant/components/arest/switch.py b/homeassistant/components/arest/switch.py index b3db6684cf2..ccc2c5d8bf5 100644 --- a/homeassistant/components/arest/switch.py +++ b/homeassistant/components/arest/switch.py @@ -46,7 +46,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): response = requests.get(resource, timeout=10) except requests.exceptions.MissingSchema: _LOGGER.error( - "Missing resource or schema in configuration. " "Add http:// to your URL" + "Missing resource or schema in configuration. Add http:// to your URL" ) return False except requests.exceptions.ConnectionError: diff --git a/homeassistant/components/august/__init__.py b/homeassistant/components/august/__init__.py index 468e6e429a7..8cbe41dac9e 100644 --- a/homeassistant/components/august/__init__.py +++ b/homeassistant/components/august/__init__.py @@ -254,7 +254,7 @@ class AugustData: ) except RequestException as ex: _LOGGER.error( - "Request error trying to retrieve doorbell" " status for %s. %s", + "Request error trying to retrieve doorbell status for %s. %s", doorbell.device_name, ex, ) @@ -301,7 +301,7 @@ class AugustData: ) except RequestException as ex: _LOGGER.error( - "Request error trying to retrieve door" " status for %s. %s", + "Request error trying to retrieve door status for %s. %s", lock.device_name, ex, ) @@ -327,7 +327,7 @@ class AugustData: ) except RequestException as ex: _LOGGER.error( - "Request error trying to retrieve door" " status for %s. %s", + "Request error trying to retrieve door status for %s. %s", lock.device_name, ex, ) @@ -342,7 +342,7 @@ class AugustData: ) except RequestException as ex: _LOGGER.error( - "Request error trying to retrieve door" " details for %s. %s", + "Request error trying to retrieve door details for %s. %s", lock.device_name, ex, ) diff --git a/homeassistant/components/aurora/binary_sensor.py b/homeassistant/components/aurora/binary_sensor.py index d76884d2895..454c3ad2405 100644 --- a/homeassistant/components/aurora/binary_sensor.py +++ b/homeassistant/components/aurora/binary_sensor.py @@ -13,7 +13,7 @@ from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) -ATTRIBUTION = "Data provided by the National Oceanic and Atmospheric " "Administration" +ATTRIBUTION = "Data provided by the National Oceanic and Atmospheric Administration" CONF_THRESHOLD = "forecast_threshold" DEFAULT_DEVICE_CLASS = "visible" diff --git a/homeassistant/components/auth/indieauth.py b/homeassistant/components/auth/indieauth.py index 5915a4ec301..3266ae65d7a 100644 --- a/homeassistant/components/auth/indieauth.py +++ b/homeassistant/components/auth/indieauth.py @@ -99,7 +99,7 @@ async def fetch_redirect_uris(hass, url): pass except aiohttp.client_exceptions.ClientConnectionError: _LOGGER.error( - ("Low level connection error while looking up " "redirect_uri %s"), url + "Low level connection error while looking up redirect_uri %s", url ) pass except aiohttp.client_exceptions.ClientError: diff --git a/homeassistant/components/automatic/device_tracker.py b/homeassistant/components/automatic/device_tracker.py index bb403687963..3c9e33cdc84 100644 --- a/homeassistant/components/automatic/device_tracker.py +++ b/homeassistant/components/automatic/device_tracker.py @@ -232,7 +232,7 @@ class AutomaticData: if event.created_at < self.vehicle_seen[event.vehicle.id]: # Skip events received out of order _LOGGER.debug( - "Skipping out of order event. Event Created %s. " "Last seen event: %s", + "Skipping out of order event. Event Created %s. Last seen event: %s", event.created_at, self.vehicle_seen[event.vehicle.id], ) diff --git a/homeassistant/components/automation/__init__.py b/homeassistant/components/automation/__init__.py index 4441b028565..671d7bd3d5b 100644 --- a/homeassistant/components/automation/__init__.py +++ b/homeassistant/components/automation/__init__.py @@ -275,7 +275,7 @@ class AutomationEntity(ToggleEntity, RestoreEntity): else: enable_automation = DEFAULT_INITIAL_STATE _LOGGER.debug( - "Automation %s not in state storage, state %s from " "default is used.", + "Automation %s not in state storage, state %s from default is used.", self.entity_id, enable_automation, ) diff --git a/homeassistant/components/buienradar/camera.py b/homeassistant/components/buienradar/camera.py index 3d30e330bc9..c1ef11c1d0d 100644 --- a/homeassistant/components/buienradar/camera.py +++ b/homeassistant/components/buienradar/camera.py @@ -16,7 +16,7 @@ from homeassistant.util import dt as dt_util CONF_DIMENSION = "dimension" CONF_DELTA = "delta" -RADAR_MAP_URL_TEMPLATE = "https://api.buienradar.nl/image/1.0/" "RadarMapNL?w={w}&h={h}" +RADAR_MAP_URL_TEMPLATE = "https://api.buienradar.nl/image/1.0/RadarMapNL?w={w}&h={h}" _LOG = logging.getLogger(__name__) diff --git a/homeassistant/components/buienradar/util.py b/homeassistant/components/buienradar/util.py index 2ef0713713b..37c518cef7a 100644 --- a/homeassistant/components/buienradar/util.py +++ b/homeassistant/components/buienradar/util.py @@ -115,7 +115,7 @@ class BrData: if raincontent.get(SUCCESS) is not True: # unable to get the data _LOGGER.warning( - "Unable to retrieve raindata from Buienradar." "(Msg: %s, status: %s,)", + "Unable to retrieve raindata from Buienradar. (Msg: %s, status: %s)", raincontent.get(MESSAGE), raincontent.get(STATUS_CODE), ) @@ -136,7 +136,7 @@ class BrData: if result.get(SUCCESS) is not True: if int(datetime.now().strftime("%H")) > 0: _LOGGER.warning( - "Unable to parse data from Buienradar." "(Msg: %s)", + "Unable to parse data from Buienradar. (Msg: %s)", result.get(MESSAGE), ) await self.schedule_update(SCHEDULE_NOK) diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index b3d5935784f..4fe52a7d164 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -168,7 +168,7 @@ async def async_get_still_stream(request, image_cb, content_type, interval): This method must be run in the event loop. """ response = web.StreamResponse() - response.content_type = "multipart/x-mixed-replace; " "boundary=--frameboundary" + response.content_type = "multipart/x-mixed-replace; boundary=--frameboundary" await response.prepare(request) async def write_to_mjpeg_stream(img_bytes): diff --git a/homeassistant/components/cisco_mobility_express/device_tracker.py b/homeassistant/components/cisco_mobility_express/device_tracker.py index 702ebdfa611..db504e3d19b 100644 --- a/homeassistant/components/cisco_mobility_express/device_tracker.py +++ b/homeassistant/components/cisco_mobility_express/device_tracker.py @@ -89,5 +89,5 @@ class CiscoMEDeviceScanner(DeviceScanner): """Check the Cisco ME controller for devices.""" self.last_results = self.controller.get_associated_devices() _LOGGER.debug( - "Cisco Mobility Express controller returned:" " %s", self.last_results + "Cisco Mobility Express controller returned: %s", self.last_results ) diff --git a/homeassistant/components/cisco_webex_teams/notify.py b/homeassistant/components/cisco_webex_teams/notify.py index 6f80fa138d4..7be53d1fb6c 100644 --- a/homeassistant/components/cisco_webex_teams/notify.py +++ b/homeassistant/components/cisco_webex_teams/notify.py @@ -54,5 +54,5 @@ class CiscoWebexTeamsNotificationService(BaseNotificationService): self.client.messages.create(roomId=self.room, html=f"{title}{message}") except ApiError as api_error: _LOGGER.error( - "Could not send CiscoWebexTeams notification. " "Error: %s", api_error + "Could not send CiscoWebexTeams notification. Error: %s", api_error ) diff --git a/homeassistant/components/citybikes/sensor.py b/homeassistant/components/citybikes/sensor.py index cb2647487ea..8e0b883b726 100644 --- a/homeassistant/components/citybikes/sensor.py +++ b/homeassistant/components/citybikes/sensor.py @@ -57,7 +57,7 @@ SCAN_INTERVAL = timedelta(minutes=5) # Timely, and doesn't suffocate the API STATIONS_URI = "v2/networks/{uid}?fields=network.stations" CITYBIKES_ATTRIBUTION = ( - "Information provided by the CityBikes Project " "(https://citybik.es/#about)" + "Information provided by the CityBikes Project (https://citybik.es/#about)" ) CITYBIKES_NETWORKS = "citybikes_networks" @@ -143,9 +143,7 @@ async def async_citybikes_request(hass, uri, schema): except ValueError: _LOGGER.error("Received non-JSON data from CityBikes API endpoint") except vol.Invalid as err: - _LOGGER.error( - "Received unexpected JSON from CityBikes" " API endpoint: %s", err - ) + _LOGGER.error("Received unexpected JSON from CityBikes API endpoint: %s", err) raise CityBikesRequestError diff --git a/homeassistant/components/cloud/http_api.py b/homeassistant/components/cloud/http_api.py index c68f24172f0..b97feb7c6f4 100644 --- a/homeassistant/components/cloud/http_api.py +++ b/homeassistant/components/cloud/http_api.py @@ -583,7 +583,7 @@ async def alexa_sync(hass, connection, msg): connection.send_error( msg["id"], "alexa_relink", - "Please go to the Alexa app and re-link the Home Assistant " "skill.", + "Please go to the Alexa app and re-link the Home Assistant skill.", ) return diff --git a/homeassistant/components/coinbase/__init__.py b/homeassistant/components/coinbase/__init__.py index 67869e6b88c..d52c0867e24 100644 --- a/homeassistant/components/coinbase/__init__.py +++ b/homeassistant/components/coinbase/__init__.py @@ -94,5 +94,5 @@ class CoinbaseData: self.exchange_rates = self.client.get_exchange_rates() except AuthenticationError as coinbase_error: _LOGGER.error( - "Authentication error connecting" " to coinbase: %s", coinbase_error + "Authentication error connecting to coinbase: %s", coinbase_error ) diff --git a/homeassistant/components/decora/light.py b/homeassistant/components/decora/light.py index 6ca427f2476..f4035352e51 100644 --- a/homeassistant/components/decora/light.py +++ b/homeassistant/components/decora/light.py @@ -62,8 +62,7 @@ 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/media_player.py b/homeassistant/components/demo/media_player.py index 9d7c3892af8..33fe4ee3647 100644 --- a/homeassistant/components/demo/media_player.py +++ b/homeassistant/components/demo/media_player.py @@ -340,7 +340,7 @@ class DemoMusicPlayer(AbstractDemoPlayer): @property def media_image_url(self): """Return the image url of current playing media.""" - return "https://graph.facebook.com/v2.5/107771475912710/" "picture?type=large" + return "https://graph.facebook.com/v2.5/107771475912710/picture?type=large" @property def media_title(self): diff --git a/homeassistant/components/directv/media_player.py b/homeassistant/components/directv/media_player.py index 5dd673ca93f..cd4f910c707 100644 --- a/homeassistant/components/directv/media_player.py +++ b/homeassistant/components/directv/media_player.py @@ -129,7 +129,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) else: _LOGGER.debug( - "Adding discovered device %s with" " client address %s", + "Adding discovered device %s with client address %s", str.title(loc["locationName"]), loc["clientAddr"], ) @@ -214,7 +214,7 @@ class DirecTvDevice(MediaPlayerDevice): except requests.RequestException as ex: _LOGGER.error( - "%s: Request error trying to update current status: " "%s", + "%s: Request error trying to update current status: %s", self.entity_id, ex, ) diff --git a/homeassistant/components/dyson/__init__.py b/homeassistant/components/dyson/__init__.py index a5dde58d30f..fbe7897e6bb 100644 --- a/homeassistant/components/dyson/__init__.py +++ b/homeassistant/components/dyson/__init__.py @@ -89,7 +89,7 @@ def setup(hass, config): # Not yet reliable for device in dyson_devices: _LOGGER.info( - "Trying to connect to device %s with timeout=%i " "and retry=%i", + "Trying to connect to device %s with timeout=%i and retry=%i", device, timeout, retry, diff --git a/homeassistant/components/ecoal_boiler/__init__.py b/homeassistant/components/ecoal_boiler/__init__.py index ed8e315bfed..608e4a59a3f 100644 --- a/homeassistant/components/ecoal_boiler/__init__.py +++ b/homeassistant/components/ecoal_boiler/__init__.py @@ -91,7 +91,7 @@ def setup(hass, hass_config): if ecoal_contr.version is None: # Wrong credentials nor network config _LOGGER.error( - "Unable to read controller status from %s@%s" " (wrong host/credentials)", + "Unable to read controller status from %s@%s (wrong host/credentials)", username, host, ) diff --git a/homeassistant/components/ecobee/climate.py b/homeassistant/components/ecobee/climate.py index 83a1453a23a..5915e64334f 100644 --- a/homeassistant/components/ecobee/climate.py +++ b/homeassistant/components/ecobee/climate.py @@ -550,7 +550,7 @@ class Thermostat(ClimateDevice): self.hold_preference(), ) _LOGGER.debug( - "Setting ecobee hold_temp to: heat=%s, is=%s, " "cool=%s, is=%s", + "Setting ecobee hold_temp to: heat=%s, is=%s, cool=%s, is=%s", heat_temp, isinstance(heat_temp, (int, float)), cool_temp, diff --git a/homeassistant/components/egardia/alarm_control_panel.py b/homeassistant/components/egardia/alarm_control_panel.py index 2c18be47a1f..7e5f88cff3e 100644 --- a/homeassistant/components/egardia/alarm_control_panel.py +++ b/homeassistant/components/egardia/alarm_control_panel.py @@ -139,7 +139,7 @@ class EgardiaAlarm(alarm.AlarmControlPanel): self._egardiasystem.alarm_disarm() except requests.exceptions.RequestException as err: _LOGGER.error( - "Egardia device exception occurred when " "sending disarm command: %s", + "Egardia device exception occurred when sending disarm command: %s", err, ) diff --git a/homeassistant/components/esphome/__init__.py b/homeassistant/components/esphome/__init__.py index 2ad24e6f75e..cabba95ea7e 100644 --- a/homeassistant/components/esphome/__init__.py +++ b/homeassistant/components/esphome/__init__.py @@ -130,7 +130,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool # ESPHome uses servicecall packet for both events and service calls # Ensure the user can only send events of form 'esphome.xyz' if domain != "esphome": - _LOGGER.error("Can only generate events under esphome " "domain!") + _LOGGER.error("Can only generate events under esphome domain!") return hass.bus.async_fire(service.service, service_data) else: diff --git a/homeassistant/components/feedreader/__init__.py b/homeassistant/components/feedreader/__init__.py index bf1e55370bc..2643607c3a8 100644 --- a/homeassistant/components/feedreader/__init__.py +++ b/homeassistant/components/feedreader/__init__.py @@ -131,7 +131,7 @@ class FeedManager: """Filter the entries provided and return the ones to keep.""" if len(self._feed.entries) > self._max_entries: _LOGGER.debug( - "Processing only the first %s entries " "in feed %s", + "Processing only the first %s entries in feed %s", self._max_entries, self._url, ) diff --git a/homeassistant/components/fibaro/__init__.py b/homeassistant/components/fibaro/__init__.py index d44819e758b..aeb7c0879e0 100644 --- a/homeassistant/components/fibaro/__init__.py +++ b/homeassistant/components/fibaro/__init__.py @@ -134,11 +134,11 @@ class FibaroController: info = self._client.info.get() self.hub_serial = slugify(info.serialNumber) except AssertionError: - _LOGGER.error("Can't connect to Fibaro HC. " "Please check URL.") + _LOGGER.error("Can't connect to Fibaro HC. Please check URL.") return False if login is None or login.status is False: _LOGGER.error( - "Invalid login for Fibaro HC. " "Please check username and password" + "Invalid login for Fibaro HC. Please check username and password" ) return False @@ -380,7 +380,7 @@ class FibaroDevice(Entity): def dont_know_message(self, action): """Make a warning in case we don't know how to perform an action.""" _LOGGER.warning( - "Not sure how to setValue: %s " "(available actions: %s)", + "Not sure how to setValue: %s (available actions: %s)", str(self.ha_id), str(self.fibaro_device.actions), ) diff --git a/homeassistant/components/flux/switch.py b/homeassistant/components/flux/switch.py index a02b1b2504b..f22b6335911 100644 --- a/homeassistant/components/flux/switch.py +++ b/homeassistant/components/flux/switch.py @@ -323,7 +323,7 @@ class FluxSwitch(SwitchDevice, RestoreEntity): elif self._mode == MODE_RGB: await async_set_lights_rgb(self.hass, self._lights, rgb, self._transition) _LOGGER.debug( - "Lights updated to rgb:%s, %s%% " "of %s cycle complete at %s", + "Lights updated to rgb:%s, %s%% of %s cycle complete at %s", rgb, round(percentage_complete * 100), time_state, diff --git a/homeassistant/components/foursquare/__init__.py b/homeassistant/components/foursquare/__init__.py index 3f0578cf5b4..af15c4e5fa8 100644 --- a/homeassistant/components/foursquare/__init__.py +++ b/homeassistant/components/foursquare/__init__.py @@ -103,7 +103,7 @@ class FoursquarePushReceiver(HomeAssistantView): if self.push_secret != secret: _LOGGER.error( - "Received Foursquare push with invalid" "push secret: %s", secret + "Received Foursquare push with invalid push secret: %s", secret ) return self.json_message("Incorrect secret", HTTP_BAD_REQUEST) diff --git a/homeassistant/components/fritz/device_tracker.py b/homeassistant/components/fritz/device_tracker.py index d16fcbb3a1e..e2382490cde 100644 --- a/homeassistant/components/fritz/device_tracker.py +++ b/homeassistant/components/fritz/device_tracker.py @@ -60,7 +60,7 @@ class FritzBoxScanner(DeviceScanner): self._update_info() else: _LOGGER.error( - "Failed to establish connection to FRITZ!Box " "with IP: %s", self.host + "Failed to establish connection to FRITZ!Box with IP: %s", self.host ) def scan_devices(self): diff --git a/homeassistant/components/generic_thermostat/climate.py b/homeassistant/components/generic_thermostat/climate.py index cb5ae275df7..58514934fc7 100644 --- a/homeassistant/components/generic_thermostat/climate.py +++ b/homeassistant/components/generic_thermostat/climate.py @@ -214,7 +214,7 @@ class GenericThermostat(ClimateDevice, RestoreEntity): else: self._target_temp = self.min_temp _LOGGER.warning( - "Undefined target temperature," "falling back to %s", + "Undefined target temperature, falling back to %s", self._target_temp, ) else: diff --git a/homeassistant/components/harmony/remote.py b/homeassistant/components/harmony/remote.py index 7f4d03ccbb0..c48d5fb00b0 100644 --- a/homeassistant/components/harmony/remote.py +++ b/homeassistant/components/harmony/remote.py @@ -369,7 +369,7 @@ class HarmonyRemote(remote.RemoteDevice): for result in result_list: _LOGGER.error( - "Sending command %s to device %s failed with code " "%s: %s", + "Sending command %s to device %s failed with code %s: %s", result.command.command, result.command.device, result.code, diff --git a/homeassistant/components/haveibeenpwned/sensor.py b/homeassistant/components/haveibeenpwned/sensor.py index a0f30dd1a8b..99f94499478 100644 --- a/homeassistant/components/haveibeenpwned/sensor.py +++ b/homeassistant/components/haveibeenpwned/sensor.py @@ -178,7 +178,7 @@ class HaveIBeenPwnedData: else: _LOGGER.error( - "Failed fetching data for %s" "(HTTP Status_code = %d)", + "Failed fetching data for %s (HTTP Status_code = %d)", self._email, req.status_code, ) diff --git a/homeassistant/components/history_stats/sensor.py b/homeassistant/components/history_stats/sensor.py index 0bded03a29c..3eb604b3957 100644 --- a/homeassistant/components/history_stats/sensor.py +++ b/homeassistant/components/history_stats/sensor.py @@ -45,7 +45,7 @@ def exactly_two_period_keys(conf): """Ensure exactly 2 of CONF_PERIOD_KEYS are provided.""" if sum(param in conf for param in CONF_PERIOD_KEYS) != 2: raise vol.Invalid( - "You must provide exactly 2 of the following:" " start, end, duration" + "You must provide exactly 2 of the following: start, end, duration" ) return conf @@ -262,7 +262,7 @@ class HistoryStatsSensor(Entity): ) except ValueError: _LOGGER.error( - "Parsing error: start must be a datetime" "or a timestamp" + "Parsing error: start must be a datetime or a timestamp" ) return @@ -281,7 +281,7 @@ class HistoryStatsSensor(Entity): ) except ValueError: _LOGGER.error( - "Parsing error: end must be a datetime " "or a timestamp" + "Parsing error: end must be a datetime or a timestamp" ) return diff --git a/homeassistant/components/homekit/__init__.py b/homeassistant/components/homekit/__init__.py index ea2c466092e..ca5a601068a 100644 --- a/homeassistant/components/homekit/__init__.py +++ b/homeassistant/components/homekit/__init__.py @@ -328,7 +328,7 @@ class HomeKit: aid = generate_aid(entity_id) if aid not in self.bridge.accessories: _LOGGER.warning( - "Could not reset accessory. entity_id " "not found %s", entity_id + "Could not reset accessory. entity_id not found %s", entity_id ) continue acc = self.remove_bridge_accessory(aid) diff --git a/homeassistant/components/homekit/type_media_players.py b/homeassistant/components/homekit/type_media_players.py index 450ae818ec8..9942c42a0de 100644 --- a/homeassistant/components/homekit/type_media_players.py +++ b/homeassistant/components/homekit/type_media_players.py @@ -422,7 +422,7 @@ class TelevisionMediaPlayer(HomeAccessory): self.char_input_source.set_value(index) else: _LOGGER.warning( - "%s: Sources out of sync. " "Restart HomeAssistant", + "%s: Sources out of sync. Restart HomeAssistant", self.entity_id, ) self.char_input_source.set_value(0) diff --git a/homeassistant/components/homekit/util.py b/homeassistant/components/homekit/util.py index 608c9a974e5..0fe97cfca63 100644 --- a/homeassistant/components/homekit/util.py +++ b/homeassistant/components/homekit/util.py @@ -103,7 +103,7 @@ def validate_entity_config(values): if not isinstance(config, dict): raise vol.Invalid( - "The configuration for {} must be " " a dictionary.".format(entity) + "The configuration for {} must be a dictionary.".format(entity) ) if domain in ("alarm_control_panel", "lock"): diff --git a/homeassistant/components/html5/notify.py b/homeassistant/components/html5/notify.py index 6d6fcd5c377..b966f5ae6a1 100644 --- a/homeassistant/components/html5/notify.py +++ b/homeassistant/components/html5/notify.py @@ -345,12 +345,12 @@ class HTML5PushCallbackView(HomeAssistantView): if parts[0].lower() != "bearer": return self.json_message( - "Authorization header must " "start with Bearer", + "Authorization header must start with Bearer", status_code=HTTP_UNAUTHORIZED, ) if len(parts) != 2: return self.json_message( - "Authorization header must " "be Bearer token", + "Authorization header must be Bearer token", status_code=HTTP_UNAUTHORIZED, ) @@ -507,7 +507,7 @@ class HTML5NotificationService(BaseNotificationService): info = REGISTER_SCHEMA(info) except vol.Invalid: _LOGGER.error( - "%s is not a valid HTML5 push notification" " target", target + "%s is not a valid HTML5 push notification target", target ) continue payload[ATTR_DATA][ATTR_JWT] = add_jwt( diff --git a/homeassistant/components/http/ban.py b/homeassistant/components/http/ban.py index 553d3657160..da406c071e4 100644 --- a/homeassistant/components/http/ban.py +++ b/homeassistant/components/http/ban.py @@ -96,7 +96,7 @@ async def process_wrong_login(request): """ remote_addr = request[KEY_REAL_IP] - msg = "Login attempt or request with invalid authentication " "from {}".format( + msg = "Login attempt or request with invalid authentication from {}".format( remote_addr ) _LOGGER.warning(msg) @@ -150,7 +150,7 @@ async def process_success_login(request): and request.app[KEY_FAILED_LOGIN_ATTEMPTS][remote_addr] > 0 ): _LOGGER.debug( - "Login success, reset failed login attempts counter" " from %s", remote_addr + "Login success, reset failed login attempts counter from %s", remote_addr ) request.app[KEY_FAILED_LOGIN_ATTEMPTS].pop(remote_addr) diff --git a/homeassistant/components/http/view.py b/homeassistant/components/http/view.py index 31f96833667..e60091684d3 100644 --- a/homeassistant/components/http/view.py +++ b/homeassistant/components/http/view.py @@ -142,9 +142,11 @@ def request_handler_factory(view, handler): elif result is None: result = b"" elif not isinstance(result, bytes): - assert False, ( - "Result should be None, string, bytes or Response. " "Got: {}" - ).format(result) + assert ( + False + ), "Result should be None, string, bytes or Response. Got: {}".format( + result + ) return web.Response(body=result, status=status_code) diff --git a/homeassistant/components/hue/__init__.py b/homeassistant/components/hue/__init__.py index 7239efafd10..cbcb21db7d0 100644 --- a/homeassistant/components/hue/__init__.py +++ b/homeassistant/components/hue/__init__.py @@ -136,9 +136,7 @@ async def async_setup_entry( ) if config.swupdate2_bridge_state == "readytoinstall": - err = ( - "Please check for software updates of the bridge " "in the Philips Hue App." - ) + err = "Please check for software updates of the bridge in the Philips Hue App." _LOGGER.warning(err) return True diff --git a/homeassistant/components/hue/light.py b/homeassistant/components/hue/light.py index ad511639d57..d81bbd4c438 100644 --- a/homeassistant/components/hue/light.py +++ b/homeassistant/components/hue/light.py @@ -277,7 +277,7 @@ class HueLight(Light): _LOGGER.warning(err, self.name) if self.gamut: if not color.check_valid_gamut(self.gamut): - err = "Color gamut of %s: %s, not valid, " "setting gamut to None." + err = "Color gamut of %s: %s, not valid, setting gamut to None." _LOGGER.warning(err, self.name, str(self.gamut)) self.gamut_typ = GAMUT_TYPE_UNAVAILABLE self.gamut = None diff --git a/homeassistant/components/imap/sensor.py b/homeassistant/components/imap/sensor.py index db2f528153b..ceef8acf7c3 100644 --- a/homeassistant/components/imap/sensor.py +++ b/homeassistant/components/imap/sensor.py @@ -162,7 +162,7 @@ class ImapSensor(Entity): self._email_count = len(lines[0].split()) else: _LOGGER.error( - "Can't parse IMAP server response to search " "'%s': %s / %s", + "Can't parse IMAP server response to search '%s': %s / %s", self._search, result, lines[0], diff --git a/homeassistant/components/influxdb/sensor.py b/homeassistant/components/influxdb/sensor.py index 58fbc5605db..4a169453e35 100644 --- a/homeassistant/components/influxdb/sensor.py +++ b/homeassistant/components/influxdb/sensor.py @@ -205,14 +205,13 @@ class InfluxSensorData: points = list(self.influx.query(self.query).get_points()) if not points: _LOGGER.warning( - "Query returned no points, sensor state set " "to UNKNOWN: %s", - self.query, + "Query returned no points, sensor state set to UNKNOWN: %s", self.query, ) self.value = None else: if len(points) > 1: _LOGGER.warning( - "Query returned multiple points, only first " "one shown: %s", + "Query returned multiple points, only first one shown: %s", self.query, ) self.value = points[0].get("value") diff --git a/homeassistant/components/input_datetime/__init__.py b/homeassistant/components/input_datetime/__init__.py index 654f3547ad6..da684e03ddc 100644 --- a/homeassistant/components/input_datetime/__init__.py +++ b/homeassistant/components/input_datetime/__init__.py @@ -98,7 +98,7 @@ async def async_setup(hass, config): and not (time or dttm) ): _LOGGER.error( - "Invalid service data for %s " "input_datetime.set_datetime: %s", + "Invalid service data for %s input_datetime.set_datetime: %s", entity.entity_id, str(call.data), ) diff --git a/homeassistant/components/ios/notify.py b/homeassistant/components/ios/notify.py index 80dbad5336d..63ed6a6ee26 100644 --- a/homeassistant/components/ios/notify.py +++ b/homeassistant/components/ios/notify.py @@ -92,9 +92,9 @@ class iOSNotificationService(BaseNotificationService): if req.status_code != 201: fallback_error = req.json().get("errorMessage", "Unknown error") - fallback_message = ( - "Internal server error, " "please try again later: " "{}" - ).format(fallback_error) + fallback_message = "Internal server error, please try again later: {}".format( + fallback_error + ) message = req.json().get("message", fallback_message) if req.status_code == 429: _LOGGER.warning(message) diff --git a/homeassistant/components/isy994/binary_sensor.py b/homeassistant/components/isy994/binary_sensor.py index eed5f1a81a0..9cf1332c4f4 100644 --- a/homeassistant/components/isy994/binary_sensor.py +++ b/homeassistant/components/isy994/binary_sensor.py @@ -165,7 +165,7 @@ class ISYBinarySensorDevice(ISYDevice, BinarySensorDevice): """Handle an "On" control event from the "negative" node.""" if event == "DON": _LOGGER.debug( - "Sensor %s turning Off via the Negative node " "sending a DON command", + "Sensor %s turning Off via the Negative node sending a DON command", self.name, ) self._computed_state = False @@ -181,7 +181,7 @@ class ISYBinarySensorDevice(ISYDevice, BinarySensorDevice): """ if event == "DON": _LOGGER.debug( - "Sensor %s turning On via the Primary node " "sending a DON command", + "Sensor %s turning On via the Primary node sending a DON command", self.name, ) self._computed_state = True @@ -189,7 +189,7 @@ class ISYBinarySensorDevice(ISYDevice, BinarySensorDevice): self._heartbeat() if event == "DOF": _LOGGER.debug( - "Sensor %s turning Off via the Primary node " "sending a DOF command", + "Sensor %s turning Off via the Primary node sending a DOF command", self.name, ) self._computed_state = False diff --git a/homeassistant/components/knx/__init__.py b/homeassistant/components/knx/__init__.py index 00d5d18f013..61a497e938a 100644 --- a/homeassistant/components/knx/__init__.py +++ b/homeassistant/components/knx/__init__.py @@ -102,7 +102,7 @@ async def async_setup(hass, config): except XKNXException as ex: _LOGGER.warning("Can't connect to KNX interface: %s", ex) hass.components.persistent_notification.async_create( - "Can't connect to KNX interface:
" "{0}".format(ex), title="KNX" + "Can't connect to KNX interface:
{0}".format(ex), title="KNX" ) for component, discovery_type in ( diff --git a/homeassistant/components/kodi/media_player.py b/homeassistant/components/kodi/media_player.py index 9721ea2d31f..71418927ed2 100644 --- a/homeassistant/components/kodi/media_player.py +++ b/homeassistant/components/kodi/media_player.py @@ -811,7 +811,7 @@ class KodiDevice(MediaPlayerDevice): except jsonrpc_base.jsonrpc.TransportError: result = None _LOGGER.warning( - "TransportError trying to run API method " "%s.%s(%s)", + "TransportError trying to run API method %s.%s(%s)", self.entity_id, method, kwargs, diff --git a/homeassistant/components/lametric/notify.py b/homeassistant/components/lametric/notify.py index b8dd610b1a0..052eb3bceac 100644 --- a/homeassistant/components/lametric/notify.py +++ b/homeassistant/components/lametric/notify.py @@ -113,7 +113,7 @@ class LaMetricNotificationService(BaseNotificationService): self._devices = lmn.get_devices() except RequestsConnectionError: _LOGGER.warning( - "Problem connecting to LaMetric, " "using cached devices instead" + "Problem connecting to LaMetric, using cached devices instead" ) for dev in self._devices: if targets is None or dev["name"] in targets: diff --git a/homeassistant/components/lcn/helpers.py b/homeassistant/components/lcn/helpers.py index 236035b0400..f4545817c9f 100644 --- a/homeassistant/components/lcn/helpers.py +++ b/homeassistant/components/lcn/helpers.py @@ -9,7 +9,7 @@ from .const import DEFAULT_NAME # Regex for address validation PATTERN_ADDRESS = re.compile( - "^((?P\\w+)\\.)?s?(?P\\d+)" "\\.(?Pm|g)?(?P\\d+)$" + "^((?P\\w+)\\.)?s?(?P\\d+)\\.(?Pm|g)?(?P\\d+)$" ) diff --git a/homeassistant/components/lcn/services.py b/homeassistant/components/lcn/services.py index 3c775224623..c35a0cc00bf 100644 --- a/homeassistant/components/lcn/services.py +++ b/homeassistant/components/lcn/services.py @@ -305,7 +305,7 @@ class SendKeys(LcnServiceCall): hit = pypck.lcn_defs.SendKeyCommand.HIT if pypck.lcn_defs.SendKeyCommand[call.data[CONF_STATE]] != hit: raise ValueError( - "Only hit command is allowed when sending" " deferred keys." + "Only hit command is allowed when sending deferred keys." ) delay_unit = pypck.lcn_defs.TimeUnit.parse(call.data[CONF_TIME_UNIT]) address_connection.send_keys_hit_deferred(keys, delay_time, delay_unit) @@ -344,7 +344,7 @@ class LockKeys(LcnServiceCall): if delay_time != 0: if table_id != 0: raise ValueError( - "Only table A is allowed when locking keys" " for a specific time." + "Only table A is allowed when locking keys for a specific time." ) delay_unit = pypck.lcn_defs.TimeUnit.parse(call.data[CONF_TIME_UNIT]) address_connection.lock_keys_tab_a_temporary(delay_time, delay_unit, states) diff --git a/homeassistant/components/logi_circle/config_flow.py b/homeassistant/components/logi_circle/config_flow.py index ce8460233d6..bc585153b64 100644 --- a/homeassistant/components/logi_circle/config_flow.py +++ b/homeassistant/components/logi_circle/config_flow.py @@ -207,5 +207,5 @@ class LogiCircleAuthCallbackView(HomeAssistantView): ) return self.json_message("Authorisation code saved") return self.json_message( - "Authorisation code missing " "from query string", status_code=400 + "Authorisation code missing from query string", status_code=400 ) diff --git a/homeassistant/components/min_max/sensor.py b/homeassistant/components/min_max/sensor.py index 977ee51cd1c..80beaf1f798 100644 --- a/homeassistant/components/min_max/sensor.py +++ b/homeassistant/components/min_max/sensor.py @@ -153,7 +153,7 @@ class MinMaxSensor(Entity): self.last = float(new_state.state) except ValueError: _LOGGER.warning( - "Unable to store state. " "Only numerical states are supported" + "Unable to store state. Only numerical states are supported" ) hass.async_add_job(self.async_update_ha_state, True) diff --git a/homeassistant/components/mobile_app/notify.py b/homeassistant/components/mobile_app/notify.py index 8ac34c9af1d..b51bf235cf0 100644 --- a/homeassistant/components/mobile_app/notify.py +++ b/homeassistant/components/mobile_app/notify.py @@ -139,9 +139,9 @@ class MobileAppNotificationService(BaseNotificationService): return fallback_error = result.get("errorMessage", "Unknown error") - fallback_message = ( - "Internal server error, " "please try again later: " "{}" - ).format(fallback_error) + fallback_message = "Internal server error, please try again later: {}".format( + fallback_error + ) message = result.get("message", fallback_message) if response.status == 429: _LOGGER.warning(message) diff --git a/homeassistant/components/modbus/sensor.py b/homeassistant/components/modbus/sensor.py index 5b04a898ab9..484382983ac 100644 --- a/homeassistant/components/modbus/sensor.py +++ b/homeassistant/components/modbus/sensor.py @@ -102,7 +102,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) except KeyError: _LOGGER.error( - "Unable to detect data type for %s sensor, " "try a custom type", + "Unable to detect data type for %s sensor, try a custom type", register.get(CONF_NAME), ) continue @@ -119,7 +119,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): if register.get(CONF_COUNT) * 2 != size: _LOGGER.error( - "Structure size (%d bytes) mismatch registers count " "(%d words)", + "Structure size (%d bytes) mismatch registers count (%d words)", size, register.get(CONF_COUNT), ) diff --git a/homeassistant/components/modbus/switch.py b/homeassistant/components/modbus/switch.py index eba0c754f45..0ed33dedb57 100644 --- a/homeassistant/components/modbus/switch.py +++ b/homeassistant/components/modbus/switch.py @@ -236,7 +236,7 @@ class ModbusRegisterSwitch(ModbusCoilSwitch): self._is_on = False else: _LOGGER.error( - "Unexpected response from hub %s, slave %s " "register %s, got 0x%2x", + "Unexpected response from hub %s, slave %s register %s, got 0x%2x", self._hub.name, self._slave, self._verify_register, diff --git a/homeassistant/components/mold_indicator/sensor.py b/homeassistant/components/mold_indicator/sensor.py index 15f8b80a5ab..0d6c6f55284 100644 --- a/homeassistant/components/mold_indicator/sensor.py +++ b/homeassistant/components/mold_indicator/sensor.py @@ -110,7 +110,7 @@ class MoldIndicator(Entity): def mold_indicator_sensors_state_listener(entity, old_state, new_state): """Handle for state changes for dependent sensors.""" _LOGGER.debug( - "Sensor state change for %s that had old state %s " "and new state %s", + "Sensor state change for %s that had old state %s and new state %s", entity, old_state, new_state, @@ -188,7 +188,7 @@ class MoldIndicator(Entity): # Return an error if the sensor change its state to Unknown. if state.state == STATE_UNKNOWN: _LOGGER.error( - "Unable to parse temperature sensor %s with state:" " %s", + "Unable to parse temperature sensor %s with state: %s", state.entity_id, state.state, ) @@ -199,7 +199,7 @@ class MoldIndicator(Entity): if temp is None: _LOGGER.error( - "Unable to parse temperature sensor %s with state:" " %s", + "Unable to parse temperature sensor %s with state: %s", state.entity_id, state.state, ) @@ -211,7 +211,7 @@ class MoldIndicator(Entity): if unit == TEMP_CELSIUS: return temp _LOGGER.error( - "Temp sensor %s has unsupported unit: %s (allowed: %s, " "%s)", + "Temp sensor %s has unsupported unit: %s (allowed: %s, %s)", state.entity_id, unit, TEMP_CELSIUS, @@ -306,7 +306,7 @@ class MoldIndicator(Entity): if None in (self._dewpoint, self._calib_factor) or self._calib_factor == 0: _LOGGER.debug( - "Invalid inputs - dewpoint: %s," " calibration-factor: %s", + "Invalid inputs - dewpoint: %s, calibration-factor: %s", self._dewpoint, self._calib_factor, ) diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index d8dc584ae30..a9d5ac93ebc 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -136,10 +136,10 @@ def valid_topic(value: Any) -> str: raise vol.Invalid("MQTT topic name/filter must not be empty.") if len(raw_value) > 65535: raise vol.Invalid( - "MQTT topic name/filter must not be longer than " "65535 encoded bytes." + "MQTT topic name/filter must not be longer than 65535 encoded bytes." ) if "\0" in value: - raise vol.Invalid("MQTT topic name/filter must not contain null " "character.") + raise vol.Invalid("MQTT topic name/filter must not contain null character.") return value @@ -151,7 +151,7 @@ def valid_subscribe_topic(value: Any) -> str: i < len(value) - 1 and value[i + 1] != "/" ): raise vol.Invalid( - "Single-level wildcard must occupy an entire " "level of the filter" + "Single-level wildcard must occupy an entire level of the filter" ) index = value.find("#") @@ -164,7 +164,7 @@ def valid_subscribe_topic(value: Any) -> str: ) if len(value) > 1 and value[index - 1] != "/": raise vol.Invalid( - "Multi-level wildcard must be after a topic " "level separator." + "Multi-level wildcard must be after a topic level separator." ) return value diff --git a/homeassistant/components/nest/__init__.py b/homeassistant/components/nest/__init__.py index e2a1479595e..73a28aa121f 100644 --- a/homeassistant/components/nest/__init__.py +++ b/homeassistant/components/nest/__init__.py @@ -216,7 +216,7 @@ async def async_setup_entry(hass, entry): structure.set_eta(trip_id, eta_begin, eta_end) else: _LOGGER.info( - "No thermostats found in structure: %s, " "unable to set ETA", + "No thermostats found in structure: %s, unable to set ETA", structure.name, ) diff --git a/homeassistant/components/nissan_leaf/__init__.py b/homeassistant/components/nissan_leaf/__init__.py index e5b4f34812a..fba84c936f5 100644 --- a/homeassistant/components/nissan_leaf/__init__.py +++ b/homeassistant/components/nissan_leaf/__init__.py @@ -124,9 +124,7 @@ def setup(hass, config): # for the charging request to reach the car. result = await hass.async_add_executor_job(data_store.leaf.start_charging) if result: - _LOGGER.debug( - "Start charging sent, " "request updated data in 1 minute" - ) + _LOGGER.debug("Start charging sent, request updated data in 1 minute") check_charge_at = utcnow() + timedelta(minutes=1) data_store.next_update = check_charge_at async_track_point_in_utc_time( @@ -414,7 +412,7 @@ class LeafDataStore: for attempt in range(MAX_RESPONSE_ATTEMPTS): if attempt > 0: _LOGGER.debug( - "Climate data not in yet (%s) (%s). " "Waiting (%s) seconds", + "Climate data not in yet (%s) (%s). Waiting (%s) seconds", self.leaf.vin, attempt, PYCARWINGS2_SLEEP, diff --git a/homeassistant/components/nut/sensor.py b/homeassistant/components/nut/sensor.py index 34e3bfaf086..bdf0eaafc99 100644 --- a/homeassistant/components/nut/sensor.py +++ b/homeassistant/components/nut/sensor.py @@ -189,7 +189,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): data.update(no_throttle=True) except data.pynuterror as err: _LOGGER.error( - "Failure while testing NUT status retrieval. " "Cannot continue setup: %s", + "Failure while testing NUT status retrieval. Cannot continue setup: %s", err, ) raise PlatformNotReady diff --git a/homeassistant/components/ohmconnect/sensor.py b/homeassistant/components/ohmconnect/sensor.py index a9606e25bad..490ebbe75b3 100644 --- a/homeassistant/components/ohmconnect/sensor.py +++ b/homeassistant/components/ohmconnect/sensor.py @@ -66,9 +66,7 @@ class OhmconnectSensor(Entity): def update(self): """Get the latest data from OhmConnect.""" try: - url = ("https://login.ohmconnect.com" "/verify-ohm-hour/{}").format( - self._ohmid - ) + url = "https://login.ohmconnect.com/verify-ohm-hour/{}".format(self._ohmid) response = requests.get(url, timeout=10) root = ET.fromstring(response.text) diff --git a/homeassistant/components/opensky/sensor.py b/homeassistant/components/opensky/sensor.py index cef99902d23..d916d9f7f29 100644 --- a/homeassistant/components/opensky/sensor.py +++ b/homeassistant/components/opensky/sensor.py @@ -40,7 +40,7 @@ EVENT_OPENSKY_EXIT = f"{DOMAIN}_exit" SCAN_INTERVAL = timedelta(seconds=12) # opensky public limit is 10 seconds OPENSKY_ATTRIBUTION = ( - "Information provided by the OpenSky Network " "(https://opensky-network.org)" + "Information provided by the OpenSky Network (https://opensky-network.org)" ) OPENSKY_API_URL = "https://opensky-network.org/api/states/all" OPENSKY_API_FIELDS = [ diff --git a/homeassistant/components/openweathermap/weather.py b/homeassistant/components/openweathermap/weather.py index 69ca965d660..ce8676ad440 100644 --- a/homeassistant/components/openweathermap/weather.py +++ b/homeassistant/components/openweathermap/weather.py @@ -272,7 +272,7 @@ class WeatherData: self.latitude, self.longitude ) except APICallError: - _LOGGER.error("Exception when calling OWM web API " "to update forecast") + _LOGGER.error("Exception when calling OWM web API to update forecast") return if fcd is None: diff --git a/homeassistant/components/owlet/__init__.py b/homeassistant/components/owlet/__init__.py index afde50cae49..3882ba4bf7d 100644 --- a/homeassistant/components/owlet/__init__.py +++ b/homeassistant/components/owlet/__init__.py @@ -51,7 +51,7 @@ def setup(hass, config): device = PyOwlet(username, password) except KeyError: _LOGGER.error( - "Owlet authentication failed. Please verify your " "credentials are correct" + "Owlet authentication failed. Please verify your credentials are correct" ) return False diff --git a/homeassistant/components/owntracks/__init__.py b/homeassistant/components/owntracks/__init__.py index b75be465aa1..71494e9e805 100644 --- a/homeassistant/components/owntracks/__init__.py +++ b/homeassistant/components/owntracks/__init__.py @@ -233,7 +233,7 @@ class OwnTracksContext: if self.max_gps_accuracy is not None and acc > self.max_gps_accuracy: _LOGGER.info( - "Ignoring %s update because expected GPS " "accuracy %s is not met: %s", + "Ignoring %s update because expected GPS accuracy %s is not met: %s", message["_type"], self.max_gps_accuracy, message, diff --git a/homeassistant/components/prowl/notify.py b/homeassistant/components/prowl/notify.py index 9690e748887..d5167ebfdc9 100644 --- a/homeassistant/components/prowl/notify.py +++ b/homeassistant/components/prowl/notify.py @@ -59,7 +59,7 @@ class ProwlNotificationService(BaseNotificationService): if response.status != 200 or "error" in result: _LOGGER.error( - "Prowl service returned http " "status %d, response %s", + "Prowl service returned http status %d, response %s", response.status, result, ) diff --git a/homeassistant/components/proximity/__init__.py b/homeassistant/components/proximity/__init__.py index 45a1c19c29e..7e5f6436757 100644 --- a/homeassistant/components/proximity/__init__.py +++ b/homeassistant/components/proximity/__init__.py @@ -268,7 +268,7 @@ class Proximity(Entity): self.nearest = entity_name self.schedule_update_ha_state() _LOGGER.debug( - "proximity.%s update entity: distance=%s: direction=%s: " "device=%s", + "proximity.%s update entity: distance=%s: direction=%s: device=%s", self.friendly_name, round(dist_to_zone), direction_of_travel, diff --git a/homeassistant/components/python_script/__init__.py b/homeassistant/components/python_script/__init__.py index ddae8a81db1..0c5886e177c 100644 --- a/homeassistant/components/python_script/__init__.py +++ b/homeassistant/components/python_script/__init__.py @@ -225,7 +225,7 @@ class TimeWrapper: if not TimeWrapper.warned: TimeWrapper.warned = True _LOGGER.warning( - "Using time.sleep can reduce the performance of " "Home Assistant" + "Using time.sleep can reduce the performance of Home Assistant" ) time.sleep(*args, **kwargs) diff --git a/homeassistant/components/quantum_gateway/device_tracker.py b/homeassistant/components/quantum_gateway/device_tracker.py index 97eb8eedfd3..58151fa02ce 100644 --- a/homeassistant/components/quantum_gateway/device_tracker.py +++ b/homeassistant/components/quantum_gateway/device_tracker.py @@ -54,7 +54,7 @@ class QuantumGatewayDeviceScanner(DeviceScanner): _LOGGER.error("Unable to connect to gateway. Check host.") if not self.success_init: - _LOGGER.error("Unable to login to gateway. Check password and " "host.") + _LOGGER.error("Unable to login to gateway. Check password and host.") def scan_devices(self): """Scan for new devices and return a list of found MACs.""" diff --git a/homeassistant/components/recorder/__init__.py b/homeassistant/components/recorder/__init__.py index 7ae1cb1a220..ab56a5fc33b 100644 --- a/homeassistant/components/recorder/__init__.py +++ b/homeassistant/components/recorder/__init__.py @@ -228,7 +228,7 @@ class Recorder(threading.Thread): _LOGGER.debug("Connected to recorder database") except Exception as err: # pylint: disable=broad-except _LOGGER.error( - "Error during connection setup: %s (retrying " "in %s seconds)", + "Error during connection setup: %s (retrying in %s seconds)", err, CONNECT_RETRY_WAIT, ) diff --git a/homeassistant/components/remember_the_milk/__init__.py b/homeassistant/components/remember_the_milk/__init__.py index fdfbdfd5cdc..02875cb8aa9 100644 --- a/homeassistant/components/remember_the_milk/__init__.py +++ b/homeassistant/components/remember_the_milk/__init__.py @@ -166,7 +166,7 @@ class RememberTheMilkConfiguration: self._config = json.load(config_file) except ValueError: _LOGGER.error( - "Failed to load configuration file, creating a " "new one: %s", + "Failed to load configuration file, creating a new one: %s", self._config_file_path, ) self._config = dict() @@ -258,7 +258,7 @@ class RememberTheMilk(Entity): valid = self._rtm_api.token_valid() if not valid: _LOGGER.error( - "Token for account %s is invalid. You need to " "register again!", + "Token for account %s is invalid. You need to register again!", self.name, ) self._rtm_config.delete_token(self._name) @@ -306,14 +306,14 @@ class RememberTheMilk(Entity): timeline=timeline, ) _LOGGER.debug( - "Updated task with id '%s' in account " "%s to name %s", + "Updated task with id '%s' in account %s to name %s", hass_id, self.name, task_name, ) except RtmRequestFailedException as rtm_exception: _LOGGER.error( - "Error creating new Remember The Milk task for " "account %s: %s", + "Error creating new Remember The Milk task for account %s: %s", self._name, rtm_exception, ) @@ -347,7 +347,7 @@ class RememberTheMilk(Entity): ) except RtmRequestFailedException as rtm_exception: _LOGGER.error( - "Error creating new Remember The Milk task for " "account %s: %s", + "Error creating new Remember The Milk task for account %s: %s", self._name, rtm_exception, ) diff --git a/homeassistant/components/satel_integra/__init__.py b/homeassistant/components/satel_integra/__init__.py index 1972eefd6b5..84bb3b570d8 100644 --- a/homeassistant/components/satel_integra/__init__.py +++ b/homeassistant/components/satel_integra/__init__.py @@ -62,9 +62,7 @@ PARTITION_SCHEMA = vol.Schema( def is_alarm_code_necessary(value): """Check if alarm code must be configured.""" if value.get(CONF_SWITCHABLE_OUTPUTS) and CONF_DEVICE_CODE not in value: - raise vol.Invalid( - "You need to specify alarm " " code to use switchable_outputs" - ) + raise vol.Invalid("You need to specify alarm code to use switchable_outputs") return value diff --git a/homeassistant/components/satel_integra/switch.py b/homeassistant/components/satel_integra/switch.py index c20f30cf871..9233b3d152d 100644 --- a/homeassistant/components/satel_integra/switch.py +++ b/homeassistant/components/satel_integra/switch.py @@ -69,14 +69,14 @@ class SatelIntegraSwitch(SwitchDevice): async def async_turn_on(self, **kwargs): """Turn the device on.""" - _LOGGER.debug("Switch: %s status: %s," " turning on", self._name, self._state) + _LOGGER.debug("Switch: %s status: %s, turning on", self._name, self._state) await self._satel.set_output(self._code, self._device_number, True) self.async_schedule_update_ha_state() async def async_turn_off(self, **kwargs): """Turn the device off.""" _LOGGER.debug( - "Switch name: %s status: %s," " turning off", self._name, self._state + "Switch name: %s status: %s, turning off", self._name, self._state ) await self._satel.set_output(self._code, self._device_number, False) self.async_schedule_update_ha_state() diff --git a/homeassistant/components/slide/__init__.py b/homeassistant/components/slide/__init__.py index 49e50e601dd..ccf4465577b 100644 --- a/homeassistant/components/slide/__init__.py +++ b/homeassistant/components/slide/__init__.py @@ -60,8 +60,7 @@ async def async_setup(hass, config): for slide in result: if "device_id" not in slide: _LOGGER.error( - "Found invalid Slide entry, device_id is " "missing. Entry=%s", - slide, + "Found invalid Slide entry, device_id is missing. Entry=%s", slide, ) continue @@ -104,7 +103,7 @@ async def async_setup(hass, config): ) elif "code" in slide["device_info"]: _LOGGER.warning( - "Slide %s (%s) is offline with " "code=%s", + "Slide %s (%s) is offline with code=%s", slide["id"], slidenew["mac"], slide["device_info"]["code"], diff --git a/homeassistant/components/smartthings/smartapp.py b/homeassistant/components/smartthings/smartapp.py index 74feb93eec4..d0487290926 100644 --- a/homeassistant/components/smartthings/smartapp.py +++ b/homeassistant/components/smartthings/smartapp.py @@ -339,7 +339,7 @@ async def smartapp_sync_subscriptions( ) except Exception as error: # pylint:disable=broad-except _LOGGER.error( - "Failed to remove subscription for '%s' under app " "'%s': %s", + "Failed to remove subscription for '%s' under app '%s': %s", sub.capability, installed_app_id, error, diff --git a/homeassistant/components/spotify/media_player.py b/homeassistant/components/spotify/media_player.py index ec21a5d7822..ba0c725eb7f 100644 --- a/homeassistant/components/spotify/media_player.py +++ b/homeassistant/components/spotify/media_player.py @@ -37,7 +37,7 @@ CONF_CLIENT_ID = "client_id" CONF_CLIENT_SECRET = "client_secret" CONFIGURATOR_DESCRIPTION = ( - "To link your Spotify account, " "click the link, login, and authorize:" + "To link your Spotify account, click the link, login, and authorize:" ) CONFIGURATOR_LINK_NAME = "Link Spotify account" CONFIGURATOR_SUBMIT_CAPTION = "I authorized successfully" diff --git a/homeassistant/components/swiss_hydrological_data/sensor.py b/homeassistant/components/swiss_hydrological_data/sensor.py index c8e7b9d6fc2..d4624e82bb7 100644 --- a/homeassistant/components/swiss_hydrological_data/sensor.py +++ b/homeassistant/components/swiss_hydrological_data/sensor.py @@ -13,7 +13,7 @@ from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) -ATTRIBUTION = "Data provided by the Swiss Federal Office for the " "Environment FOEN" +ATTRIBUTION = "Data provided by the Swiss Federal Office for the Environment FOEN" ATTR_DELTA_24H = "delta-24h" ATTR_MAX_1H = "max-1h" diff --git a/homeassistant/components/tado/device_tracker.py b/homeassistant/components/tado/device_tracker.py index c63f5061dfa..ea797754da8 100644 --- a/homeassistant/components/tado/device_tracker.py +++ b/homeassistant/components/tado/device_tracker.py @@ -60,9 +60,7 @@ class TadoDeviceScanner(DeviceScanner): if self.home_id is None: self.tadoapiurl = "https://my.tado.com/api/v2/me" else: - self.tadoapiurl = ( - "https://my.tado.com/api/v2" "/homes/{home_id}/mobileDevices" - ) + self.tadoapiurl = "https://my.tado.com/api/v2/homes/{home_id}/mobileDevices" # The API URL always needs a username and password self.tadoapiurl += "?username={username}&password={password}" diff --git a/homeassistant/components/telegram_bot/__init__.py b/homeassistant/components/telegram_bot/__init__.py index b91c37b35de..fc37121f3f9 100644 --- a/homeassistant/components/telegram_bot/__init__.py +++ b/homeassistant/components/telegram_bot/__init__.py @@ -628,7 +628,7 @@ class TelegramNotificationService: """Answer a callback originated with a press in an inline keyboard.""" params = self._get_msg_kwargs(kwargs) _LOGGER.debug( - "Answer callback query with callback ID %s: %s, " "alert: %s.", + "Answer callback query with callback ID %s: %s, alert: %s.", callback_query_id, message, show_alert, diff --git a/homeassistant/components/template/binary_sensor.py b/homeassistant/components/template/binary_sensor.py index 3ca25a33d64..7de43ea0702 100644 --- a/homeassistant/components/template/binary_sensor.py +++ b/homeassistant/components/template/binary_sensor.py @@ -223,7 +223,7 @@ class BinarySensorTemplate(BinarySensorDevice): ): # Common during HA startup - so just a warning _LOGGER.warning( - "Could not render template %s, " "the state is unknown", self._name + "Could not render template %s, the state is unknown", self._name ) return _LOGGER.error("Could not render template %s: %s", self._name, ex) @@ -259,7 +259,7 @@ class BinarySensorTemplate(BinarySensorDevice): ): # Common during HA startup - so just a warning _LOGGER.warning( - "Could not render %s template %s," " the state is unknown.", + "Could not render %s template %s, the state is unknown.", friendly_property_name, self._name, ) diff --git a/homeassistant/components/template/cover.py b/homeassistant/components/template/cover.py index c55c3f97df5..f6678067d70 100644 --- a/homeassistant/components/template/cover.py +++ b/homeassistant/components/template/cover.py @@ -437,8 +437,7 @@ class CoverTemplate(CoverDevice): 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 @@ -466,7 +465,7 @@ class CoverTemplate(CoverDevice): ): # Common during HA startup - so just a warning _LOGGER.warning( - "Could not render %s template %s," " the state is unknown.", + "Could not render %s template %s, the state is unknown.", friendly_property_name, self._name, ) diff --git a/homeassistant/components/template/light.py b/homeassistant/components/template/light.py index e18833aae39..f4682fa903d 100644 --- a/homeassistant/components/template/light.py +++ b/homeassistant/components/template/light.py @@ -320,7 +320,7 @@ class LightTemplate(Light): ): # Common during HA startup - so just a warning _LOGGER.warning( - "Could not render %s template %s," " the state is unknown.", + "Could not render %s template %s, the state is unknown.", friendly_property_name, self._name, ) diff --git a/homeassistant/components/template/sensor.py b/homeassistant/components/template/sensor.py index a4e28265e1d..0ca5571515a 100644 --- a/homeassistant/components/template/sensor.py +++ b/homeassistant/components/template/sensor.py @@ -230,7 +230,7 @@ class SensorTemplate(Entity): ): # Common during HA startup - so just a warning _LOGGER.warning( - "Could not render template %s," " the state is unknown.", self._name + "Could not render template %s, the state is unknown.", self._name ) else: self._state = None @@ -268,7 +268,7 @@ class SensorTemplate(Entity): ): # Common during HA startup - so just a warning _LOGGER.warning( - "Could not render %s template %s," " the state is unknown.", + "Could not render %s template %s, the state is unknown.", friendly_property_name, self._name, ) diff --git a/homeassistant/components/template/switch.py b/homeassistant/components/template/switch.py index f44f7256e19..c2d8e8158c1 100644 --- a/homeassistant/components/template/switch.py +++ b/homeassistant/components/template/switch.py @@ -233,7 +233,7 @@ class SwitchTemplate(SwitchDevice): ): # Common during HA startup - so just a warning _LOGGER.warning( - "Could not render %s template %s," " the state is unknown.", + "Could not render %s template %s, the state is unknown.", friendly_property_name, self._name, ) diff --git a/homeassistant/components/tomato/device_tracker.py b/homeassistant/components/tomato/device_tracker.py index d53b5ab6cf0..5a5f1b1985b 100644 --- a/homeassistant/components/tomato/device_tracker.py +++ b/homeassistant/components/tomato/device_tracker.py @@ -124,7 +124,7 @@ class TomatoDeviceScanner(DeviceScanner): # We get this if we could not connect to the router or # an invalid http_id was supplied. _LOGGER.exception( - "Failed to connect to the router or " "invalid http_id supplied" + "Failed to connect to the router or invalid http_id supplied" ) return False diff --git a/homeassistant/components/totalconnect/alarm_control_panel.py b/homeassistant/components/totalconnect/alarm_control_panel.py index b8b4236806f..ed77fc4eea0 100644 --- a/homeassistant/components/totalconnect/alarm_control_panel.py +++ b/homeassistant/components/totalconnect/alarm_control_panel.py @@ -119,7 +119,7 @@ class TotalConnectAlarm(alarm.AlarmControlPanel): attr["triggered_source"] = "Carbon Monoxide" else: logging.info( - "Total Connect Client returned unknown " "status code: %s", status + "Total Connect Client returned unknown status code: %s", status ) state = None diff --git a/homeassistant/components/uscis/sensor.py b/homeassistant/components/uscis/sensor.py index 6f94d5c38b0..12e84a9dbf8 100644 --- a/homeassistant/components/uscis/sensor.py +++ b/homeassistant/components/uscis/sensor.py @@ -30,7 +30,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): if uscis.valid_case_id: add_entities([uscis]) else: - _LOGGER.error("Setup USCIS Sensor Fail" " check if your Case ID is Valid") + _LOGGER.error("Setup USCIS Sensor Fail check if your Case ID is Valid") class UscisSensor(Entity): diff --git a/homeassistant/components/wink/__init__.py b/homeassistant/components/wink/__init__.py index b3ae01c8f67..b71d44206c8 100644 --- a/homeassistant/components/wink/__init__.py +++ b/homeassistant/components/wink/__init__.py @@ -740,7 +740,7 @@ class WinkDevice(Entity): try: if message is None: _LOGGER.error( - "Error on pubnub update for %s " "polling API for current state", + "Error on pubnub update for %s polling API for current state", self.name, ) self.schedule_update_ha_state(True) @@ -749,8 +749,7 @@ class WinkDevice(Entity): self.schedule_update_ha_state() except (ValueError, KeyError, AttributeError): _LOGGER.error( - "Error in pubnub JSON for %s " "polling API for current state", - self.name, + "Error in pubnub JSON for %s polling API for current state", self.name, ) self.schedule_update_ha_state(True) diff --git a/homeassistant/components/wirelesstag/__init__.py b/homeassistant/components/wirelesstag/__init__.py index 1bc971f1372..c0a30a8867f 100644 --- a/homeassistant/components/wirelesstag/__init__.py +++ b/homeassistant/components/wirelesstag/__init__.py @@ -199,7 +199,7 @@ def setup(hass, config): except (ConnectTimeout, HTTPError, WirelessTagsException) as ex: _LOGGER.error("Unable to connect to wirelesstag.net service: %s", str(ex)) hass.components.persistent_notification.create( - "Error: {}
" "Please restart hass after fixing this." "".format(ex), + "Error: {}
Please restart hass after fixing this.".format(ex), title=NOTIFICATION_TITLE, notification_id=NOTIFICATION_ID, ) diff --git a/homeassistant/components/wunderground/sensor.py b/homeassistant/components/wunderground/sensor.py index cc71e71a1d0..5d3bf1f74b8 100644 --- a/homeassistant/components/wunderground/sensor.py +++ b/homeassistant/components/wunderground/sensor.py @@ -1012,7 +1012,7 @@ class WUndergroundSensor(Entity): val = val(self.rest) except (KeyError, IndexError, TypeError, ValueError) as err: _LOGGER.warning( - "Failed to expand cfg from WU API." " Condition: %s Attr: %s Error: %s", + "Failed to expand cfg from WU API. Condition: %s Attr: %s Error: %s", self._condition, what, repr(err), diff --git a/homeassistant/components/xfinity/device_tracker.py b/homeassistant/components/xfinity/device_tracker.py index 524929ae42d..20e13682979 100644 --- a/homeassistant/components/xfinity/device_tracker.py +++ b/homeassistant/components/xfinity/device_tracker.py @@ -32,7 +32,7 @@ def get_scanner(hass, config): scanner = XfinityDeviceScanner(gateway) except (RequestException, ValueError): _LOGGER.error( - "Error communicating with Xfinity Gateway. " "Check host: %s", gateway.host + "Error communicating with Xfinity Gateway. Check host: %s", gateway.host ) return scanner @@ -51,7 +51,7 @@ class XfinityDeviceScanner(DeviceScanner): try: connected_devices = self.gateway.scan_devices() except (RequestException, ValueError): - _LOGGER.error("Unable to scan devices. " "Check connection to gateway") + _LOGGER.error("Unable to scan devices. Check connection to gateway") return connected_devices def get_device_name(self, device): diff --git a/homeassistant/components/xiaomi_miio/light.py b/homeassistant/components/xiaomi_miio/light.py index 5a7b743b362..bcc83bae454 100644 --- a/homeassistant/components/xiaomi_miio/light.py +++ b/homeassistant/components/xiaomi_miio/light.py @@ -467,7 +467,7 @@ class XiaomiPhilipsBulb(XiaomiPhilipsGenericLight): ) result = await self._try_command( - "Setting brightness and color temperature failed: " "%s bri, %s cct", + "Setting brightness and color temperature failed: %s bri, %s cct", self._light.set_brightness_and_color_temperature, percent_brightness, percent_color_temp, @@ -479,7 +479,7 @@ class XiaomiPhilipsBulb(XiaomiPhilipsGenericLight): elif ATTR_COLOR_TEMP in kwargs: _LOGGER.debug( - "Setting color temperature: " "%s mireds, %s%% cct", + "Setting color temperature: %s mireds, %s%% cct", color_temp, percent_color_temp, ) @@ -825,14 +825,14 @@ class XiaomiPhilipsMoonlightLamp(XiaomiPhilipsBulb): if ATTR_BRIGHTNESS in kwargs and ATTR_HS_COLOR in kwargs: _LOGGER.debug( - "Setting brightness and color: " "%s %s%%, %s", + "Setting brightness and color: %s %s%%, %s", brightness, percent_brightness, rgb, ) result = await self._try_command( - "Setting brightness and color failed: " "%s bri, %s color", + "Setting brightness and color failed: %s bri, %s color", self._light.set_brightness_and_rgb, percent_brightness, rgb, @@ -853,7 +853,7 @@ class XiaomiPhilipsMoonlightLamp(XiaomiPhilipsBulb): ) result = await self._try_command( - "Setting brightness and color temperature failed: " "%s bri, %s cct", + "Setting brightness and color temperature failed: %s bri, %s cct", self._light.set_brightness_and_color_temperature, percent_brightness, percent_color_temp, @@ -875,7 +875,7 @@ class XiaomiPhilipsMoonlightLamp(XiaomiPhilipsBulb): elif ATTR_COLOR_TEMP in kwargs: _LOGGER.debug( - "Setting color temperature: " "%s mireds, %s%% cct", + "Setting color temperature: %s mireds, %s%% cct", color_temp, percent_color_temp, ) diff --git a/homeassistant/components/xiaomi_miio/vacuum.py b/homeassistant/components/xiaomi_miio/vacuum.py index bc703c769a5..4ef34e8ff56 100644 --- a/homeassistant/components/xiaomi_miio/vacuum.py +++ b/homeassistant/components/xiaomi_miio/vacuum.py @@ -379,7 +379,7 @@ class MiroboVacuum(StateVacuumDevice): fan_speed = int(fan_speed) except ValueError as exc: _LOGGER.error( - "Fan speed step not recognized (%s). " "Valid speeds are: %s", + "Fan speed step not recognized (%s). Valid speeds are: %s", exc, self.fan_speed_list, ) diff --git a/homeassistant/components/xmpp/notify.py b/homeassistant/components/xmpp/notify.py index d26b1eed151..28d42698657 100644 --- a/homeassistant/components/xmpp/notify.py +++ b/homeassistant/components/xmpp/notify.py @@ -201,7 +201,7 @@ async def async_send_message( except FileTooBig as ex: _LOGGER.error("File too big for server, could not upload file %s", ex) except UploadServiceNotFound as ex: - _LOGGER.error("UploadServiceNotFound: " " could not upload file %s", ex) + _LOGGER.error("UploadServiceNotFound, could not upload file %s", ex) except FileUploadError as ex: _LOGGER.error("FileUploadError, could not upload file %s", ex) except requests.exceptions.SSLError as ex: diff --git a/homeassistant/components/xs1/__init__.py b/homeassistant/components/xs1/__init__.py index aeb6204265b..1fbcb49d0c9 100644 --- a/homeassistant/components/xs1/__init__.py +++ b/homeassistant/components/xs1/__init__.py @@ -63,8 +63,7 @@ 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/yeelight/light.py b/homeassistant/components/yeelight/light.py index 0039755a6af..c40ead2a892 100644 --- a/homeassistant/components/yeelight/light.py +++ b/homeassistant/components/yeelight/light.py @@ -298,7 +298,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): else: _lights_setup_helper(YeelightGenericLight) _LOGGER.warning( - "Cannot determine device type for %s, %s. " "Falling back to white only", + "Cannot determine device type for %s, %s. Falling back to white only", device.ipaddr, device.name, ) @@ -743,7 +743,7 @@ class YeelightGenericLight(Light): self.set_music_mode(self.config[CONF_MODE_MUSIC]) except BulbException as ex: _LOGGER.error( - "Unable to turn on music mode," "consider disabling it: %s", ex + "Unable to turn on music mode, consider disabling it: %s", ex ) try: diff --git a/homeassistant/components/yr/sensor.py b/homeassistant/components/yr/sensor.py index f8fbc97962f..c9392561fc8 100644 --- a/homeassistant/components/yr/sensor.py +++ b/homeassistant/components/yr/sensor.py @@ -160,7 +160,7 @@ class YrData: def __init__(self, hass, coordinates, forecast, devices): """Initialize the data object.""" self._url = ( - "https://aa015h6buqvih86i1.api.met.no/" "weatherapi/locationforecast/1.9/" + "https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/1.9/" ) self._urlparams = coordinates self._forecast = forecast diff --git a/homeassistant/components/zigbee/__init__.py b/homeassistant/components/zigbee/__init__.py index d63a713045b..475d63a5c3b 100644 --- a/homeassistant/components/zigbee/__init__.py +++ b/homeassistant/components/zigbee/__init__.py @@ -335,7 +335,7 @@ class ZigBeeDigitalIn(Entity): pin_name = DIGITAL_PINS[self._config.pin] if pin_name not in sample: _LOGGER.warning( - "Pin %s (%s) was not in the sample provided by Zigbee device " "%s.", + "Pin %s (%s) was not in the sample provided by Zigbee device %s.", self._config.pin, pin_name, hexlify(self._config.address), diff --git a/homeassistant/components/zwave/__init__.py b/homeassistant/components/zwave/__init__.py index cb494b5fa6f..32348a8becc 100644 --- a/homeassistant/components/zwave/__init__.py +++ b/homeassistant/components/zwave/__init__.py @@ -275,7 +275,7 @@ def nice_print_node(node): value_id: _obj_to_dict(value) for value_id, value in node.values.items() } - _LOGGER.info("FOUND NODE %s \n" "%s", node.product_name, node_dict) + _LOGGER.info("FOUND NODE %s \n%s", node.product_name, node_dict) def get_config_value(node, value_index, tries=5): @@ -476,7 +476,7 @@ async def async_setup_entry(hass, config_entry): @callback def _on_timeout(sec): _LOGGER.warning( - "Z-Wave node %d not ready after %d seconds, " "continuing anyway", + "Z-Wave node %d not ready after %d seconds, continuing anyway", entity.node_id, sec, ) @@ -526,7 +526,7 @@ async def async_setup_entry(hass, config_entry): def network_complete(): """Handle the querying of all nodes on network.""" _LOGGER.info( - "Z-Wave network is complete. All nodes on the network " "have been queried" + "Z-Wave network is complete. All nodes on the network have been queried" ) hass.bus.fire(const.EVENT_NETWORK_COMPLETE) @@ -684,7 +684,7 @@ async def async_setup_entry(hass, config_entry): if value.type == const.TYPE_BOOL: value.data = int(selection == "True") _LOGGER.info( - "Setting config parameter %s on Node %s " "with bool selection %s", + "Setting config parameter %s on Node %s with bool selection %s", param, node_id, str(selection), @@ -693,7 +693,7 @@ async def async_setup_entry(hass, config_entry): if value.type == const.TYPE_LIST: value.data = str(selection) _LOGGER.info( - "Setting config parameter %s on Node %s " "with list selection %s", + "Setting config parameter %s on Node %s with list selection %s", param, node_id, str(selection), @@ -712,7 +712,7 @@ async def async_setup_entry(hass, config_entry): return value.data = int(selection) _LOGGER.info( - "Setting config parameter %s on Node %s " "with selection %s", + "Setting config parameter %s on Node %s with selection %s", param, node_id, selection, @@ -720,7 +720,7 @@ async def async_setup_entry(hass, config_entry): return node.set_config_param(param, selection, size) _LOGGER.info( - "Setting unknown config parameter %s on Node %s " "with selection %s", + "Setting unknown config parameter %s on Node %s with selection %s", param, node_id, selection, @@ -831,7 +831,7 @@ async def async_setup_entry(hass, config_entry): ) return _LOGGER.info( - "Node %s on instance %s does not have resettable " "meters.", + "Node %s on instance %s does not have resettable meters.", node_id, instance, ) diff --git a/homeassistant/components/zwave/lock.py b/homeassistant/components/zwave/lock.py index 9d7b2bffddd..f84b1b5cfd4 100644 --- a/homeassistant/components/zwave/lock.py +++ b/homeassistant/components/zwave/lock.py @@ -270,7 +270,7 @@ class ZwaveLock(ZWaveDeviceEntity, LockDevice): workaround = DEVICE_MAPPINGS[specific_sensor_key] if workaround & WORKAROUND_V2BTZE: self._v2btze = 1 - _LOGGER.debug("Polycontrol Danalock v2 BTZE " "workaround enabled") + _LOGGER.debug("Polycontrol Danalock v2 BTZE workaround enabled") if workaround & WORKAROUND_DEVICE_STATE: self._state_workaround = True _LOGGER.debug("Notification device state workaround enabled") @@ -299,7 +299,7 @@ class ZwaveLock(ZWaveDeviceEntity, LockDevice): ): self._state = LOCK_STATUS.get(str(notification_data)) _LOGGER.debug( - "Lock state set from Access Control value and is %s, " "get=%s", + "Lock state set from Access Control value and is %s, get=%s", str(notification_data), self.state, ) diff --git a/homeassistant/config.py b/homeassistant/config.py index c3a97a1184c..ee3ccc15f81 100644 --- a/homeassistant/config.py +++ b/homeassistant/config.py @@ -209,7 +209,7 @@ CORE_CONFIG_SCHEMA = CUSTOMIZE_CONFIG_SCHEMA.extend( { CONF_TYPE: vol.NotIn( ["insecure_example"], - "The insecure_example mfa module" " is for testing only.", + "The insecure_example mfa module is for testing only.", ) } ) diff --git a/homeassistant/helpers/condition.py b/homeassistant/helpers/condition.py index c02c49ce311..02853f7615b 100644 --- a/homeassistant/helpers/condition.py +++ b/homeassistant/helpers/condition.py @@ -192,7 +192,7 @@ def async_numeric_state( fvalue = float(value) except ValueError: _LOGGER.warning( - "Value cannot be processed as a number: %s " "(Offending entity: %s)", + "Value cannot be processed as a number: %s (Offending entity: %s)", entity, value, ) diff --git a/homeassistant/helpers/config_validation.py b/homeassistant/helpers/config_validation.py index 035e1f678bf..bcf0d42df70 100644 --- a/homeassistant/helpers/config_validation.py +++ b/homeassistant/helpers/config_validation.py @@ -544,7 +544,7 @@ def socket_timeout(value: Optional[Any]) -> object: float_value = float(value) if float_value > 0.0: return float_value - raise vol.Invalid("Invalid socket timeout value." " float > 0.0 required.") + raise vol.Invalid("Invalid socket timeout value. float > 0.0 required.") except Exception as _: raise vol.Invalid("Invalid socket timeout: {err}".format(err=_)) diff --git a/homeassistant/helpers/entity_platform.py b/homeassistant/helpers/entity_platform.py index 5fd88729f08..9b82eb76dec 100644 --- a/homeassistant/helpers/entity_platform.py +++ b/homeassistant/helpers/entity_platform.py @@ -459,7 +459,7 @@ class EntityPlatform: self._process_updates = asyncio.Lock() if self._process_updates.locked(): self.logger.warning( - "Updating %s %s took longer than the scheduled update " "interval %s", + "Updating %s %s took longer than the scheduled update interval %s", self.platform_name, self.domain, self.scan_interval, diff --git a/homeassistant/helpers/template.py b/homeassistant/helpers/template.py index 4bdee750034..b27120e1825 100644 --- a/homeassistant/helpers/template.py +++ b/homeassistant/helpers/template.py @@ -615,7 +615,7 @@ def distance(hass, *args): if latitude is None or longitude is None: _LOGGER.warning( - "Distance:Unable to process latitude and " "longitude: %s, %s", + "Distance:Unable to process latitude and longitude: %s, %s", value, value_2, ) diff --git a/homeassistant/loader.py b/homeassistant/loader.py index de05c944aaf..a14a5209840 100644 --- a/homeassistant/loader.py +++ b/homeassistant/loader.py @@ -407,7 +407,7 @@ def _load_file( if str(err) not in white_listed_errors: _LOGGER.exception( - ("Error loading %s. Make sure all " "dependencies are installed"), + ("Error loading %s. Make sure all dependencies are installed"), path, ) diff --git a/homeassistant/scripts/ensure_config.py b/homeassistant/scripts/ensure_config.py index cb2c4088049..0b5d1104997 100644 --- a/homeassistant/scripts/ensure_config.py +++ b/homeassistant/scripts/ensure_config.py @@ -11,9 +11,7 @@ from homeassistant.core import HomeAssistant def run(args): """Handle ensure config commandline script.""" parser = argparse.ArgumentParser( - description=( - "Ensure a Home Assistant config exists, " "creates one if necessary." - ) + description=("Ensure a Home Assistant config exists, creates one if necessary.") ) parser.add_argument( "-c", diff --git a/homeassistant/setup.py b/homeassistant/setup.py index 2424f5fc465..f0d1e492b99 100644 --- a/homeassistant/setup.py +++ b/homeassistant/setup.py @@ -75,7 +75,7 @@ async def _async_process_dependencies( if failed: _LOGGER.error( - "Unable to set up dependencies of %s. " "Setup failed for dependencies: %s", + "Unable to set up dependencies of %s. Setup failed for dependencies: %s", name, ", ".join(failed), ) @@ -108,14 +108,14 @@ async def _async_setup_component( await loader.async_component_dependencies(hass, domain) except loader.IntegrationNotFound as err: _LOGGER.error( - "Not setting up %s because we are unable to resolve " "(sub)dependency %s", + "Not setting up %s because we are unable to resolve (sub)dependency %s", domain, err.domain, ) return False except loader.CircularDependency as err: _LOGGER.error( - "Not setting up %s because it contains a circular dependency: " "%s -> %s", + "Not setting up %s because it contains a circular dependency: %s -> %s", domain, err.from_domain, err.to_domain, diff --git a/homeassistant/util/dt.py b/homeassistant/util/dt.py index 791b36a4236..49f9d7d5f99 100644 --- a/homeassistant/util/dt.py +++ b/homeassistant/util/dt.py @@ -253,7 +253,7 @@ def find_next_time_expression_time( including daylight saving time. """ if not seconds or not minutes or not hours: - raise ValueError("Cannot find a next time: Time expression never " "matches!") + raise ValueError("Cannot find a next time: Time expression never matches!") def _lower_bound(arr: List[int], cmp: int) -> Optional[int]: """Return the first value in arr greater or equal to cmp. diff --git a/homeassistant/util/yaml/loader.py b/homeassistant/util/yaml/loader.py index 65422f231ba..6b921ade961 100644 --- a/homeassistant/util/yaml/loader.py +++ b/homeassistant/util/yaml/loader.py @@ -258,7 +258,7 @@ def _load_secret_yaml(secret_path: str) -> JSON_TYPE: _LOGGER.setLevel(logging.DEBUG) else: _LOGGER.error( - "secrets.yaml: 'logger: debug' expected," " but 'logger: %s' found", + "secrets.yaml: 'logger: debug' expected, but 'logger: %s' found", logger, ) del secrets["logger"] @@ -276,7 +276,7 @@ def secret_yaml(loader: SafeLineLoader, node: yaml.nodes.Node) -> JSON_TYPE: if node.value in secrets: _LOGGER.debug( - "Secret %s retrieved from secrets.yaml in " "folder %s", + "Secret %s retrieved from secrets.yaml in folder %s", node.value, secret_path, ) diff --git a/script/hassfest/codeowners.py b/script/hassfest/codeowners.py index f6970b50a3c..cfbd112100a 100644 --- a/script/hassfest/codeowners.py +++ b/script/hassfest/codeowners.py @@ -66,7 +66,7 @@ def validate(integrations: Dict[str, Integration], config: Config): if fp.read().strip() != content: config.add_error( "codeowners", - "File CODEOWNERS is not up to date. " "Run python3 -m script.hassfest", + "File CODEOWNERS is not up to date. Run python3 -m script.hassfest", fixable=True, ) return diff --git a/script/hassfest/ssdp.py b/script/hassfest/ssdp.py index 7578d52ed4f..5ee2076ecf4 100644 --- a/script/hassfest/ssdp.py +++ b/script/hassfest/ssdp.py @@ -68,7 +68,7 @@ def validate(integrations: Dict[str, Integration], config: Config): if fp.read().strip() != content: config.add_error( "ssdp", - "File ssdp.py is not up to date. " "Run python3 -m script.hassfest", + "File ssdp.py is not up to date. Run python3 -m script.hassfest", fixable=True, ) return diff --git a/script/hassfest/zeroconf.py b/script/hassfest/zeroconf.py index f864d3e0327..2a1bb936871 100644 --- a/script/hassfest/zeroconf.py +++ b/script/hassfest/zeroconf.py @@ -122,7 +122,7 @@ def validate(integrations: Dict[str, Integration], config: Config): if current != content: config.add_error( "zeroconf", - "File zeroconf.py is not up to date. " "Run python3 -m script.hassfest", + "File zeroconf.py is not up to date. Run python3 -m script.hassfest", fixable=True, ) return diff --git a/tests/components/aprs/test_device_tracker.py b/tests/components/aprs/test_device_tracker.py index d02188a3079..dc0cf09f28d 100644 --- a/tests/components/aprs/test_device_tracker.py +++ b/tests/components/aprs/test_device_tracker.py @@ -302,7 +302,7 @@ def test_aprs_listener_rx_msg_no_position(): def test_setup_scanner(): """Test setup_scanner.""" with patch( - "homeassistant.components." "aprs.device_tracker.AprsListenerThread" + "homeassistant.components.aprs.device_tracker.AprsListenerThread" ) as listener: hass = get_test_home_assistant() hass.start() diff --git a/tests/components/automation/test_time.py b/tests/components/automation/test_time.py index e12ce6684d2..d84fd18fb6b 100644 --- a/tests/components/automation/test_time.py +++ b/tests/components/automation/test_time.py @@ -39,7 +39,7 @@ async def test_if_fires_using_at(hass, calls): "action": { "service": "test.automation", "data_template": { - "some": "{{ trigger.platform }} - " "{{ trigger.now.hour }}" + "some": "{{ trigger.platform }} - {{ trigger.now.hour }}" }, }, } diff --git a/tests/components/binary_sensor/test_init.py b/tests/components/binary_sensor/test_init.py index 9759d3281e6..2299ba4c9a2 100644 --- a/tests/components/binary_sensor/test_init.py +++ b/tests/components/binary_sensor/test_init.py @@ -14,12 +14,11 @@ class TestBinarySensor(unittest.TestCase): sensor = binary_sensor.BinarySensorDevice() assert STATE_OFF == sensor.state with mock.patch( - "homeassistant.components.binary_sensor." "BinarySensorDevice.is_on", + "homeassistant.components.binary_sensor.BinarySensorDevice.is_on", new=False, ): assert STATE_OFF == binary_sensor.BinarySensorDevice().state with mock.patch( - "homeassistant.components.binary_sensor." "BinarySensorDevice.is_on", - new=True, + "homeassistant.components.binary_sensor.BinarySensorDevice.is_on", new=True, ): assert STATE_ON == binary_sensor.BinarySensorDevice().state diff --git a/tests/components/buienradar/test_camera.py b/tests/components/buienradar/test_camera.py index 2dd63583741..6faac295d54 100644 --- a/tests/components/buienradar/test_camera.py +++ b/tests/components/buienradar/test_camera.py @@ -12,7 +12,7 @@ EPSILON_DELTA = 0.0000000001 def radar_map_url(dim: int = 512) -> str: """Build map url, defaulting to 512 wide (as in component).""" - return ("https://api.buienradar.nl/" "image/1.0/RadarMapNL?w={dim}&h={dim}").format( + return ("https://api.buienradar.nl/image/1.0/RadarMapNL?w={dim}&h={dim}").format( dim=dim ) diff --git a/tests/components/camera/test_init.py b/tests/components/camera/test_init.py index 4bd13c35ad8..de48a1d48f3 100644 --- a/tests/components/camera/test_init.py +++ b/tests/components/camera/test_init.py @@ -119,7 +119,7 @@ class TestGetImage: def test_get_image_without_exists_camera(self): """Try to get image without exists camera.""" with patch( - "homeassistant.helpers.entity_component.EntityComponent." "get_entity", + "homeassistant.helpers.entity_component.EntityComponent.get_entity", return_value=None, ), pytest.raises(HomeAssistantError): asyncio.run_coroutine_threadsafe( diff --git a/tests/components/cloud/test_http_api.py b/tests/components/cloud/test_http_api.py index 515489035fb..b82b2b5481e 100644 --- a/tests/components/cloud/test_http_api.py +++ b/tests/components/cloud/test_http_api.py @@ -321,7 +321,7 @@ async def test_websocket_status( client = await hass_ws_client(hass) with patch.dict( - "homeassistant.components.google_assistant.const." "DOMAIN_TO_GOOGLE_TYPES", + "homeassistant.components.google_assistant.const.DOMAIN_TO_GOOGLE_TYPES", {"light": None}, clear=True, ), patch.dict( @@ -683,7 +683,7 @@ async def test_list_google_entities(hass, hass_ws_client, setup_api, mock_cloud_ hass, MockConfig(should_expose=lambda *_: False), State("light.kitchen", "on") ) with patch( - "homeassistant.components.google_assistant.helpers" ".async_get_entities", + "homeassistant.components.google_assistant.helpers.async_get_entities", return_value=[entity], ): await client.send_json({"id": 5, "type": "cloud/google_assistant/entities"}) @@ -779,7 +779,7 @@ async def test_list_alexa_entities(hass, hass_ws_client, setup_api, mock_cloud_l hass, MagicMock(entity_config={}), State("light.kitchen", "on") ) with patch( - "homeassistant.components.alexa.entities" ".async_get_entities", + "homeassistant.components.alexa.entities.async_get_entities", return_value=[entity], ): await client.send_json({"id": 5, "type": "cloud/alexa/entities"}) diff --git a/tests/components/demo/test_media_player.py b/tests/components/demo/test_media_player.py index 60402844d24..a70e7ea4b5d 100644 --- a/tests/components/demo/test_media_player.py +++ b/tests/components/demo/test_media_player.py @@ -209,7 +209,7 @@ class TestDemoMediaPlayer(unittest.TestCase): assert "some_id" == state.attributes.get("media_content_id") @patch( - "homeassistant.components.demo.media_player.DemoYoutubePlayer." "media_seek", + "homeassistant.components.demo.media_player.DemoYoutubePlayer.media_seek", autospec=True, ) def test_seek(self, mock_seek): diff --git a/tests/components/device_tracker/test_init.py b/tests/components/device_tracker/test_init.py index e839a88536e..c82f36f92e7 100644 --- a/tests/components/device_tracker/test_init.py +++ b/tests/components/device_tracker/test_init.py @@ -77,7 +77,7 @@ async def test_reading_broken_yaml_config(hass): "badkey.yaml": "@:\n name: Device", "noname.yaml": "my_device:\n", "allok.yaml": "My Device:\n name: Device", - "oneok.yaml": ("My Device!:\n name: Device\n" "bad_device:\n nme: Device"), + "oneok.yaml": ("My Device!:\n name: Device\nbad_device:\n nme: Device"), } args = {"hass": hass, "consider_home": timedelta(seconds=60)} with patch_yaml_files(files): @@ -341,7 +341,7 @@ async def test_group_all_devices(hass, mock_device_tracker_conf): assert (entity_id,) == state.attributes.get(ATTR_ENTITY_ID) -@patch("homeassistant.components.device_tracker.legacy." "DeviceTracker.async_see") +@patch("homeassistant.components.device_tracker.legacy.DeviceTracker.async_see") async def test_see_service(mock_see, hass): """Test the see service with a unicode dev_id and NO MAC.""" with assert_setup_component(1, device_tracker.DOMAIN): diff --git a/tests/components/emulated_hue/test_hue_api.py b/tests/components/emulated_hue/test_hue_api.py index 6c1a17c0538..2fb5c48e768 100644 --- a/tests/components/emulated_hue/test_hue_api.py +++ b/tests/components/emulated_hue/test_hue_api.py @@ -56,7 +56,7 @@ def hass_hue(loop, hass): ) ) - with patch("homeassistant.components" ".emulated_hue.UPNPResponderThread"): + with patch("homeassistant.components.emulated_hue.UPNPResponderThread"): loop.run_until_complete( setup.async_setup_component( hass, diff --git a/tests/components/emulated_hue/test_init.py b/tests/components/emulated_hue/test_init.py index 09c0731e4cd..6fa6d969539 100644 --- a/tests/components/emulated_hue/test_init.py +++ b/tests/components/emulated_hue/test_init.py @@ -14,7 +14,7 @@ def test_config_google_home_entity_id_to_number(): "homeassistant.components.emulated_hue.load_json", return_value={"1": "light.test2"}, ) as json_loader: - with patch("homeassistant.components.emulated_hue" ".save_json") as json_saver: + with patch("homeassistant.components.emulated_hue.save_json") as json_saver: number = conf.entity_id_to_number("light.test") assert number == "2" @@ -48,7 +48,7 @@ def test_config_google_home_entity_id_to_number_altered(): "homeassistant.components.emulated_hue.load_json", return_value={"21": "light.test2"}, ) as json_loader: - with patch("homeassistant.components.emulated_hue" ".save_json") as json_saver: + with patch("homeassistant.components.emulated_hue.save_json") as json_saver: number = conf.entity_id_to_number("light.test") assert number == "22" assert json_saver.call_count == 1 @@ -80,7 +80,7 @@ def test_config_google_home_entity_id_to_number_empty(): with patch( "homeassistant.components.emulated_hue.load_json", return_value={} ) as json_loader: - with patch("homeassistant.components.emulated_hue" ".save_json") as json_saver: + with patch("homeassistant.components.emulated_hue.save_json") as json_saver: number = conf.entity_id_to_number("light.test") assert number == "1" assert json_saver.call_count == 1 diff --git a/tests/components/emulated_hue/test_upnp.py b/tests/components/emulated_hue/test_upnp.py index 2fc9d903d3b..5897b80659a 100644 --- a/tests/components/emulated_hue/test_upnp.py +++ b/tests/components/emulated_hue/test_upnp.py @@ -32,7 +32,7 @@ class TestEmulatedHue(unittest.TestCase): hass, http.DOMAIN, {http.DOMAIN: {http.CONF_SERVER_PORT: HTTP_SERVER_PORT}} ) - with patch("homeassistant.components" ".emulated_hue.UPNPResponderThread"): + with patch("homeassistant.components.emulated_hue.UPNPResponderThread"): setup.setup_component( hass, emulated_hue.DOMAIN, diff --git a/tests/components/facebox/test_image_processing.py b/tests/components/facebox/test_image_processing.py index d82f70e7ca1..6b248ba1c3c 100644 --- a/tests/components/facebox/test_image_processing.py +++ b/tests/components/facebox/test_image_processing.py @@ -81,7 +81,7 @@ VALID_CONFIG = { def mock_healthybox(): """Mock fb.check_box_health.""" check_box_health = ( - "homeassistant.components.facebox.image_processing." "check_box_health" + "homeassistant.components.facebox.image_processing.check_box_health" ) with patch(check_box_health, return_value=MOCK_BOX_ID) as _mock_healthybox: yield _mock_healthybox diff --git a/tests/components/feedreader/test_init.py b/tests/components/feedreader/test_init.py index 62412e53900..048be11e079 100644 --- a/tests/components/feedreader/test_init.py +++ b/tests/components/feedreader/test_init.py @@ -50,7 +50,7 @@ class TestFeedreaderComponent(unittest.TestCase): def test_setup_one_feed(self): """Test the general setup of this component.""" with patch( - "homeassistant.components.feedreader." "track_time_interval" + "homeassistant.components.feedreader.track_time_interval" ) as track_method: assert setup_component(self.hass, feedreader.DOMAIN, VALID_CONFIG_1) track_method.assert_called_once_with( @@ -60,7 +60,7 @@ class TestFeedreaderComponent(unittest.TestCase): def test_setup_scan_interval(self): """Test the setup of this component with scan interval.""" with patch( - "homeassistant.components.feedreader." "track_time_interval" + "homeassistant.components.feedreader.track_time_interval" ) as track_method: assert setup_component(self.hass, feedreader.DOMAIN, VALID_CONFIG_2) track_method.assert_called_once_with( @@ -88,7 +88,7 @@ class TestFeedreaderComponent(unittest.TestCase): data_file = self.hass.config.path("{}.pickle".format(feedreader.DOMAIN)) storage = StoredData(data_file) with patch( - "homeassistant.components.feedreader." "track_time_interval" + "homeassistant.components.feedreader.track_time_interval" ) as track_method: manager = FeedManager( feed_data, DEFAULT_SCAN_INTERVAL, max_entries, self.hass, storage @@ -131,7 +131,7 @@ class TestFeedreaderComponent(unittest.TestCase): # Must patch 'get_timestamp' method because the timestamp is stored # with the URL which in these tests is the raw XML data. with patch( - "homeassistant.components.feedreader.StoredData." "get_timestamp", + "homeassistant.components.feedreader.StoredData.get_timestamp", return_value=time.struct_time((2018, 4, 30, 5, 10, 0, 0, 120, 0)), ): manager2, events2 = self.setup_manager(feed_data2) @@ -139,7 +139,7 @@ class TestFeedreaderComponent(unittest.TestCase): # 3. Run feed_data3 = load_fixture("feedreader1.xml") with patch( - "homeassistant.components.feedreader.StoredData." "get_timestamp", + "homeassistant.components.feedreader.StoredData.get_timestamp", return_value=time.struct_time((2018, 4, 30, 5, 11, 0, 0, 120, 0)), ): manager3, events3 = self.setup_manager(feed_data3) diff --git a/tests/components/filter/test_sensor.py b/tests/components/filter/test_sensor.py index a5f23b464dd..9ae4245ed70 100644 --- a/tests/components/filter/test_sensor.py +++ b/tests/components/filter/test_sensor.py @@ -117,11 +117,11 @@ class TestFilterSensor(unittest.TestCase): } with patch( - "homeassistant.components.history." "state_changes_during_period", + "homeassistant.components.history.state_changes_during_period", return_value=fake_states, ): with patch( - "homeassistant.components.history." "get_last_state_changes", + "homeassistant.components.history.get_last_state_changes", return_value=fake_states, ): with assert_setup_component(1, "sensor"): @@ -165,11 +165,11 @@ class TestFilterSensor(unittest.TestCase): ] } with patch( - "homeassistant.components.history." "state_changes_during_period", + "homeassistant.components.history.state_changes_during_period", return_value=fake_states, ): with patch( - "homeassistant.components.history." "get_last_state_changes", + "homeassistant.components.history.get_last_state_changes", return_value=fake_states, ): with assert_setup_component(1, "sensor"): diff --git a/tests/components/hassio/conftest.py b/tests/components/hassio/conftest.py index d7ef853012e..091270c12c4 100644 --- a/tests/components/hassio/conftest.py +++ b/tests/components/hassio/conftest.py @@ -20,7 +20,7 @@ def hassio_env(): "homeassistant.components.hassio.HassIO.is_connected", Mock(return_value=mock_coro({"result": "ok", "data": {}})), ), patch.dict(os.environ, {"HASSIO_TOKEN": "123456"}), patch( - "homeassistant.components.hassio.HassIO." "get_homeassistant_info", + "homeassistant.components.hassio.HassIO.get_homeassistant_info", Mock(side_effect=HassioAPIError()), ): yield diff --git a/tests/components/hassio/test_discovery.py b/tests/components/hassio/test_discovery.py index 2a2fdc4deaa..a0d64440041 100644 --- a/tests/components/hassio/test_discovery.py +++ b/tests/components/hassio/test_discovery.py @@ -40,7 +40,7 @@ async def test_hassio_discovery_startup(hass, aioclient_mock, hassio_client): assert aioclient_mock.call_count == 0 with patch( - "homeassistant.components.mqtt." "config_flow.FlowHandler.async_step_hassio", + "homeassistant.components.mqtt.config_flow.FlowHandler.async_step_hassio", Mock(return_value=mock_coro({"type": "abort"})), ) as mock_mqtt: hass.bus.async_fire(EVENT_HOMEASSISTANT_START) @@ -93,10 +93,10 @@ async def test_hassio_discovery_startup_done(hass, aioclient_mock, hassio_client "homeassistant.components.hassio.HassIO.update_hass_api", Mock(return_value=mock_coro({"result": "ok"})), ), patch( - "homeassistant.components.hassio.HassIO." "get_homeassistant_info", + "homeassistant.components.hassio.HassIO.get_homeassistant_info", Mock(side_effect=HassioAPIError()), ), patch( - "homeassistant.components.mqtt." "config_flow.FlowHandler.async_step_hassio", + "homeassistant.components.mqtt.config_flow.FlowHandler.async_step_hassio", Mock(return_value=mock_coro({"type": "abort"})), ) as mock_mqtt: await hass.async_start() @@ -143,7 +143,7 @@ async def test_hassio_discovery_webhook(hass, aioclient_mock, hassio_client): ) with patch( - "homeassistant.components.mqtt." "config_flow.FlowHandler.async_step_hassio", + "homeassistant.components.mqtt.config_flow.FlowHandler.async_step_hassio", Mock(return_value=mock_coro({"type": "abort"})), ) as mock_mqtt: resp = await hassio_client.post( diff --git a/tests/components/here_travel_time/test_sensor.py b/tests/components/here_travel_time/test_sensor.py index 6b9c52b1042..4456b256f6e 100644 --- a/tests/components/here_travel_time/test_sensor.py +++ b/tests/components/here_travel_time/test_sensor.py @@ -387,7 +387,7 @@ async def test_public_transport(hass, requests_mock_credentials_check): assert sensor.attributes.get(ATTR_DURATION) == 89.16666666666667 assert sensor.attributes.get(ATTR_DISTANCE) == 22.325 assert sensor.attributes.get(ATTR_ROUTE) == ( - "332 - Palmer/Schiller; 332 - Cargo Rd./Delta Cargo; " "332 - Palmer/Schiller" + "332 - Palmer/Schiller; 332 - Cargo Rd./Delta Cargo; 332 - Palmer/Schiller" ) assert sensor.attributes.get(CONF_UNIT_SYSTEM) == "metric" assert sensor.attributes.get(ATTR_DURATION_IN_TRAFFIC) == 89.16666666666667 diff --git a/tests/components/history_stats/test_sensor.py b/tests/components/history_stats/test_sensor.py index 492f928c9f0..588e0df81db 100644 --- a/tests/components/history_stats/test_sensor.py +++ b/tests/components/history_stats/test_sensor.py @@ -50,7 +50,7 @@ class TestHistoryStatsSensor(unittest.TestCase): assert state.state == STATE_UNKNOWN @patch( - "homeassistant.helpers.template.TemplateEnvironment." "is_safe_callable", + "homeassistant.helpers.template.TemplateEnvironment.is_safe_callable", return_value=True, ) def test_period_parsing(self, mock): @@ -58,7 +58,7 @@ class TestHistoryStatsSensor(unittest.TestCase): now = datetime(2019, 1, 1, 23, 30, 0, tzinfo=pytz.utc) with patch("homeassistant.util.dt.now", return_value=now): today = Template( - "{{ now().replace(hour=0).replace(minute=0)" ".replace(second=0) }}", + "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}", self.hass, ) duration = timedelta(hours=2, minutes=1) @@ -137,7 +137,7 @@ class TestHistoryStatsSensor(unittest.TestCase): assert sensor4._type == "ratio" with patch( - "homeassistant.components.history." "state_changes_during_period", + "homeassistant.components.history.state_changes_during_period", return_value=fake_states, ): with patch("homeassistant.components.history.get_state", return_value=None): diff --git a/tests/components/homekit/test_accessories.py b/tests/components/homekit/test_accessories.py index 0c5810a5b10..f67e0e2478d 100644 --- a/tests/components/homekit/test_accessories.py +++ b/tests/components/homekit/test_accessories.py @@ -97,7 +97,7 @@ async def test_home_accessory(hass, hk_driver): hass.states.async_set(entity_id, "on") await hass.async_block_till_done() with patch( - "homeassistant.components.homekit.accessories." "HomeAccessory.update_state" + "homeassistant.components.homekit.accessories.HomeAccessory.update_state" ) as mock_update_state: await hass.async_add_job(acc.run) await hass.async_block_till_done() @@ -343,7 +343,7 @@ def test_home_driver(): # pair with patch("pyhap.accessory_driver.AccessoryDriver.pair") as mock_pair, patch( - "homeassistant.components.homekit.accessories." "dismiss_setup_message" + "homeassistant.components.homekit.accessories.dismiss_setup_message" ) as mock_dissmiss_msg: driver.pair("client_uuid", "client_public") @@ -352,7 +352,7 @@ def test_home_driver(): # unpair with patch("pyhap.accessory_driver.AccessoryDriver.unpair") as mock_unpair, patch( - "homeassistant.components.homekit.accessories." "show_setup_message" + "homeassistant.components.homekit.accessories.show_setup_message" ) as mock_show_msg: driver.unpair("client_uuid") diff --git a/tests/components/honeywell/test_climate.py b/tests/components/honeywell/test_climate.py index feba4f6410e..058988203e5 100644 --- a/tests/components/honeywell/test_climate.py +++ b/tests/components/honeywell/test_climate.py @@ -27,7 +27,7 @@ class TestHoneywell(unittest.TestCase): """A test class for Honeywell themostats.""" @mock.patch("somecomfort.SomeComfort") - @mock.patch("homeassistant.components.honeywell." "climate.HoneywellUSThermostat") + @mock.patch("homeassistant.components.honeywell.climate.HoneywellUSThermostat") def test_setup_us(self, mock_ht, mock_sc): """Test for the US setup.""" config = { @@ -98,7 +98,7 @@ class TestHoneywell(unittest.TestCase): assert not add_entities.called @mock.patch("somecomfort.SomeComfort") - @mock.patch("homeassistant.components.honeywell." "climate.HoneywellUSThermostat") + @mock.patch("homeassistant.components.honeywell.climate.HoneywellUSThermostat") def _test_us_filtered_devices(self, mock_ht, mock_sc, loc=None, dev=None): """Test for US filtered thermostats.""" config = { @@ -157,7 +157,7 @@ class TestHoneywell(unittest.TestCase): assert [mock.sentinel.loc2dev1] == devices @mock.patch("evohomeclient.EvohomeClient") - @mock.patch("homeassistant.components.honeywell.climate." "HoneywellUSThermostat") + @mock.patch("homeassistant.components.honeywell.climate.HoneywellUSThermostat") def test_eu_setup_full_config(self, mock_round, mock_evo): """Test the EU setup with complete configuration.""" config = { @@ -184,7 +184,7 @@ class TestHoneywell(unittest.TestCase): assert 2 == add_entities.call_count @mock.patch("evohomeclient.EvohomeClient") - @mock.patch("homeassistant.components.honeywell.climate." "HoneywellUSThermostat") + @mock.patch("homeassistant.components.honeywell.climate.HoneywellUSThermostat") def test_eu_setup_partial_config(self, mock_round, mock_evo): """Test the EU setup with partial configuration.""" config = { @@ -206,7 +206,7 @@ class TestHoneywell(unittest.TestCase): ) @mock.patch("evohomeclient.EvohomeClient") - @mock.patch("homeassistant.components.honeywell.climate." "HoneywellUSThermostat") + @mock.patch("homeassistant.components.honeywell.climate.HoneywellUSThermostat") def test_eu_setup_bad_temp(self, mock_round, mock_evo): """Test the EU setup with invalid temperature.""" config = { @@ -219,7 +219,7 @@ class TestHoneywell(unittest.TestCase): honeywell.PLATFORM_SCHEMA(config) @mock.patch("evohomeclient.EvohomeClient") - @mock.patch("homeassistant.components.honeywell.climate." "HoneywellUSThermostat") + @mock.patch("homeassistant.components.honeywell.climate.HoneywellUSThermostat") def test_eu_setup_error(self, mock_round, mock_evo): """Test the EU setup with errors.""" config = { diff --git a/tests/components/ign_sismologia/test_geo_location.py b/tests/components/ign_sismologia/test_geo_location.py index 2d869c1a062..0f0191f3b82 100644 --- a/tests/components/ign_sismologia/test_geo_location.py +++ b/tests/components/ign_sismologia/test_geo_location.py @@ -94,7 +94,7 @@ async def test_setup(hass): # Patching 'utcnow' to gain more control over the timed update. utcnow = dt_util.utcnow() with patch("homeassistant.util.dt.utcnow", return_value=utcnow), patch( - "georss_ign_sismologia_client." "IgnSismologiaFeed" + "georss_ign_sismologia_client.IgnSismologiaFeed" ) as mock_feed: mock_feed.return_value.update.return_value = ( "OK", @@ -199,7 +199,7 @@ async def test_setup_with_custom_location(hass): # Set up some mock feed entries for this test. mock_entry_1 = _generate_mock_feed_entry("1234", "Title 1", 20.5, (38.1, -3.1)) - with patch("georss_ign_sismologia_client." "IgnSismologiaFeed") as mock_feed: + with patch("georss_ign_sismologia_client.IgnSismologiaFeed") as mock_feed: mock_feed.return_value.update.return_value = "OK", [mock_entry_1] with assert_setup_component(1, geo_location.DOMAIN): diff --git a/tests/components/islamic_prayer_times/test_sensor.py b/tests/components/islamic_prayer_times/test_sensor.py index 389fa43945e..3151b030637 100644 --- a/tests/components/islamic_prayer_times/test_sensor.py +++ b/tests/components/islamic_prayer_times/test_sensor.py @@ -175,7 +175,7 @@ async def test_islamic_prayer_times_sensor_update(hass): future = midnight_dt + timedelta(days=1, minutes=1) with patch( - "homeassistant.components.islamic_prayer_times.sensor" ".dt_util.utcnow", + "homeassistant.components.islamic_prayer_times.sensor.dt_util.utcnow", return_value=future, ): diff --git a/tests/components/logentries/test_init.py b/tests/components/logentries/test_init.py index 7125822e93e..f850a7dd62b 100644 --- a/tests/components/logentries/test_init.py +++ b/tests/components/logentries/test_init.py @@ -70,7 +70,7 @@ class TestLogentries(unittest.TestCase): } ] payload = { - "host": "https://webhook.logentries.com/noformat/" "logs/token", + "host": "https://webhook.logentries.com/noformat/logs/token", "event": body, } self.handler_method(event) diff --git a/tests/components/mailbox/test_init.py b/tests/components/mailbox/test_init.py index 258e0cc7ebf..6536e1317fa 100644 --- a/tests/components/mailbox/test_init.py +++ b/tests/components/mailbox/test_init.py @@ -38,7 +38,7 @@ async def test_get_messages_from_mailbox(mock_http_client): async def test_get_media_from_mailbox(mock_http_client): """Get audio from mailbox.""" mp3sha = "3f67c4ea33b37d1710f772a26dd3fb43bb159d50" - msgtxt = "Message 1. " "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " + msgtxt = "Message 1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. " msgsha = sha1(msgtxt.encode("utf-8")).hexdigest() url = "/api/mailbox/media/DemoMailbox/%s" % (msgsha) @@ -50,8 +50,8 @@ async def test_get_media_from_mailbox(mock_http_client): async def test_delete_from_mailbox(mock_http_client): """Get audio from mailbox.""" - msgtxt1 = "Message 1. " "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " - msgtxt2 = "Message 3. " "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " + msgtxt1 = "Message 1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. " + msgtxt2 = "Message 3. Lorem ipsum dolor sit amet, consectetur adipiscing elit. " msgsha1 = sha1(msgtxt1.encode("utf-8")).hexdigest() msgsha2 = sha1(msgtxt2.encode("utf-8")).hexdigest() diff --git a/tests/components/manual/test_alarm_control_panel.py b/tests/components/manual/test_alarm_control_panel.py index 1b06477750b..f1596277e3c 100644 --- a/tests/components/manual/test_alarm_control_panel.py +++ b/tests/components/manual/test_alarm_control_panel.py @@ -111,7 +111,7 @@ async def test_arm_home_with_pending(hass): future = dt_util.utcnow() + timedelta(seconds=1) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -252,7 +252,7 @@ async def test_arm_away_with_pending(hass): future = dt_util.utcnow() + timedelta(seconds=1) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -367,7 +367,7 @@ async def test_arm_night_with_pending(hass): future = dt_util.utcnow() + timedelta(seconds=1) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -432,7 +432,7 @@ async def test_trigger_no_pending(hass): future = dt_util.utcnow() + timedelta(seconds=60) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -474,7 +474,7 @@ async def test_trigger_with_delay(hass): future = dt_util.utcnow() + timedelta(seconds=1) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -563,7 +563,7 @@ async def test_trigger_with_pending(hass): future = dt_util.utcnow() + timedelta(seconds=2) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -574,7 +574,7 @@ async def test_trigger_with_pending(hass): future = dt_util.utcnow() + timedelta(seconds=5) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -618,7 +618,7 @@ async def test_trigger_with_unused_specific_delay(hass): future = dt_util.utcnow() + timedelta(seconds=5) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -662,7 +662,7 @@ async def test_trigger_with_specific_delay(hass): future = dt_util.utcnow() + timedelta(seconds=1) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -706,7 +706,7 @@ async def test_trigger_with_pending_and_delay(hass): future = dt_util.utcnow() + timedelta(seconds=1) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -718,7 +718,7 @@ async def test_trigger_with_pending_and_delay(hass): future += timedelta(seconds=1) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -763,7 +763,7 @@ async def test_trigger_with_pending_and_specific_delay(hass): future = dt_util.utcnow() + timedelta(seconds=1) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -775,7 +775,7 @@ async def test_trigger_with_pending_and_specific_delay(hass): future += timedelta(seconds=1) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -808,7 +808,7 @@ async def test_armed_home_with_specific_pending(hass): future = dt_util.utcnow() + timedelta(seconds=2) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -840,7 +840,7 @@ async def test_armed_away_with_specific_pending(hass): future = dt_util.utcnow() + timedelta(seconds=2) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -872,7 +872,7 @@ async def test_armed_night_with_specific_pending(hass): future = dt_util.utcnow() + timedelta(seconds=2) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -906,7 +906,7 @@ async def test_trigger_with_specific_pending(hass): future = dt_util.utcnow() + timedelta(seconds=2) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -916,7 +916,7 @@ async def test_trigger_with_specific_pending(hass): future = dt_util.utcnow() + timedelta(seconds=5) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -951,7 +951,7 @@ async def test_trigger_with_disarm_after_trigger(hass): future = dt_util.utcnow() + timedelta(seconds=5) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -1013,7 +1013,7 @@ async def test_trigger_with_unused_zero_specific_trigger_time(hass): future = dt_util.utcnow() + timedelta(seconds=5) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -1048,7 +1048,7 @@ async def test_trigger_with_specific_trigger_time(hass): future = dt_util.utcnow() + timedelta(seconds=5) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -1087,7 +1087,7 @@ async def test_trigger_with_no_disarm_after_trigger(hass): future = dt_util.utcnow() + timedelta(seconds=5) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -1126,7 +1126,7 @@ async def test_back_to_back_trigger_with_no_disarm_after_trigger(hass): future = dt_util.utcnow() + timedelta(seconds=5) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -1140,7 +1140,7 @@ async def test_back_to_back_trigger_with_no_disarm_after_trigger(hass): future = dt_util.utcnow() + timedelta(seconds=5) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -1178,7 +1178,7 @@ async def test_disarm_while_pending_trigger(hass): future = dt_util.utcnow() + timedelta(seconds=5) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -1217,7 +1217,7 @@ async def test_disarm_during_trigger_with_invalid_code(hass): future = dt_util.utcnow() + timedelta(seconds=5) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -1342,7 +1342,7 @@ async def test_arm_custom_bypass_with_pending(hass): future = dt_util.utcnow() + timedelta(seconds=1) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -1400,7 +1400,7 @@ async def test_armed_custom_bypass_with_specific_pending(hass): future = dt_util.utcnow() + timedelta(seconds=2) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -1448,7 +1448,7 @@ async def test_arm_away_after_disabled_disarmed(hass): future = dt_util.utcnow() + timedelta(seconds=1) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) @@ -1466,7 +1466,7 @@ async def test_arm_away_after_disabled_disarmed(hass): future += timedelta(seconds=1) with patch( - ("homeassistant.components.manual.alarm_control_panel." "dt_util.utcnow"), + ("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"), return_value=future, ): async_fire_time_changed(hass, future) diff --git a/tests/components/microsoft_face/test_init.py b/tests/components/microsoft_face/test_init.py index 24d67f56fb5..3e2cdf0d530 100644 --- a/tests/components/microsoft_face/test_init.py +++ b/tests/components/microsoft_face/test_init.py @@ -96,7 +96,7 @@ class TestMicrosoftFaceSetup: self.hass.stop() @patch( - "homeassistant.components.microsoft_face." "MicrosoftFace.update_store", + "homeassistant.components.microsoft_face.MicrosoftFace.update_store", return_value=mock_coro(), ) def test_setup_component(self, mock_update): @@ -105,7 +105,7 @@ class TestMicrosoftFaceSetup: setup_component(self.hass, mf.DOMAIN, self.config) @patch( - "homeassistant.components.microsoft_face." "MicrosoftFace.update_store", + "homeassistant.components.microsoft_face.MicrosoftFace.update_store", return_value=mock_coro(), ) def test_setup_component_wrong_api_key(self, mock_update): @@ -114,7 +114,7 @@ class TestMicrosoftFaceSetup: setup_component(self.hass, mf.DOMAIN, {mf.DOMAIN: {}}) @patch( - "homeassistant.components.microsoft_face." "MicrosoftFace.update_store", + "homeassistant.components.microsoft_face.MicrosoftFace.update_store", return_value=mock_coro(), ) def test_setup_component_test_service(self, mock_update): @@ -170,7 +170,7 @@ class TestMicrosoftFaceSetup: ) @patch( - "homeassistant.components.microsoft_face." "MicrosoftFace.update_store", + "homeassistant.components.microsoft_face.MicrosoftFace.update_store", return_value=mock_coro(), ) def test_service_groups(self, mock_update, aioclient_mock): @@ -257,7 +257,7 @@ class TestMicrosoftFaceSetup: assert "Hans" not in entity_group1.attributes @patch( - "homeassistant.components.microsoft_face." "MicrosoftFace.update_store", + "homeassistant.components.microsoft_face.MicrosoftFace.update_store", return_value=mock_coro(), ) def test_service_train(self, mock_update, aioclient_mock): @@ -317,7 +317,7 @@ class TestMicrosoftFaceSetup: assert aioclient_mock.mock_calls[3][2] == b"Test" @patch( - "homeassistant.components.microsoft_face." "MicrosoftFace.update_store", + "homeassistant.components.microsoft_face.MicrosoftFace.update_store", return_value=mock_coro(), ) def test_service_status_400(self, mock_update, aioclient_mock): @@ -339,7 +339,7 @@ class TestMicrosoftFaceSetup: assert len(aioclient_mock.mock_calls) == 1 @patch( - "homeassistant.components.microsoft_face." "MicrosoftFace.update_store", + "homeassistant.components.microsoft_face.MicrosoftFace.update_store", return_value=mock_coro(), ) def test_service_status_timeout(self, mock_update, aioclient_mock): diff --git a/tests/components/microsoft_face_detect/test_image_processing.py b/tests/components/microsoft_face_detect/test_image_processing.py index 1b01ee7434c..384e0ba130f 100644 --- a/tests/components/microsoft_face_detect/test_image_processing.py +++ b/tests/components/microsoft_face_detect/test_image_processing.py @@ -28,7 +28,7 @@ class TestMicrosoftFaceDetectSetup: self.hass.stop() @patch( - "homeassistant.components.microsoft_face." "MicrosoftFace.update_store", + "homeassistant.components.microsoft_face.MicrosoftFace.update_store", return_value=mock_coro(), ) def test_setup_platform(self, store_mock): @@ -49,7 +49,7 @@ class TestMicrosoftFaceDetectSetup: assert self.hass.states.get("image_processing.microsoftface_demo_camera") @patch( - "homeassistant.components.microsoft_face." "MicrosoftFace.update_store", + "homeassistant.components.microsoft_face.MicrosoftFace.update_store", return_value=mock_coro(), ) def test_setup_platform_name(self, store_mock): diff --git a/tests/components/microsoft_face_identify/test_image_processing.py b/tests/components/microsoft_face_identify/test_image_processing.py index 311d463bc1d..d1054cf8dc4 100644 --- a/tests/components/microsoft_face_identify/test_image_processing.py +++ b/tests/components/microsoft_face_identify/test_image_processing.py @@ -28,7 +28,7 @@ class TestMicrosoftFaceIdentifySetup: self.hass.stop() @patch( - "homeassistant.components.microsoft_face." "MicrosoftFace.update_store", + "homeassistant.components.microsoft_face.MicrosoftFace.update_store", return_value=mock_coro(), ) def test_setup_platform(self, store_mock): @@ -49,7 +49,7 @@ class TestMicrosoftFaceIdentifySetup: assert self.hass.states.get("image_processing.microsoftface_demo_camera") @patch( - "homeassistant.components.microsoft_face." "MicrosoftFace.update_store", + "homeassistant.components.microsoft_face.MicrosoftFace.update_store", return_value=mock_coro(), ) def test_setup_platform_name(self, store_mock): diff --git a/tests/components/mqtt/test_binary_sensor.py b/tests/components/mqtt/test_binary_sensor.py index 3e8f342ea94..3bfe32633b3 100644 --- a/tests/components/mqtt/test_binary_sensor.py +++ b/tests/components/mqtt/test_binary_sensor.py @@ -78,7 +78,7 @@ async def expires_helper(hass, mqtt_mock, caplog): """Run the basic expiry code.""" now = datetime(2017, 1, 1, 1, tzinfo=dt_util.UTC) - with patch(("homeassistant.helpers.event." "dt_util.utcnow"), return_value=now): + with patch(("homeassistant.helpers.event.dt_util.utcnow"), return_value=now): async_fire_time_changed(hass, now) async_fire_mqtt_message(hass, "test-topic", "ON") await hass.async_block_till_done() @@ -97,7 +97,7 @@ async def expires_helper(hass, mqtt_mock, caplog): assert state.state == STATE_ON # Next message resets timer - with patch(("homeassistant.helpers.event." "dt_util.utcnow"), return_value=now): + with patch(("homeassistant.helpers.event.dt_util.utcnow"), return_value=now): async_fire_time_changed(hass, now) async_fire_mqtt_message(hass, "test-topic", "OFF") await hass.async_block_till_done() diff --git a/tests/components/mqtt/test_climate.py b/tests/components/mqtt/test_climate.py index 2db368d0311..29962287dd7 100644 --- a/tests/components/mqtt/test_climate.py +++ b/tests/components/mqtt/test_climate.py @@ -113,7 +113,7 @@ async def test_set_operation_bad_attr_and_state(hass, mqtt_mock, caplog): assert state.state == "off" with pytest.raises(vol.Invalid) as excinfo: await common.async_set_hvac_mode(hass, None, ENTITY_CLIMATE) - assert ("value is not allowed for dictionary value @ " "data['hvac_mode']") in str( + assert ("value is not allowed for dictionary value @ data['hvac_mode']") in str( excinfo.value ) state = hass.states.get(ENTITY_CLIMATE) diff --git a/tests/components/mqtt/test_device_tracker.py b/tests/components/mqtt/test_device_tracker.py index 71348fcf5cb..f4324bd8634 100644 --- a/tests/components/mqtt/test_device_tracker.py +++ b/tests/components/mqtt/test_device_tracker.py @@ -27,7 +27,7 @@ async def test_ensure_device_tracker_platform_validation(hass): assert "qos" in config with patch( - "homeassistant.components.mqtt.device_tracker." "async_setup_scanner", + "homeassistant.components.mqtt.device_tracker.async_setup_scanner", autospec=True, side_effect=mock_setup_scanner, ) as mock_sp: diff --git a/tests/components/mqtt/test_discovery.py b/tests/components/mqtt/test_discovery.py index 2b6c65b919e..6320be3b772 100644 --- a/tests/components/mqtt/test_discovery.py +++ b/tests/components/mqtt/test_discovery.py @@ -179,9 +179,7 @@ async def test_discovery_incl_nodeid(hass, mqtt_mock, caplog): await async_start(hass, "homeassistant", {}, entry) async_fire_mqtt_message( - hass, - "homeassistant/binary_sensor/my_node_id/bla" "/config", - '{ "name": "Beer" }', + hass, "homeassistant/binary_sensor/my_node_id/bla/config", '{ "name": "Beer" }', ) await hass.async_block_till_done() @@ -212,7 +210,7 @@ async def test_non_duplicate_discovery(hass, mqtt_mock, caplog): assert state is not None assert state.name == "Beer" assert state_duplicate is None - assert "Component has already been discovered: " "binary_sensor bla" in caplog.text + assert "Component has already been discovered: binary_sensor bla" in caplog.text async def test_discovery_expansion(hass, mqtt_mock, caplog): @@ -424,7 +422,7 @@ async def test_complex_discovery_topic_prefix(hass, mqtt_mock, caplog): async_fire_mqtt_message( hass, - ("my_home/homeassistant/register" "/binary_sensor/node1/object1/config"), + ("my_home/homeassistant/register/binary_sensor/node1/object1/config"), '{ "name": "Beer" }', ) await hass.async_block_till_done() diff --git a/tests/components/mqtt/test_light.py b/tests/components/mqtt/test_light.py index b03cd4b8d73..43ccaf6dea5 100644 --- a/tests/components/mqtt/test_light.py +++ b/tests/components/mqtt/test_light.py @@ -555,7 +555,7 @@ async def test_sending_mqtt_commands_and_optimistic(hass, mqtt_mock): }, ) with patch( - "homeassistant.helpers.restore_state.RestoreEntity" ".async_get_last_state", + "homeassistant.helpers.restore_state.RestoreEntity.async_get_last_state", return_value=mock_coro(fake_state), ): with assert_setup_component(1, light.DOMAIN): diff --git a/tests/components/mqtt/test_light_json.py b/tests/components/mqtt/test_light_json.py index 52adeb61514..355451f6469 100644 --- a/tests/components/mqtt/test_light_json.py +++ b/tests/components/mqtt/test_light_json.py @@ -299,7 +299,7 @@ async def test_sending_mqtt_commands_and_optimistic(hass, mqtt_mock): ) with patch( - "homeassistant.helpers.restore_state.RestoreEntity" ".async_get_last_state", + "homeassistant.helpers.restore_state.RestoreEntity.async_get_last_state", return_value=mock_coro(fake_state), ): assert await async_setup_component( diff --git a/tests/components/mqtt/test_light_template.py b/tests/components/mqtt/test_light_template.py index 5148f45e6e7..1d109af5930 100644 --- a/tests/components/mqtt/test_light_template.py +++ b/tests/components/mqtt/test_light_template.py @@ -261,7 +261,7 @@ async def test_optimistic(hass, mqtt_mock): ) with patch( - "homeassistant.helpers.restore_state.RestoreEntity" ".async_get_last_state", + "homeassistant.helpers.restore_state.RestoreEntity.async_get_last_state", return_value=mock_coro(fake_state), ): with assert_setup_component(1, light.DOMAIN): diff --git a/tests/components/mqtt/test_sensor.py b/tests/components/mqtt/test_sensor.py index 4e8e5f9bfd0..66f8996bc2e 100644 --- a/tests/components/mqtt/test_sensor.py +++ b/tests/components/mqtt/test_sensor.py @@ -63,7 +63,7 @@ async def test_setting_sensor_value_expires(hass, mqtt_mock, caplog): assert state.state == "unknown" now = datetime(2017, 1, 1, 1, tzinfo=dt_util.UTC) - with patch(("homeassistant.helpers.event." "dt_util.utcnow"), return_value=now): + with patch(("homeassistant.helpers.event.dt_util.utcnow"), return_value=now): async_fire_time_changed(hass, now) async_fire_mqtt_message(hass, "test-topic", "100") await hass.async_block_till_done() @@ -82,7 +82,7 @@ async def test_setting_sensor_value_expires(hass, mqtt_mock, caplog): assert state.state == "100" # Next message resets timer - with patch(("homeassistant.helpers.event." "dt_util.utcnow"), return_value=now): + with patch(("homeassistant.helpers.event.dt_util.utcnow"), return_value=now): async_fire_time_changed(hass, now) async_fire_mqtt_message(hass, "test-topic", "101") await hass.async_block_till_done() diff --git a/tests/components/mqtt/test_switch.py b/tests/components/mqtt/test_switch.py index 35cbea5a82b..25fc3212f05 100644 --- a/tests/components/mqtt/test_switch.py +++ b/tests/components/mqtt/test_switch.py @@ -69,7 +69,7 @@ async def test_sending_mqtt_commands_and_optimistic(hass, mock_publish): fake_state = ha.State("switch.test", "on") with patch( - "homeassistant.helpers.restore_state.RestoreEntity" ".async_get_last_state", + "homeassistant.helpers.restore_state.RestoreEntity.async_get_last_state", return_value=mock_coro(fake_state), ): assert await async_setup_component( diff --git a/tests/components/mqtt_json/test_device_tracker.py b/tests/components/mqtt_json/test_device_tracker.py index 7f3f806da52..5af196c5bf2 100644 --- a/tests/components/mqtt_json/test_device_tracker.py +++ b/tests/components/mqtt_json/test_device_tracker.py @@ -46,7 +46,7 @@ async def test_ensure_device_tracker_platform_validation(hass): assert "qos" in config with patch( - "homeassistant.components.mqtt_json.device_tracker." "async_setup_scanner", + "homeassistant.components.mqtt_json.device_tracker.async_setup_scanner", autospec=True, side_effect=mock_setup_scanner, ) as mock_sp: diff --git a/tests/components/owntracks/test_config_flow.py b/tests/components/owntracks/test_config_flow.py index d48c3c43a25..21bb5bcf993 100644 --- a/tests/components/owntracks/test_config_flow.py +++ b/tests/components/owntracks/test_config_flow.py @@ -126,7 +126,7 @@ async def test_user_not_supports_encryption(hass, not_supports_encryption): async def test_unload(hass): """Test unloading a config flow.""" with patch( - "homeassistant.config_entries.ConfigEntries" ".async_forward_entry_setup" + "homeassistant.config_entries.ConfigEntries.async_forward_entry_setup" ) as mock_forward: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "import"}, data={} @@ -140,7 +140,7 @@ async def test_unload(hass): assert entry.data["webhook_id"] in hass.data["webhook"] with patch( - "homeassistant.config_entries.ConfigEntries" ".async_forward_entry_unload", + "homeassistant.config_entries.ConfigEntries.async_forward_entry_unload", return_value=mock_coro(), ) as mock_unload: assert await hass.config_entries.async_unload(entry.entry_id) diff --git a/tests/components/owntracks/test_device_tracker.py b/tests/components/owntracks/test_device_tracker.py index 3a7f3c030ed..730da4bc7b2 100644 --- a/tests/components/owntracks/test_device_tracker.py +++ b/tests/components/owntracks/test_device_tracker.py @@ -1300,7 +1300,7 @@ async def test_single_waypoint_import(hass, context): async def test_not_implemented_message(hass, context): """Handle not implemented message type.""" patch_handler = patch( - "homeassistant.components.owntracks." "messages.async_handle_not_impl_msg", + "homeassistant.components.owntracks.messages.async_handle_not_impl_msg", return_value=mock_coro(False), ) patch_handler.start() @@ -1311,7 +1311,7 @@ async def test_not_implemented_message(hass, context): async def test_unsupported_message(hass, context): """Handle not implemented message type.""" patch_handler = patch( - "homeassistant.components.owntracks." "messages.async_handle_unsupported_msg", + "homeassistant.components.owntracks.messages.async_handle_unsupported_msg", return_value=mock_coro(False), ) patch_handler.start() @@ -1396,7 +1396,7 @@ def config_context(hass, setup_comp): patch_load.start() patch_save = patch( - "homeassistant.components.device_tracker." "DeviceTracker.async_update_config" + "homeassistant.components.device_tracker.DeviceTracker.async_update_config" ) patch_save.start() diff --git a/tests/components/qld_bushfire/test_geo_location.py b/tests/components/qld_bushfire/test_geo_location.py index 86ab16c5f1b..ad9bdd7c536 100644 --- a/tests/components/qld_bushfire/test_geo_location.py +++ b/tests/components/qld_bushfire/test_geo_location.py @@ -89,7 +89,7 @@ async def test_setup(hass): # Patching 'utcnow' to gain more control over the timed update. utcnow = dt_util.utcnow() with patch("homeassistant.util.dt.utcnow", return_value=utcnow), patch( - "georss_qld_bushfire_alert_client." "QldBushfireAlertFeed" + "georss_qld_bushfire_alert_client.QldBushfireAlertFeed" ) as mock_feed: mock_feed.return_value.update.return_value = ( "OK", @@ -193,7 +193,7 @@ async def test_setup_with_custom_location(hass): "1234", "Title 1", 20.5, (38.1, -3.1), category="Category 1" ) - with patch("georss_qld_bushfire_alert_client." "QldBushfireAlertFeed") as mock_feed: + with patch("georss_qld_bushfire_alert_client.QldBushfireAlertFeed") as mock_feed: mock_feed.return_value.update.return_value = "OK", [mock_entry_1] with assert_setup_component(1, geo_location.DOMAIN): diff --git a/tests/components/radarr/test_sensor.py b/tests/components/radarr/test_sensor.py index ecd0c501ee8..114daa7d2f7 100644 --- a/tests/components/radarr/test_sensor.py +++ b/tests/components/radarr/test_sensor.py @@ -182,7 +182,7 @@ def mocked_requests_get(*args, **kwargs): "sqliteVersion": "3.16.2", "urlBase": "", "runtimeVersion": ( - "4.6.1 " "(Stable 4.6.1.3/abb06f1 " "Mon Oct 3 07:57:59 UTC 2016)" + "4.6.1 (Stable 4.6.1.3/abb06f1 Mon Oct 3 07:57:59 UTC 2016)" ), }, 200, diff --git a/tests/components/rflink/test_binary_sensor.py b/tests/components/rflink/test_binary_sensor.py index d1fdec579c9..18c4f946318 100644 --- a/tests/components/rflink/test_binary_sensor.py +++ b/tests/components/rflink/test_binary_sensor.py @@ -126,7 +126,7 @@ async def test_off_delay(hass, monkeypatch): now = dt_util.utcnow() # fake time and turn on sensor future = now + timedelta(seconds=0) - with patch(("homeassistant.helpers.event." "dt_util.utcnow"), return_value=future): + with patch(("homeassistant.helpers.event.dt_util.utcnow"), return_value=future): async_fire_time_changed(hass, future) event_callback(on_event) await hass.async_block_till_done() @@ -136,7 +136,7 @@ async def test_off_delay(hass, monkeypatch): # fake time and turn on sensor again future = now + timedelta(seconds=15) - with patch(("homeassistant.helpers.event." "dt_util.utcnow"), return_value=future): + with patch(("homeassistant.helpers.event.dt_util.utcnow"), return_value=future): async_fire_time_changed(hass, future) event_callback(on_event) await hass.async_block_till_done() @@ -146,7 +146,7 @@ async def test_off_delay(hass, monkeypatch): # fake time and verify sensor still on (de-bounce) future = now + timedelta(seconds=35) - with patch(("homeassistant.helpers.event." "dt_util.utcnow"), return_value=future): + with patch(("homeassistant.helpers.event.dt_util.utcnow"), return_value=future): async_fire_time_changed(hass, future) await hass.async_block_till_done() state = hass.states.get("binary_sensor.test2") @@ -155,7 +155,7 @@ async def test_off_delay(hass, monkeypatch): # fake time and verify sensor is off future = now + timedelta(seconds=45) - with patch(("homeassistant.helpers.event." "dt_util.utcnow"), return_value=future): + with patch(("homeassistant.helpers.event.dt_util.utcnow"), return_value=future): async_fire_time_changed(hass, future) await hass.async_block_till_done() state = hass.states.get("binary_sensor.test2") diff --git a/tests/components/shell_command/test_init.py b/tests/components/shell_command/test_init.py index a54bd9f7787..50c3c6bfb55 100644 --- a/tests/components/shell_command/test_init.py +++ b/tests/components/shell_command/test_init.py @@ -111,7 +111,7 @@ class TestShellCommand(unittest.TestCase): shell_command.DOMAIN, { shell_command.DOMAIN: { - "test_service": ("ls /bin {{ states.sensor" ".test_state.state }}") + "test_service": ("ls /bin {{ states.sensor.test_state.state }}") } }, ) diff --git a/tests/components/shopping_list/conftest.py b/tests/components/shopping_list/conftest.py index 5026f19302e..44c8000efa2 100644 --- a/tests/components/shopping_list/conftest.py +++ b/tests/components/shopping_list/conftest.py @@ -11,7 +11,7 @@ from homeassistant.setup import async_setup_component def mock_shopping_list_io(): """Stub out the persistence.""" with patch("homeassistant.components.shopping_list.ShoppingData.save"), patch( - "homeassistant.components.shopping_list." "ShoppingData.async_load" + "homeassistant.components.shopping_list.ShoppingData.async_load" ): yield diff --git a/tests/components/startca/test_sensor.py b/tests/components/startca/test_sensor.py index aa06e13a812..eac75a3b4e7 100644 --- a/tests/components/startca/test_sensor.py +++ b/tests/components/startca/test_sensor.py @@ -45,7 +45,7 @@ async def test_capped_setup(hass, aioclient_mock): "" ) aioclient_mock.get( - "https://www.start.ca/support/usage/api?key=" "NOTAKEY", text=result + "https://www.start.ca/support/usage/api?key=NOTAKEY", text=result ) await async_setup_component(hass, "sensor", {"sensor": config}) @@ -140,7 +140,7 @@ async def test_unlimited_setup(hass, aioclient_mock): "" ) aioclient_mock.get( - "https://www.start.ca/support/usage/api?key=" "NOTAKEY", text=result + "https://www.start.ca/support/usage/api?key=NOTAKEY", text=result ) await async_setup_component(hass, "sensor", {"sensor": config}) @@ -196,9 +196,7 @@ async def test_unlimited_setup(hass, aioclient_mock): async def test_bad_return_code(hass, aioclient_mock): """Test handling a return code that isn't HTTP OK.""" - aioclient_mock.get( - "https://www.start.ca/support/usage/api?key=" "NOTAKEY", status=404 - ) + aioclient_mock.get("https://www.start.ca/support/usage/api?key=NOTAKEY", status=404) scd = StartcaData(hass.loop, async_get_clientsession(hass), "NOTAKEY", 400) @@ -209,7 +207,7 @@ async def test_bad_return_code(hass, aioclient_mock): async def test_bad_json_decode(hass, aioclient_mock): """Test decoding invalid json result.""" aioclient_mock.get( - "https://www.start.ca/support/usage/api?key=" "NOTAKEY", text="this is not xml" + "https://www.start.ca/support/usage/api?key=NOTAKEY", text="this is not xml" ) scd = StartcaData(hass.loop, async_get_clientsession(hass), "NOTAKEY", 400) diff --git a/tests/components/tomato/test_device_tracker.py b/tests/components/tomato/test_device_tracker.py index 96957805466..cbc8316f7c8 100644 --- a/tests/components/tomato/test_device_tracker.py +++ b/tests/components/tomato/test_device_tracker.py @@ -51,7 +51,7 @@ def mock_session_response(*args, **kwargs): def mock_exception_logger(): """Mock pyunifi.""" with mock.patch( - "homeassistant.components.tomato.device_tracker" "._LOGGER.exception" + "homeassistant.components.tomato.device_tracker._LOGGER.exception" ) as mock_exception_logger: yield mock_exception_logger @@ -312,7 +312,7 @@ def test_config_bad_credentials(hass, mock_exception_logger): assert mock_exception_logger.call_count == 1 assert mock_exception_logger.mock_calls[0] == mock.call( - "Failed to authenticate, " "please check your username and password" + "Failed to authenticate, please check your username and password" ) @@ -382,7 +382,7 @@ def test_bad_connection(hass, mock_exception_logger): tomato.get_scanner(hass, config) assert mock_exception_logger.call_count == 1 assert mock_exception_logger.mock_calls[0] == mock.call( - "Failed to connect to the router " "or invalid http_id supplied" + "Failed to connect to the router or invalid http_id supplied" ) diff --git a/tests/components/tplink/test_init.py b/tests/components/tplink/test_init.py index 9428bf05483..97512dfc9bd 100644 --- a/tests/components/tplink/test_init.py +++ b/tests/components/tplink/test_init.py @@ -242,7 +242,7 @@ async def test_unload(hass, platform): with patch( "homeassistant.components.tplink.common.SmartDevice._query_helper" ), patch( - "homeassistant.components.tplink.{}" ".async_setup_entry".format(platform), + "homeassistant.components.tplink.{}.async_setup_entry".format(platform), return_value=mock_coro(True), ) as light_setup: config = { diff --git a/tests/components/tradfri/conftest.py b/tests/components/tradfri/conftest.py index 7ebd4bbcd7c..1c6e572b81f 100644 --- a/tests/components/tradfri/conftest.py +++ b/tests/components/tradfri/conftest.py @@ -8,6 +8,6 @@ import pytest def mock_gateway_info(): """Mock get_gateway_info.""" with patch( - "homeassistant.components.tradfri.config_flow." "get_gateway_info" + "homeassistant.components.tradfri.config_flow.get_gateway_info" ) as mock_gateway: yield mock_gateway diff --git a/tests/components/tradfri/test_config_flow.py b/tests/components/tradfri/test_config_flow.py index 151607b1ed8..ad7386c530f 100644 --- a/tests/components/tradfri/test_config_flow.py +++ b/tests/components/tradfri/test_config_flow.py @@ -13,7 +13,7 @@ from tests.common import MockConfigEntry, mock_coro def mock_auth(): """Mock authenticate.""" with patch( - "homeassistant.components.tradfri.config_flow." "authenticate" + "homeassistant.components.tradfri.config_flow.authenticate" ) as mock_auth: yield mock_auth @@ -21,7 +21,7 @@ def mock_auth(): @pytest.fixture def mock_entry_setup(): """Mock entry setup.""" - with patch("homeassistant.components.tradfri." "async_setup_entry") as mock_setup: + with patch("homeassistant.components.tradfri.async_setup_entry") as mock_setup: mock_setup.return_value = mock_coro(True) yield mock_setup diff --git a/tests/components/tts/test_init.py b/tests/components/tts/test_init.py index 389f9478ad3..f8dc11069d8 100644 --- a/tests/components/tts/test_init.py +++ b/tests/components/tts/test_init.py @@ -99,7 +99,7 @@ class TestTTS: assert calls[0].data[ATTR_MEDIA_CONTENT_TYPE] == MEDIA_TYPE_MUSIC assert calls[0].data[ ATTR_MEDIA_CONTENT_ID - ] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" "_en_-_demo.mp3".format( + ] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd_en_-_demo.mp3".format( self.hass.config.api.base_url ) assert os.path.isfile( @@ -129,7 +129,7 @@ class TestTTS: assert calls[0].data[ATTR_MEDIA_CONTENT_TYPE] == MEDIA_TYPE_MUSIC assert calls[0].data[ ATTR_MEDIA_CONTENT_ID - ] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" "_de_-_demo.mp3".format( + ] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd_de_-_demo.mp3".format( self.hass.config.api.base_url ) assert os.path.isfile( @@ -169,7 +169,7 @@ class TestTTS: assert calls[0].data[ATTR_MEDIA_CONTENT_TYPE] == MEDIA_TYPE_MUSIC assert calls[0].data[ ATTR_MEDIA_CONTENT_ID - ] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" "_de_-_demo.mp3".format( + ] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd_de_-_demo.mp3".format( self.hass.config.api.base_url ) assert os.path.isfile( @@ -232,7 +232,7 @@ class TestTTS: assert calls[0].data[ATTR_MEDIA_CONTENT_TYPE] == MEDIA_TYPE_MUSIC assert calls[0].data[ ATTR_MEDIA_CONTENT_ID - ] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" "_de_{}_demo.mp3".format( + ] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd_de_{}_demo.mp3".format( self.hass.config.api.base_url, opt_hash ) assert os.path.isfile( @@ -273,7 +273,7 @@ class TestTTS: assert calls[0].data[ATTR_MEDIA_CONTENT_TYPE] == MEDIA_TYPE_MUSIC assert calls[0].data[ ATTR_MEDIA_CONTENT_ID - ] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" "_de_{}_demo.mp3".format( + ] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd_de_{}_demo.mp3".format( self.hass.config.api.base_url, opt_hash ) assert os.path.isfile( @@ -449,7 +449,7 @@ class TestTTS: self.hass.start() url = ( - "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" "_en_-_demo.mp3" + "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd_en_-_demo.mp3" ).format(self.hass.config.api.base_url) req = requests.get(url) @@ -465,7 +465,7 @@ class TestTTS: self.hass.start() url = ( - "{}/api/tts_proxy/265944dsk32c1b2a621be5930510bb2cd" "_en_-_demo.mp3" + "{}/api/tts_proxy/265944dsk32c1b2a621be5930510bb2cd_en_-_demo.mp3" ).format(self.hass.config.api.base_url) req = requests.get(url) @@ -542,7 +542,7 @@ class TestTTS: setup_component(self.hass, tts.DOMAIN, config) with patch( - "homeassistant.components.demo.tts.DemoProvider." "get_tts_audio", + "homeassistant.components.demo.tts.DemoProvider.get_tts_audio", return_value=(None, None), ): self.hass.services.call( @@ -555,7 +555,7 @@ class TestTTS: assert len(calls) == 1 assert calls[0].data[ ATTR_MEDIA_CONTENT_ID - ] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" "_en_-_demo.mp3".format( + ] == "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd_en_-_demo.mp3".format( self.hass.config.api.base_url ) @@ -601,7 +601,7 @@ class TestTTS: self.hass.start() url = ( - "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd" "_en_-_demo.mp3" + "{}/api/tts_proxy/265944c108cbb00b2a621be5930513e03a0bb2cd_en_-_demo.mp3" ).format(self.hass.config.api.base_url) req = requests.get(url) diff --git a/tests/components/websocket_api/test_auth.py b/tests/components/websocket_api/test_auth.py index ccc033ccc72..2a0bc9f8c5a 100644 --- a/tests/components/websocket_api/test_auth.py +++ b/tests/components/websocket_api/test_auth.py @@ -44,7 +44,7 @@ async def test_auth_events( async def test_auth_via_msg_incorrect_pass(no_auth_websocket_client): """Test authenticating.""" with patch( - "homeassistant.components.websocket_api.auth." "process_wrong_login", + "homeassistant.components.websocket_api.auth.process_wrong_login", return_value=mock_coro(), ) as mock_process_wrong_login: await no_auth_websocket_client.send_json( diff --git a/tests/components/wunderground/test_sensor.py b/tests/components/wunderground/test_sensor.py index bfe9f83fbc3..5f74a837cf3 100644 --- a/tests/components/wunderground/test_sensor.py +++ b/tests/components/wunderground/test_sensor.py @@ -49,11 +49,9 @@ URL = ( "http://api.wunderground.com/api/foo/alerts/conditions/forecast/lang" ":EN/q/32.87336,-117.22743.json" ) -PWS_URL = ( - "http://api.wunderground.com/api/foo/alerts/conditions/" "lang:EN/q/pws:bar.json" -) +PWS_URL = "http://api.wunderground.com/api/foo/alerts/conditions/lang:EN/q/pws:bar.json" INVALID_URL = ( - "http://api.wunderground.com/api/BOB/alerts/conditions/" "lang:foo/q/pws:bar.json" + "http://api.wunderground.com/api/BOB/alerts/conditions/lang:foo/q/pws:bar.json" ) diff --git a/tests/components/yr/test_sensor.py b/tests/components/yr/test_sensor.py index 7e2e8543f77..161a7cef66b 100644 --- a/tests/components/yr/test_sensor.py +++ b/tests/components/yr/test_sensor.py @@ -13,7 +13,7 @@ NOW = datetime(2016, 6, 9, 1, tzinfo=dt_util.UTC) async def test_default_setup(hass, aioclient_mock): """Test the default setup.""" aioclient_mock.get( - "https://aa015h6buqvih86i1.api.met.no/" "weatherapi/locationforecast/1.9/", + "https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/1.9/", text=load_fixture("yr.no.xml"), ) config = {"platform": "yr", "elevation": 0} @@ -32,7 +32,7 @@ async def test_default_setup(hass, aioclient_mock): async def test_custom_setup(hass, aioclient_mock): """Test a custom setup.""" aioclient_mock.get( - "https://aa015h6buqvih86i1.api.met.no/" "weatherapi/locationforecast/1.9/", + "https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/1.9/", text=load_fixture("yr.no.xml"), ) @@ -77,7 +77,7 @@ async def test_custom_setup(hass, aioclient_mock): async def test_forecast_setup(hass, aioclient_mock): """Test a custom setup with 24h forecast.""" aioclient_mock.get( - "https://aa015h6buqvih86i1.api.met.no/" "weatherapi/locationforecast/1.9/", + "https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/1.9/", text=load_fixture("yr.no.xml"), ) diff --git a/tests/components/zha/test_config_flow.py b/tests/components/zha/test_config_flow.py index fdff064a1c5..7e0b89f8d70 100644 --- a/tests/components/zha/test_config_flow.py +++ b/tests/components/zha/test_config_flow.py @@ -16,7 +16,7 @@ async def test_user_flow(hass): flow.hass = hass with asynctest.patch( - "homeassistant.components.zha.config_flow" ".check_zigpy_connection", + "homeassistant.components.zha.config_flow.check_zigpy_connection", return_value=False, ): result = await flow.async_step_user( @@ -26,7 +26,7 @@ async def test_user_flow(hass): assert result["errors"] == {"base": "cannot_connect"} with asynctest.patch( - "homeassistant.components.zha.config_flow" ".check_zigpy_connection", + "homeassistant.components.zha.config_flow.check_zigpy_connection", return_value=True, ): result = await flow.async_step_user( diff --git a/tests/conftest.py b/tests/conftest.py index 262acda6314..558da48a7c1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -60,7 +60,7 @@ def verify_cleanup(): for inst in INSTANCES: inst.stop() pytest.exit( - "Detected non stopped instances " "({}), aborting test run".format(count) + "Detected non stopped instances ({}), aborting test run".format(count) ) diff --git a/tests/helpers/test_check_config.py b/tests/helpers/test_check_config.py index 54c835895ca..0182d830e4c 100644 --- a/tests/helpers/test_check_config.py +++ b/tests/helpers/test_check_config.py @@ -23,7 +23,7 @@ BASE_CONFIG = ( "\n\n" ) -BAD_CORE_CONFIG = "homeassistant:\n" " unit_system: bad\n" "\n\n" +BAD_CORE_CONFIG = "homeassistant:\n unit_system: bad\n\n\n" def log_ha_config(conf): @@ -106,8 +106,7 @@ async def test_component_platform_not_found_2(hass, loop): async def test_package_invalid(hass, loop): """Test a valid platform setup.""" files = { - YAML_CONFIG_FILE: BASE_CONFIG - + (" packages:\n" " p1:\n" ' group: ["a"]') + YAML_CONFIG_FILE: BASE_CONFIG + (" packages:\n p1:\n" ' group: ["a"]') } with patch("os.path.isfile", return_value=True), patch_yaml_files(files): res = await async_check_ha_config_file(hass) diff --git a/tests/helpers/test_device_registry.py b/tests/helpers/test_device_registry.py index 3846230e6d3..7f31c32cde3 100644 --- a/tests/helpers/test_device_registry.py +++ b/tests/helpers/test_device_registry.py @@ -340,7 +340,7 @@ async def test_no_unnecessary_changes(registry): identifiers={("hue", "456"), ("bla", "123")}, ) with patch( - "homeassistant.helpers.device_registry" ".DeviceRegistry.async_schedule_save" + "homeassistant.helpers.device_registry.DeviceRegistry.async_schedule_save" ) as mock_save: entry2 = registry.async_get_or_create( config_entry_id="1234", identifiers={("hue", "456")} diff --git a/tests/helpers/test_entity_component.py b/tests/helpers/test_entity_component.py index a069c050cf4..7284a5d9b67 100644 --- a/tests/helpers/test_entity_component.py +++ b/tests/helpers/test_entity_component.py @@ -115,7 +115,7 @@ async def test_setup_recovers_when_setup_raises(hass): @asynctest.patch( - "homeassistant.helpers.entity_component.EntityComponent" ".async_setup_platform", + "homeassistant.helpers.entity_component.EntityComponent.async_setup_platform", return_value=mock_coro(), ) @asynctest.patch( @@ -137,7 +137,7 @@ async def test_setup_does_discovery(mock_setup_component, mock_setup, hass): assert ("platform_test", {}, {"msg": "discovery_info"}) == mock_setup.call_args[0] -@asynctest.patch("homeassistant.helpers.entity_platform." "async_track_time_interval") +@asynctest.patch("homeassistant.helpers.entity_platform.async_track_time_interval") async def test_set_scan_interval_via_config(mock_track, hass): """Test the setting of the scan interval via configuration.""" @@ -460,5 +460,5 @@ async def test_extract_all_use_match_all(hass, caplog): ent.entity_id for ent in await component.async_extract_from_service(call) ) assert ( - "Not passing an entity ID to a service to target all entities is " "deprecated" + "Not passing an entity ID to a service to target all entities is deprecated" ) not in caplog.text diff --git a/tests/helpers/test_entity_platform.py b/tests/helpers/test_entity_platform.py index 0f73699c896..592cc24df8e 100644 --- a/tests/helpers/test_entity_platform.py +++ b/tests/helpers/test_entity_platform.py @@ -134,7 +134,7 @@ async def test_update_state_adds_entities_with_update_before_add_false(hass): assert not ent.update.called -@asynctest.patch("homeassistant.helpers.entity_platform." "async_track_time_interval") +@asynctest.patch("homeassistant.helpers.entity_platform.async_track_time_interval") async def test_set_scan_interval_via_platform(mock_track, hass): """Test the setting of the scan interval via platform.""" diff --git a/tests/helpers/test_event.py b/tests/helpers/test_event.py index d331da5d92d..cef8baec70e 100644 --- a/tests/helpers/test_event.py +++ b/tests/helpers/test_event.py @@ -805,7 +805,7 @@ async def test_call_later(hass): now = datetime(2017, 12, 19, 15, 40, 0, tzinfo=dt_util.UTC) with patch( - "homeassistant.helpers.event" ".async_track_point_in_utc_time" + "homeassistant.helpers.event.async_track_point_in_utc_time" ) as mock, patch("homeassistant.util.dt.utcnow", return_value=now): async_call_later(hass, 3, action) @@ -825,7 +825,7 @@ async def test_async_call_later(hass): now = datetime(2017, 12, 19, 15, 40, 0, tzinfo=dt_util.UTC) with patch( - "homeassistant.helpers.event" ".async_track_point_in_utc_time" + "homeassistant.helpers.event.async_track_point_in_utc_time" ) as mock, patch("homeassistant.util.dt.utcnow", return_value=now): remove = async_call_later(hass, 3, action) diff --git a/tests/helpers/test_service.py b/tests/helpers/test_service.py index 2697c59b787..b42b30a836a 100644 --- a/tests/helpers/test_service.py +++ b/tests/helpers/test_service.py @@ -459,7 +459,7 @@ async def test_call_with_match_all( mock_entities["light.living_room"], ] assert ( - "Not passing an entity ID to a service to target " "all entities is deprecated" + "Not passing an entity ID to a service to target all entities is deprecated" ) not in caplog.text diff --git a/tests/helpers/test_template.py b/tests/helpers/test_template.py index cbd530d0b4c..1c3afa472f2 100644 --- a/tests/helpers/test_template.py +++ b/tests/helpers/test_template.py @@ -153,7 +153,7 @@ def test_iterating_all_states(hass): def test_iterating_domain_states(hass): """Test iterating domain states.""" - tmpl_str = "{% for state in states.sensor %}" "{{ state.state }}{% endfor %}" + tmpl_str = "{% for state in states.sensor %}{{ state.state }}{% endfor %}" info = render_to_info(hass, tmpl_str) assert_result_info(info, "", domains=["sensor"]) @@ -818,7 +818,7 @@ def test_states_function(hass): @patch( - "homeassistant.helpers.template.TemplateEnvironment." "is_safe_callable", + "homeassistant.helpers.template.TemplateEnvironment.is_safe_callable", return_value=True, ) def test_now(mock_is_safe, hass): @@ -832,7 +832,7 @@ def test_now(mock_is_safe, hass): @patch( - "homeassistant.helpers.template.TemplateEnvironment." "is_safe_callable", + "homeassistant.helpers.template.TemplateEnvironment.is_safe_callable", return_value=True, ) def test_utcnow(mock_is_safe, hass): @@ -1260,18 +1260,18 @@ async def test_expand(hass): hass.states.async_set("test.object", "happy") info = render_to_info( - hass, "{{ expand('test.object') | map(attribute='entity_id')" " | join(', ') }}" + hass, "{{ expand('test.object') | map(attribute='entity_id') | join(', ') }}" ) assert_result_info(info, "test.object", []) info = render_to_info( hass, - "{{ expand('group.new_group') | map(attribute='entity_id')" " | join(', ') }}", + "{{ expand('group.new_group') | map(attribute='entity_id') | join(', ') }}", ) assert_result_info(info, "", ["group.new_group"]) info = render_to_info( - hass, "{{ expand(states.group) | map(attribute='entity_id')" " | join(', ') }}" + hass, "{{ expand(states.group) | map(attribute='entity_id') | join(', ') }}" ) assert_result_info(info, "", [], ["group"]) @@ -1279,12 +1279,12 @@ async def test_expand(hass): info = render_to_info( hass, - "{{ expand('group.new_group') | map(attribute='entity_id')" " | join(', ') }}", + "{{ expand('group.new_group') | map(attribute='entity_id') | join(', ') }}", ) assert_result_info(info, "test.object", ["group.new_group"]) info = render_to_info( - hass, "{{ expand(states.group) | map(attribute='entity_id')" " | join(', ') }}" + hass, "{{ expand(states.group) | map(attribute='entity_id') | join(', ') }}" ) assert_result_info(info, "test.object", ["group.new_group"], ["group"]) @@ -1437,7 +1437,7 @@ def test_closest_function_to_state(hass): assert ( template.Template( - "{{ closest(states.zone.far_away, " "states.test_domain).entity_id }}", hass + "{{ closest(states.zone.far_away, states.test_domain).entity_id }}", hass ).async_render() == "test_domain.closest_zone" ) @@ -1471,7 +1471,7 @@ def test_closest_function_state_with_invalid_location(hass): assert ( template.Template( - "{{ closest(states.test_domain.closest_home, " "states) }}", hass + "{{ closest(states.test_domain.closest_home, states) }}", hass ).async_render() == "None" ) @@ -1517,7 +1517,7 @@ def test_extract_entities_none_exclude_stuff(hass): assert ( template.extract_entities( - "{{ closest(states.zone.far_away, " "states.test_domain).entity_id }}" + "{{ closest(states.zone.far_away, states.test_domain).entity_id }}" ) == MATCH_ALL ) diff --git a/tests/scripts/test_check_config.py b/tests/scripts/test_check_config.py index 481efc6fb30..ea7ae03b5db 100644 --- a/tests/scripts/test_check_config.py +++ b/tests/scripts/test_check_config.py @@ -20,7 +20,7 @@ BASE_CONFIG = ( "\n\n" ) -BAD_CORE_CONFIG = "homeassistant:\n" " unit_system: bad\n" "\n\n" +BAD_CORE_CONFIG = "homeassistant:\n unit_system: bad\n\n\n" def normalize_yaml_files(check_dict): @@ -92,8 +92,8 @@ def test_secrets(isfile_patch, loop): files = { get_test_config_dir(YAML_CONFIG_FILE): BASE_CONFIG - + ("http:\n" " cors_allowed_origins: !secret http_pw"), - secrets_path: ("logger: debug\n" "http_pw: http://google.com"), + + ("http:\n cors_allowed_origins: !secret http_pw"), + secrets_path: ("logger: debug\nhttp_pw: http://google.com"), } with patch_yaml_files(files): @@ -122,8 +122,7 @@ def test_secrets(isfile_patch, loop): def test_package_invalid(isfile_patch, loop): """Test a valid platform setup.""" files = { - YAML_CONFIG_FILE: BASE_CONFIG - + (" packages:\n" " p1:\n" ' group: ["a"]') + YAML_CONFIG_FILE: BASE_CONFIG + (" packages:\n p1:\n" ' group: ["a"]') } with patch_yaml_files(files): res = check_config.check(get_test_config_dir()) diff --git a/tests/util/test_yaml.py b/tests/util/test_yaml.py index ba31ce57010..622d87d1a27 100644 --- a/tests/util/test_yaml.py +++ b/tests/util/test_yaml.py @@ -392,7 +392,7 @@ class TestSecrets(unittest.TestCase): with pytest.raises(HomeAssistantError): load_yaml( os.path.join(self._sub_folder_path, "sub.yaml"), - "http:\n" " api_password: !secret test", + "http:\n api_password: !secret test", ) def test_secrets_keyring(self): @@ -431,9 +431,9 @@ class TestSecrets(unittest.TestCase): def test_secrets_are_not_dict(self): """Did secrets handle non-dict file.""" - FILES[self._secret_path] = ( - "- http_pw: pwhttp\n" " comp1_un: un1\n" " comp1_pw: pw1\n" - ) + FILES[ + self._secret_path + ] = "- http_pw: pwhttp\n comp1_un: un1\n comp1_pw: pw1\n" yaml.clear_secret_cache() with pytest.raises(HomeAssistantError): load_yaml(