From b0cee0bc46cbd7efe0e6421da18d91595c7a25ad Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 22 Dec 2022 10:12:50 +0100 Subject: [PATCH] String formatting and max line length - Part 1 (#84390) Co-authored-by: Erik Montnemery --- homeassistant/auth/__init__.py | 3 +- homeassistant/auth/auth_store.py | 6 ++- homeassistant/auth/mfa_modules/totp.py | 6 ++- homeassistant/auth/providers/homeassistant.py | 16 +++--- homeassistant/bootstrap.py | 3 +- .../components/airnow/config_flow.py | 5 +- homeassistant/components/airq/config_flow.py | 7 ++- .../components/airthings/config_flow.py | 4 +- .../components/aladdin_connect/cover.py | 4 +- homeassistant/components/alexa/handlers.py | 5 +- homeassistant/components/alexa/logbook.py | 5 +- homeassistant/components/almond/__init__.py | 5 +- .../components/amberelectric/sensor.py | 5 +- .../components/ambient_station/__init__.py | 4 +- .../components/androidtv/__init__.py | 5 +- .../components/androidtv/media_player.py | 14 +++-- homeassistant/components/apple_tv/__init__.py | 3 +- .../application_credentials/__init__.py | 4 +- homeassistant/components/asuswrt/router.py | 5 +- homeassistant/components/august/__init__.py | 15 ++++-- .../components/august/binary_sensor.py | 5 +- homeassistant/components/august/gateway.py | 5 +- .../components/aussie_broadband/__init__.py | 3 +- homeassistant/components/auth/login_flow.py | 4 +- .../components/automation/__init__.py | 6 +-- .../components/azure_devops/__init__.py | 3 +- .../components/azure_event_hub/client.py | 4 +- homeassistant/components/backup/manager.py | 5 +- .../components/bayesian/binary_sensor.py | 14 +++-- homeassistant/components/blebox/light.py | 3 +- homeassistant/components/blink/__init__.py | 5 +- .../components/blueprint/importer.py | 6 ++- homeassistant/components/blueprint/models.py | 5 +- .../components/bluetooth/base_scanner.py | 5 +- homeassistant/components/bluetooth/manager.py | 10 +++- .../bluetooth/passive_update_processor.py | 3 +- homeassistant/components/bluetooth/scanner.py | 3 +- .../components/bluetooth/wrappers.py | 3 +- .../bluetooth_tracker/device_tracker.py | 5 +- .../components/bmw_connected_drive/button.py | 8 +-- .../bmw_connected_drive/device_tracker.py | 5 +- homeassistant/components/bond/fan.py | 6 ++- homeassistant/components/bond/light.py | 21 +++++--- homeassistant/components/bond/switch.py | 3 +- .../components/broadlink/config_flow.py | 14 +++-- homeassistant/components/broadlink/device.py | 8 +-- homeassistant/components/camera/__init__.py | 5 +- homeassistant/components/camera/prefs.py | 3 +- homeassistant/components/cast/helpers.py | 5 +- .../components/cast/home_assistant_cast.py | 5 +- homeassistant/components/cast/media_player.py | 8 +-- .../components/cloud/alexa_config.py | 8 +-- homeassistant/components/cloud/client.py | 5 +- homeassistant/components/cloud/http_api.py | 6 ++- homeassistant/components/cloud/stt.py | 5 +- .../components/cloud/subscription.py | 5 +- homeassistant/components/coinbase/sensor.py | 6 ++- .../components/color_extractor/__init__.py | 10 +++- .../components/compensation/__init__.py | 3 +- homeassistant/components/control4/__init__.py | 5 +- homeassistant/components/control4/light.py | 5 +- .../components/daikin/config_flow.py | 6 ++- homeassistant/components/deconz/logbook.py | 4 +- homeassistant/components/deluge/__init__.py | 4 +- .../components/denonavr/config_flow.py | 6 ++- .../components/denonavr/media_player.py | 20 ++++--- homeassistant/components/denonavr/receiver.py | 5 +- .../components/device_tracker/legacy.py | 8 +-- .../components/dialogflow/__init__.py | 3 +- homeassistant/components/discogs/sensor.py | 9 +++- homeassistant/components/discord/notify.py | 5 +- .../components/discovery/__init__.py | 6 ++- .../components/doods/image_processing.py | 5 +- homeassistant/components/doorbird/__init__.py | 10 ++-- homeassistant/components/ecobee/climate.py | 18 ++++--- .../components/ecobee/config_flow.py | 6 ++- homeassistant/components/ecobee/humidifier.py | 3 +- .../eddystone_temperature/sensor.py | 6 ++- .../components/egardia/alarm_control_panel.py | 6 +-- homeassistant/components/elmax/common.py | 3 +- homeassistant/components/emoncms/sensor.py | 6 ++- homeassistant/components/esphome/__init__.py | 10 ++-- .../components/esphome/bluetooth/__init__.py | 5 +- .../components/esphome/bluetooth/client.py | 21 ++++++-- homeassistant/components/evohome/__init__.py | 40 ++++++++------ homeassistant/components/evohome/climate.py | 6 ++- homeassistant/components/ezviz/camera.py | 5 +- homeassistant/components/fan/__init__.py | 3 +- homeassistant/components/fibaro/climate.py | 12 +++-- homeassistant/components/file/notify.py | 5 +- homeassistant/components/firmata/board.py | 3 +- homeassistant/config.py | 16 ++++-- homeassistant/config_entries.py | 52 +++++++++++++------ homeassistant/core.py | 26 +++++++--- homeassistant/data_entry_flow.py | 9 ++-- homeassistant/loader.py | 36 +++++++++---- homeassistant/requirements.py | 5 +- homeassistant/setup.py | 6 ++- 98 files changed, 532 insertions(+), 237 deletions(-) diff --git a/homeassistant/auth/__init__.py b/homeassistant/auth/__init__.py index e1a460f7e8b..966536f446c 100644 --- a/homeassistant/auth/__init__.py +++ b/homeassistant/auth/__init__.py @@ -534,7 +534,8 @@ class AuthManager: ) if provider is None: raise InvalidProvider( - f"Auth provider {refresh_token.credential.auth_provider_type}, {refresh_token.credential.auth_provider_id} not available" + f"Auth provider {refresh_token.credential.auth_provider_type}," + f" {refresh_token.credential.auth_provider_id} not available" ) return provider diff --git a/homeassistant/auth/auth_store.py b/homeassistant/auth/auth_store.py index 2597781dc60..5a9fb469e0d 100644 --- a/homeassistant/auth/auth_store.py +++ b/homeassistant/auth/auth_store.py @@ -449,8 +449,10 @@ class AuthStore: created_at = dt_util.parse_datetime(rt_dict["created_at"]) if created_at is None: getLogger(__name__).error( - "Ignoring refresh token %(id)s with invalid created_at " - "%(created_at)s for user_id %(user_id)s", + ( + "Ignoring refresh token %(id)s with invalid created_at " + "%(created_at)s for user_id %(user_id)s" + ), rt_dict, ) continue diff --git a/homeassistant/auth/mfa_modules/totp.py b/homeassistant/auth/mfa_modules/totp.py index 6160a922351..0c02ef4bd8d 100644 --- a/homeassistant/auth/mfa_modules/totp.py +++ b/homeassistant/auth/mfa_modules/totp.py @@ -47,8 +47,10 @@ def _generate_qr_code(data: str) -> str: .decode("ascii") .replace("\n", "") .replace( - '' - '' + ' None: """Set up Aladdin Connect devices yaml depreciated.""" _LOGGER.warning( - "Configuring Aladdin Connect through yaml is deprecated" - "Please remove it from your configuration as it has already been imported to a config entry" + "Configuring Aladdin Connect through yaml is deprecated. Please remove it from" + " your configuration as it has already been imported to a config entry" ) await hass.async_create_task( hass.config_entries.flow.async_init( diff --git a/homeassistant/components/alexa/handlers.py b/homeassistant/components/alexa/handlers.py index 220036e5296..24ab3ec10e3 100644 --- a/homeassistant/components/alexa/handlers.py +++ b/homeassistant/components/alexa/handlers.py @@ -475,7 +475,10 @@ async def async_api_unlock( ) -> AlexaResponse: """Process an unlock request.""" if config.locale not in {"de-DE", "en-US", "ja-JP"}: - msg = f"The unlock directive is not supported for the following locales: {config.locale}" + msg = ( + "The unlock directive is not supported for the following locales:" + f" {config.locale}" + ) raise AlexaInvalidDirectiveError(msg) entity = directive.entity diff --git a/homeassistant/components/alexa/logbook.py b/homeassistant/components/alexa/logbook.py index 079fea99fdf..496989c57de 100644 --- a/homeassistant/components/alexa/logbook.py +++ b/homeassistant/components/alexa/logbook.py @@ -21,7 +21,10 @@ def async_describe_events(hass, async_describe_event): if entity_id := data["request"].get("entity_id"): state = hass.states.get(entity_id) name = state.name if state else entity_id - message = f"sent command {data['request']['namespace']}/{data['request']['name']} for {name}" + message = ( + "sent command" + f" {data['request']['namespace']}/{data['request']['name']} for {name}" + ) else: message = ( f"sent command {data['request']['namespace']}/{data['request']['name']}" diff --git a/homeassistant/components/almond/__init__.py b/homeassistant/components/almond/__init__.py index fe1ff65f932..07aea4f792e 100644 --- a/homeassistant/components/almond/__init__.py +++ b/homeassistant/components/almond/__init__.py @@ -273,7 +273,10 @@ class AlmondAgent(conversation.AbstractConversationAgent): if self.entry.data.get("is_hassio"): host = "/core_almond" return { - "text": "Would you like to opt-in to share your anonymized commands with Stanford to improve Almond's responses?", + "text": ( + "Would you like to opt-in to share your anonymized commands with" + " Stanford to improve Almond's responses?" + ), "url": f"{host}/conversation", } diff --git a/homeassistant/components/amberelectric/sensor.py b/homeassistant/components/amberelectric/sensor.py index 1e7b6fc8705..4a6d1a6ea18 100644 --- a/homeassistant/components/amberelectric/sensor.py +++ b/homeassistant/components/amberelectric/sensor.py @@ -227,7 +227,10 @@ async def async_setup_entry( for channel_type in current: description = SensorEntityDescription( key="descriptors", - name=f"{entry.title} - {friendly_channel_type(channel_type)} Price Descriptor", + name=( + f"{entry.title} - {friendly_channel_type(channel_type)} Price" + " Descriptor" + ), icon=ICONS[channel_type], ) entities.append( diff --git a/homeassistant/components/ambient_station/__init__.py b/homeassistant/components/ambient_station/__init__.py index 7242c0ba53b..9aced7a2a45 100644 --- a/homeassistant/components/ambient_station/__init__.py +++ b/homeassistant/components/ambient_station/__init__.py @@ -213,7 +213,9 @@ class AmbientWeatherEntity(Entity): public_device_id = get_public_device_id(mac_address) self._attr_device_info = DeviceInfo( - configuration_url=f"https://ambientweather.net/dashboard/{public_device_id}", + configuration_url=( + f"https://ambientweather.net/dashboard/{public_device_id}" + ), identifiers={(DOMAIN, mac_address)}, manufacturer="Ambient Weather", name=station_name.capitalize(), diff --git a/homeassistant/components/androidtv/__init__.py b/homeassistant/components/androidtv/__init__.py index 6942ff7ffd0..c2d83ab05e8 100644 --- a/homeassistant/components/androidtv/__init__.py +++ b/homeassistant/components/androidtv/__init__.py @@ -79,7 +79,10 @@ def _setup_androidtv( else: # Use "pure-python-adb" (communicate with ADB server) signer = None - adb_log = f"using ADB server at {config[CONF_ADB_SERVER_IP]}:{config[CONF_ADB_SERVER_PORT]}" + adb_log = ( + "using ADB server at" + f" {config[CONF_ADB_SERVER_IP]}:{config[CONF_ADB_SERVER_PORT]}" + ) return adbkey, signer, adb_log diff --git a/homeassistant/components/androidtv/media_player.py b/homeassistant/components/androidtv/media_player.py index 241ac12e780..572aa426105 100644 --- a/homeassistant/components/androidtv/media_player.py +++ b/homeassistant/components/androidtv/media_player.py @@ -179,13 +179,16 @@ def adb_decorator( except LockNotAcquiredException: # If the ADB lock could not be acquired, skip this command _LOGGER.info( - "ADB command not executed because the connection is currently in use" + "ADB command not executed because the connection is currently" + " in use" ) return None except self.exceptions as err: _LOGGER.error( - "Failed to execute an ADB command. ADB connection re-" - "establishing attempt in the next update. Error: %s", + ( + "Failed to execute an ADB command. ADB connection re-" + "establishing attempt in the next update. Error: %s" + ), err, ) await self.aftv.adb_close() @@ -427,7 +430,10 @@ class ADBDevice(MediaPlayerEntity): self._attr_extra_state_attributes[ATTR_ADB_RESPONSE] = output self.async_write_ha_state() - msg = f"Output from service '{SERVICE_LEARN_SENDEVENT}' from {self.entity_id}: '{output}'" + msg = ( + f"Output from service '{SERVICE_LEARN_SENDEVENT}' from" + f" {self.entity_id}: '{output}'" + ) persistent_notification.async_create( self.hass, msg, diff --git a/homeassistant/components/apple_tv/__init__.py b/homeassistant/components/apple_tv/__init__.py index 5d9c1cde785..2c9ad84ac42 100644 --- a/homeassistant/components/apple_tv/__init__.py +++ b/homeassistant/components/apple_tv/__init__.py @@ -309,7 +309,8 @@ class AppleTVManager: missing_protocols_str = ", ".join(missing_protocols) if raise_missing_credentials: raise ConfigEntryNotReady( - f"Protocol(s) {missing_protocols_str} not yet found for {name}, waiting for discovery." + f"Protocol(s) {missing_protocols_str} not yet found for {name}," + " waiting for discovery." ) _LOGGER.info( "Protocol(s) %s not yet found for %s, trying later", diff --git a/homeassistant/components/application_credentials/__init__.py b/homeassistant/components/application_credentials/__init__.py index 811a637b4ef..38c14de4d8c 100644 --- a/homeassistant/components/application_credentials/__init__.py +++ b/homeassistant/components/application_credentials/__init__.py @@ -302,8 +302,8 @@ async def _get_platform( platform, "async_get_auth_implementation" ): raise ValueError( - f"Integration '{integration_domain}' platform {DOMAIN} did not " - f"implement 'async_get_authorization_server' or 'async_get_auth_implementation'" + f"Integration '{integration_domain}' platform {DOMAIN} did not implement" + " 'async_get_authorization_server' or 'async_get_auth_implementation'" ) return platform diff --git a/homeassistant/components/asuswrt/router.py b/homeassistant/components/asuswrt/router.py index a48e1374b6d..ffdec02bd3e 100644 --- a/homeassistant/components/asuswrt/router.py +++ b/homeassistant/components/asuswrt/router.py @@ -402,7 +402,10 @@ class AsusWrtRouter: ] except Exception as exc: # pylint: disable=broad-except _LOGGER.debug( - "Failed checking temperature sensor availability for ASUS router %s. Exception: %s", + ( + "Failed checking temperature sensor availability for ASUS router" + " %s. Exception: %s" + ), self._host, exc, ) diff --git a/homeassistant/components/august/__init__.py b/homeassistant/components/august/__init__.py index 8d1f54f4a4a..20007ed8304 100644 --- a/homeassistant/components/august/__init__.py +++ b/homeassistant/components/august/__init__.py @@ -400,7 +400,10 @@ class AugustData(AugustSubscriberMixin): if self._device_detail_by_id.get(device_id): continue _LOGGER.info( - "The doorbell %s could not be setup because the system could not fetch details about the doorbell", + ( + "The doorbell %s could not be setup because the system could not" + " fetch details about the doorbell" + ), doorbell.device_name, ) del self._doorbells_by_id[device_id] @@ -414,12 +417,18 @@ class AugustData(AugustSubscriberMixin): lock_detail = self._device_detail_by_id.get(device_id) if lock_detail is None: _LOGGER.info( - "The lock %s could not be setup because the system could not fetch details about the lock", + ( + "The lock %s could not be setup because the system could not" + " fetch details about the lock" + ), lock.device_name, ) elif lock_detail.bridge is None: _LOGGER.info( - "The lock %s could not be setup because it does not have a bridge (Connect)", + ( + "The lock %s could not be setup because it does not have a" + " bridge (Connect)" + ), lock.device_name, ) del self._device_detail_by_id[device_id] diff --git a/homeassistant/components/august/binary_sensor.py b/homeassistant/components/august/binary_sensor.py index 6f45f626180..89e05c5057e 100644 --- a/homeassistant/components/august/binary_sensor.py +++ b/homeassistant/components/august/binary_sensor.py @@ -167,7 +167,10 @@ async def async_setup_entry( detail = data.get_device_detail(door.device_id) if not detail.doorsense: _LOGGER.debug( - "Not adding sensor class door for lock %s because it does not have doorsense", + ( + "Not adding sensor class door for lock %s because it does not have" + " doorsense" + ), door.device_name, ) continue diff --git a/homeassistant/components/august/gateway.py b/homeassistant/components/august/gateway.py index 6c9f9113d98..ac7b81a7117 100644 --- a/homeassistant/components/august/gateway.py +++ b/homeassistant/components/august/gateway.py @@ -131,7 +131,10 @@ class AugustGateway: await self.authenticator.async_refresh_access_token(force=False) ) _LOGGER.info( - "Refreshed august access token. The old token expired at %s, and the new token expires at %s", + ( + "Refreshed august access token. The old token expired at %s, and" + " the new token expires at %s" + ), self.authentication.access_token_expires, refreshed_authentication.access_token_expires, ) diff --git a/homeassistant/components/aussie_broadband/__init__.py b/homeassistant/components/aussie_broadband/__init__.py index b32e11f27c0..ae4bc78580c 100644 --- a/homeassistant/components/aussie_broadband/__init__.py +++ b/homeassistant/components/aussie_broadband/__init__.py @@ -45,7 +45,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await client.get_usage(service_id) except UnrecognisedServiceType as err: raise UpdateFailed( - f"Service {service_id} of type '{services[service_id]['type']}' was unrecognised" + f"Service {service_id} of type '{services[service_id]['type']}' was" + " unrecognised" ) from err return async_update_data diff --git a/homeassistant/components/auth/login_flow.py b/homeassistant/components/auth/login_flow.py index b907598fe5a..364f5242377 100644 --- a/homeassistant/components/auth/login_flow.py +++ b/homeassistant/components/auth/login_flow.py @@ -122,7 +122,9 @@ class WellKnownOAuthInfoView(HomeAssistantView): "token_endpoint": "/auth/token", "revocation_endpoint": "/auth/revoke", "response_types_supported": ["code"], - "service_documentation": "https://developers.home-assistant.io/docs/auth_api", + "service_documentation": ( + "https://developers.home-assistant.io/docs/auth_api" + ), } ) diff --git a/homeassistant/components/automation/__init__.py b/homeassistant/components/automation/__init__.py index b0be5359d38..c0bbf51138a 100644 --- a/homeassistant/components/automation/__init__.py +++ b/homeassistant/components/automation/__init__.py @@ -418,8 +418,7 @@ class AutomationEntity(ToggleEntity, RestoreEntity): if last_triggered is not None: self.action_script.last_triggered = parse_datetime(last_triggered) self._logger.debug( - "Loaded automation %s with state %s from state " - " storage last state %s", + "Loaded automation %s with state %s from state storage last state %s", self.entity_id, enable_automation, state, @@ -435,8 +434,7 @@ class AutomationEntity(ToggleEntity, RestoreEntity): if self._initial_state is not None: enable_automation = self._initial_state self._logger.debug( - "Automation %s initial state %s overridden from " - "config initial_state", + "Automation %s initial state %s overridden from config initial_state", self.entity_id, enable_automation, ) diff --git a/homeassistant/components/azure_devops/__init__.py b/homeassistant/components/azure_devops/__init__.py index 645932f8b73..01c0cd123e3 100644 --- a/homeassistant/components/azure_devops/__init__.py +++ b/homeassistant/components/azure_devops/__init__.py @@ -48,7 +48,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: await client.authorize(entry.data[CONF_PAT], entry.data[CONF_ORG]) if not client.authorized: raise ConfigEntryAuthFailed( - "Could not authorize with Azure DevOps. You will need to update your token" + "Could not authorize with Azure DevOps. You will need to update your" + " token" ) project = await client.get_project( diff --git a/homeassistant/components/azure_event_hub/client.py b/homeassistant/components/azure_event_hub/client.py index 90880a92b64..dc1bfe37971 100644 --- a/homeassistant/components/azure_event_hub/client.py +++ b/homeassistant/components/azure_event_hub/client.py @@ -64,7 +64,9 @@ class AzureEventHubClientSAS(AzureEventHubClient): def client(self) -> EventHubProducerClient: """Get a Event Producer Client.""" return EventHubProducerClient( - fully_qualified_namespace=f"{self.event_hub_namespace}.servicebus.windows.net", + fully_qualified_namespace=( + f"{self.event_hub_namespace}.servicebus.windows.net" + ), eventhub_name=self.event_hub_instance_name, credential=EventHubSharedKeyCredential( # type: ignore[arg-type] policy=self.event_hub_sas_policy, key=self.event_hub_sas_key diff --git a/homeassistant/components/backup/manager.py b/homeassistant/components/backup/manager.py index 15fc4a7f648..cf42f49fa1b 100644 --- a/homeassistant/components/backup/manager.py +++ b/homeassistant/components/backup/manager.py @@ -129,7 +129,10 @@ class BackupManager: if not backup.path.exists(): LOGGER.debug( - "Removing tracked backup (%s) that does not exists on the expected path %s", + ( + "Removing tracked backup (%s) that does not exists on the expected" + " path %s" + ), backup.slug, backup.path, ) diff --git a/homeassistant/components/bayesian/binary_sensor.py b/homeassistant/components/bayesian/binary_sensor.py index 28af050e85e..4cd68c7a9b4 100644 --- a/homeassistant/components/bayesian/binary_sensor.py +++ b/homeassistant/components/bayesian/binary_sensor.py @@ -266,9 +266,7 @@ class BayesianBinarySensor(BinarySensorEntity): ) if isinstance(result, TemplateError): _LOGGER.error( - "TemplateError('%s') " - "while processing template '%s' " - "in entity '%s'", + "TemplateError('%s') while processing template '%s' in entity '%s'", result, template, self.entity_id, @@ -369,12 +367,18 @@ class BayesianBinarySensor(BinarySensorEntity): # observation.observed is None if observation.entity_id is not None: _LOGGER.debug( - "Observation for entity '%s' returned None, it will not be used for Bayesian updating", + ( + "Observation for entity '%s' returned None, it will not be used" + " for Bayesian updating" + ), observation.entity_id, ) continue _LOGGER.debug( - "Observation for template entity returned None rather than a valid boolean, it will not be used for Bayesian updating", + ( + "Observation for template entity returned None rather than a valid" + " boolean, it will not be used for Bayesian updating" + ), ) # the prior has been updated and is now the posterior return prior diff --git a/homeassistant/components/blebox/light.py b/homeassistant/components/blebox/light.py index b138aae15b7..c4f13503abf 100644 --- a/homeassistant/components/blebox/light.py +++ b/homeassistant/components/blebox/light.py @@ -177,7 +177,8 @@ class BleBoxLightEntity(BleBoxEntity[blebox_uniapi.light.Light], LightEntity): await self._feature.async_api_command("effect", effect_value) except ValueError as exc: raise ValueError( - f"Turning on with effect '{self.name}' failed: {effect} not in effect list." + f"Turning on with effect '{self.name}' failed: {effect} not in" + " effect list." ) from exc async def async_turn_off(self, **kwargs: Any) -> None: diff --git a/homeassistant/components/blink/__init__.py b/homeassistant/components/blink/__init__.py index ef5a99356bc..668a7f99c02 100644 --- a/homeassistant/components/blink/__init__.py +++ b/homeassistant/components/blink/__init__.py @@ -55,7 +55,10 @@ def _reauth_flow_wrapper(hass, data): ) persistent_notification.async_create( hass, - "Blink configuration migrated to a new version. Please go to the integrations page to re-configure (such as sending a new 2FA key).", + ( + "Blink configuration migrated to a new version. Please go to the" + " integrations page to re-configure (such as sending a new 2FA key)." + ), "Blink Migration", ) diff --git a/homeassistant/components/blueprint/importer.py b/homeassistant/components/blueprint/importer.py index f8b37a97c31..d857992a13c 100644 --- a/homeassistant/components/blueprint/importer.py +++ b/homeassistant/components/blueprint/importer.py @@ -125,7 +125,8 @@ def _extract_blueprint_from_community_topic( if blueprint is None: raise HomeAssistantError( - "No valid blueprint found in the topic. Blueprint syntax blocks need to be marked as YAML or no syntax." + "No valid blueprint found in the topic. Blueprint syntax blocks need to be" + " marked as YAML or no syntax." ) return ImportedBlueprint( @@ -209,7 +210,8 @@ async def fetch_blueprint_from_github_gist_url( if blueprint is None: raise HomeAssistantError( - "No valid blueprint found in the gist. The blueprint file needs to end with '.yaml'" + "No valid blueprint found in the gist. The blueprint file needs to end with" + " '.yaml'" ) return ImportedBlueprint( diff --git a/homeassistant/components/blueprint/models.py b/homeassistant/components/blueprint/models.py index ee81a583391..6f48080a451 100644 --- a/homeassistant/components/blueprint/models.py +++ b/homeassistant/components/blueprint/models.py @@ -69,7 +69,10 @@ class Blueprint: expected_domain, path or self.name, data, - f"Found incorrect blueprint type {data_domain}, expected {expected_domain}", + ( + f"Found incorrect blueprint type {data_domain}, expected" + f" {expected_domain}" + ), ) self.domain = data_domain diff --git a/homeassistant/components/bluetooth/base_scanner.py b/homeassistant/components/bluetooth/base_scanner.py index ffa2c4f568d..09243e67dbe 100644 --- a/homeassistant/components/bluetooth/base_scanner.py +++ b/homeassistant/components/bluetooth/base_scanner.py @@ -108,7 +108,10 @@ class BaseHaScanner(ABC): """ if self._async_watchdog_triggered(): _LOGGER.info( - "%s: Bluetooth scanner has gone quiet for %ss, check logs on the scanner device for more information", + ( + "%s: Bluetooth scanner has gone quiet for %ss, check logs on the" + " scanner device for more information" + ), self.name, SCANNER_WATCHDOG_TIMEOUT, ) diff --git a/homeassistant/components/bluetooth/manager.py b/homeassistant/components/bluetooth/manager.py index e05598242d5..bb9ec8041ad 100644 --- a/homeassistant/components/bluetooth/manager.py +++ b/homeassistant/components/bluetooth/manager.py @@ -318,7 +318,10 @@ class BluetoothManager: # If the old advertisement is stale, any new advertisement is preferred if debug: _LOGGER.debug( - "%s (%s): Switching from %s to %s (time elapsed:%s > stale seconds:%s)", + ( + "%s (%s): Switching from %s to %s (time elapsed:%s > stale" + " seconds:%s)" + ), new.name, new.address, self._async_describe_source(old), @@ -333,7 +336,10 @@ class BluetoothManager: # If new advertisement is RSSI_SWITCH_THRESHOLD more, the new one is preferred if debug: _LOGGER.debug( - "%s (%s): Switching from %s to %s (new rssi:%s - threshold:%s > old rssi:%s)", + ( + "%s (%s): Switching from %s to %s (new rssi:%s - threshold:%s >" + " old rssi:%s)" + ), new.name, new.address, self._async_describe_source(old), diff --git a/homeassistant/components/bluetooth/passive_update_processor.py b/homeassistant/components/bluetooth/passive_update_processor.py index b04447cc4ee..04034293491 100644 --- a/homeassistant/components/bluetooth/passive_update_processor.py +++ b/homeassistant/components/bluetooth/passive_update_processor.py @@ -286,7 +286,8 @@ class PassiveBluetoothDataProcessor(Generic[_T]): if not isinstance(new_data, PassiveBluetoothDataUpdate): self.last_update_success = False # type: ignore[unreachable] raise ValueError( - f"The update_method for {self.coordinator.name} returned {new_data} instead of a PassiveBluetoothDataUpdate" + f"The update_method for {self.coordinator.name} returned" + f" {new_data} instead of a PassiveBluetoothDataUpdate" ) if not self.last_update_success: diff --git a/homeassistant/components/bluetooth/scanner.py b/homeassistant/components/bluetooth/scanner.py index 6f2da53ce7f..b077d046fb5 100644 --- a/homeassistant/components/bluetooth/scanner.py +++ b/homeassistant/components/bluetooth/scanner.py @@ -263,7 +263,8 @@ class HaScanner(BaseHaScanner): await self._async_reset_adapter() continue raise ScannerStartError( - f"{self.name}: Timed out starting Bluetooth after {START_TIMEOUT} seconds" + f"{self.name}: Timed out starting Bluetooth after" + f" {START_TIMEOUT} seconds" ) from ex except BleakError as ex: error_str = str(ex) diff --git a/homeassistant/components/bluetooth/wrappers.py b/homeassistant/components/bluetooth/wrappers.py index 91482b2634e..b25de347d02 100644 --- a/homeassistant/components/bluetooth/wrappers.py +++ b/homeassistant/components/bluetooth/wrappers.py @@ -258,7 +258,8 @@ class HaBleakClientWrapper(BleakClient): return backend raise BleakError( - f"No backend with an available connection slot that can reach address {address} was found" + "No backend with an available connection slot that can reach address" + f" {address} was found" ) async def disconnect(self) -> bool: diff --git a/homeassistant/components/bluetooth_tracker/device_tracker.py b/homeassistant/components/bluetooth_tracker/device_tracker.py index ce8f6ca8006..c277985782c 100644 --- a/homeassistant/components/bluetooth_tracker/device_tracker.py +++ b/homeassistant/components/bluetooth_tracker/device_tracker.py @@ -187,7 +187,10 @@ async def async_setup_scanner( # If an update is in progress, we don't do anything if update_bluetooth_lock.locked(): _LOGGER.debug( - "Previous execution of update_bluetooth is taking longer than the scheduled update of interval %s", + ( + "Previous execution of update_bluetooth is taking longer than the" + " scheduled update of interval %s" + ), interval, ) return diff --git a/homeassistant/components/bmw_connected_drive/button.py b/homeassistant/components/bmw_connected_drive/button.py index 810edaf9617..873a72762ab 100644 --- a/homeassistant/components/bmw_connected_drive/button.py +++ b/homeassistant/components/bmw_connected_drive/button.py @@ -120,9 +120,11 @@ class BMWButton(BMWBaseEntity, ButtonEntity): await self.entity_description.remote_function(self.vehicle) elif self.entity_description.account_function: _LOGGER.warning( - "The 'Refresh from cloud' button is deprecated. Use the 'homeassistant.update_entity' " - "service with any BMW entity for a full reload. See https://www.home-assistant.io/" - "integrations/bmw_connected_drive/#update-the-state--refresh-from-api for details" + "The 'Refresh from cloud' button is deprecated. Use the" + " 'homeassistant.update_entity' service with any BMW entity for a full" + " reload. See" + " https://www.home-assistant.io/integrations/bmw_connected_drive/#update-the-state--refresh-from-api" + " for details" ) await self.entity_description.account_function(self.coordinator) diff --git a/homeassistant/components/bmw_connected_drive/device_tracker.py b/homeassistant/components/bmw_connected_drive/device_tracker.py index fc33335fe24..c94d9b5b678 100644 --- a/homeassistant/components/bmw_connected_drive/device_tracker.py +++ b/homeassistant/components/bmw_connected_drive/device_tracker.py @@ -31,7 +31,10 @@ async def async_setup_entry( entities.append(BMWDeviceTracker(coordinator, vehicle)) if not vehicle.is_vehicle_tracking_enabled: _LOGGER.info( - "Tracking is (currently) disabled for vehicle %s (%s), defaulting to unknown", + ( + "Tracking is (currently) disabled for vehicle %s (%s), defaulting" + " to unknown" + ), vehicle.name, vehicle.vin, ) diff --git a/homeassistant/components/bond/fan.py b/homeassistant/components/bond/fan.py index bd4f01bce52..a856af83bb8 100644 --- a/homeassistant/components/bond/fan.py +++ b/homeassistant/components/bond/fan.py @@ -151,7 +151,8 @@ class BondFan(BondEntity, FanEntity): ) except ClientResponseError as ex: raise HomeAssistantError( - f"The bond API returned an error calling set_power_state_belief for {self.entity_id}. Code: {ex.code} Message: {ex.message}" + "The bond API returned an error calling set_power_state_belief for" + f" {self.entity_id}. Code: {ex.code} Message: {ex.message}" ) from ex async def async_set_speed_belief(self, speed: int) -> None: @@ -175,7 +176,8 @@ class BondFan(BondEntity, FanEntity): ) except ClientResponseError as ex: raise HomeAssistantError( - f"The bond API returned an error calling set_speed_belief for {self.entity_id}. Code: {ex.code} Message: {ex.message}" + "The bond API returned an error calling set_speed_belief for" + f" {self.entity_id}. Code: {ex.code} Message: {ex.message}" ) from ex async def async_turn_on( diff --git a/homeassistant/components/bond/light.py b/homeassistant/components/bond/light.py index 2fcff44ddc1..2380321cc4c 100644 --- a/homeassistant/components/bond/light.py +++ b/homeassistant/components/bond/light.py @@ -137,7 +137,8 @@ class BondBaseLight(BondEntity, LightEntity): ) except ClientResponseError as ex: raise HomeAssistantError( - f"The bond API returned an error calling set_brightness_belief for {self.entity_id}. Code: {ex.code} Message: {ex.message}" + "The bond API returned an error calling set_brightness_belief for" + f" {self.entity_id}. Code: {ex.code} Message: {ex.message}" ) from ex async def async_set_power_belief(self, power_state: bool) -> None: @@ -148,7 +149,8 @@ class BondBaseLight(BondEntity, LightEntity): ) except ClientResponseError as ex: raise HomeAssistantError( - f"The bond API returned an error calling set_light_state_belief for {self.entity_id}. Code: {ex.code} Message: {ex.message}" + "The bond API returned an error calling set_light_state_belief for" + f" {self.entity_id}. Code: {ex.code} Message: {ex.message}" ) from ex @@ -197,7 +199,8 @@ class BondLight(BondBaseLight, BondEntity, LightEntity): async def async_start_increasing_brightness(self) -> None: """Start increasing the light brightness.""" _LOGGER.warning( - "The bond.start_increasing_brightness service is deprecated and has been replaced with a button; Call the button.press service instead" + "The bond.start_increasing_brightness service is deprecated and has been" + " replaced with a button; Call the button.press service instead" ) self._async_has_action_or_raise(Action.START_INCREASING_BRIGHTNESS) await self._hub.bond.action( @@ -207,7 +210,8 @@ class BondLight(BondBaseLight, BondEntity, LightEntity): async def async_start_decreasing_brightness(self) -> None: """Start decreasing the light brightness.""" _LOGGER.warning( - "The bond.start_decreasing_brightness service is deprecated and has been replaced with a button; Call the button.press service instead" + "The bond.start_decreasing_brightness service is deprecated and has been" + " replaced with a button; Call the button.press service instead" ) self._async_has_action_or_raise(Action.START_DECREASING_BRIGHTNESS) await self._hub.bond.action( @@ -217,7 +221,8 @@ class BondLight(BondBaseLight, BondEntity, LightEntity): async def async_stop(self) -> None: """Stop all actions and clear the queue.""" _LOGGER.warning( - "The bond.stop service is deprecated and has been replaced with a button; Call the button.press service instead" + "The bond.stop service is deprecated and has been replaced with a button;" + " Call the button.press service instead" ) self._async_has_action_or_raise(Action.STOP) await self._hub.bond.action(self._device.device_id, Action(Action.STOP)) @@ -307,7 +312,8 @@ class BondFireplace(BondEntity, LightEntity): ) except ClientResponseError as ex: raise HomeAssistantError( - f"The bond API returned an error calling set_brightness_belief for {self.entity_id}. Code: {ex.code} Message: {ex.message}" + "The bond API returned an error calling set_brightness_belief for" + f" {self.entity_id}. Code: {ex.code} Message: {ex.message}" ) from ex async def async_set_power_belief(self, power_state: bool) -> None: @@ -318,5 +324,6 @@ class BondFireplace(BondEntity, LightEntity): ) except ClientResponseError as ex: raise HomeAssistantError( - f"The bond API returned an error calling set_power_state_belief for {self.entity_id}. Code: {ex.code} Message: {ex.message}" + "The bond API returned an error calling set_power_state_belief for" + f" {self.entity_id}. Code: {ex.code} Message: {ex.message}" ) from ex diff --git a/homeassistant/components/bond/switch.py b/homeassistant/components/bond/switch.py index afa5e1cee10..c0ff6368e5a 100644 --- a/homeassistant/components/bond/switch.py +++ b/homeassistant/components/bond/switch.py @@ -64,5 +64,6 @@ class BondSwitch(BondEntity, SwitchEntity): ) except ClientResponseError as ex: raise HomeAssistantError( - f"The bond API returned an error calling set_power_state_belief for {self.entity_id}. Code: {ex.code} Message: {ex.message}" + "The bond API returned an error calling set_power_state_belief for" + f" {self.entity_id}. Code: {ex.code} Message: {ex.message}" ) from ex diff --git a/homeassistant/components/broadlink/config_flow.py b/homeassistant/components/broadlink/config_flow.py index 5a0ed45b2ba..39c470ad77b 100644 --- a/homeassistant/components/broadlink/config_flow.py +++ b/homeassistant/components/broadlink/config_flow.py @@ -39,8 +39,10 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): """Define a device for the config flow.""" if device.type not in DEVICE_TYPES: _LOGGER.error( - "Unsupported device: %s. If it worked before, please open " - "an issue at https://github.com/home-assistant/core/issues", + ( + "Unsupported device: %s. If it worked before, please open " + "an issue at https://github.com/home-assistant/core/issues" + ), hex(device.devtype), ) raise AbortFlow("not_supported") @@ -175,9 +177,11 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): await self.async_set_unique_id(device.mac.hex()) if self.source == config_entries.SOURCE_IMPORT: _LOGGER.warning( - "%s (%s at %s) is ready to be configured. Click " - "Configuration in the sidebar, click Integrations and " - "click Configure on the device to complete the setup", + ( + "%s (%s at %s) is ready to be configured. Click " + "Configuration in the sidebar, click Integrations and " + "click Configure on the device to complete the setup" + ), device.name, device.model, device.host[0], diff --git a/homeassistant/components/broadlink/device.py b/homeassistant/components/broadlink/device.py index c279e7860b6..99239e3030a 100644 --- a/homeassistant/components/broadlink/device.py +++ b/homeassistant/components/broadlink/device.py @@ -175,9 +175,11 @@ class BroadlinkDevice: self.authorized = False _LOGGER.error( - "%s (%s at %s) is locked. Click Configuration in the sidebar, " - "click Integrations, click Configure on the device and follow " - "the instructions to unlock it", + ( + "%s (%s at %s) is locked. Click Configuration in the sidebar, " + "click Integrations, click Configure on the device and follow " + "the instructions to unlock it" + ), self.name, self.api.model, self.api.host[0], diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index 803abefef00..f329be16f1d 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -836,7 +836,10 @@ async def ws_camera_web_rtc_offer( connection.send_error( msg["id"], "web_rtc_offer_failed", - f"Camera does not support WebRTC, frontend_stream_type={camera.frontend_stream_type}", + ( + "Camera does not support WebRTC," + f" frontend_stream_type={camera.frontend_stream_type}" + ), ) return try: diff --git a/homeassistant/components/camera/prefs.py b/homeassistant/components/camera/prefs.py index 0a8785457e8..f1bb0a0a840 100644 --- a/homeassistant/components/camera/prefs.py +++ b/homeassistant/components/camera/prefs.py @@ -73,7 +73,8 @@ class CameraPreferences: ) else: raise HomeAssistantError( - "Orientation is only supported on entities set up through config flows" + "Orientation is only supported on entities set up through config" + " flows" ) if dynamic_stream_settings: dynamic_stream_settings.orientation = orientation diff --git a/homeassistant/components/cast/helpers.py b/homeassistant/components/cast/helpers.py index 48f57c39bd5..26759ca9606 100644 --- a/homeassistant/components/cast/helpers.py +++ b/homeassistant/components/cast/helpers.py @@ -76,7 +76,10 @@ class ChromecastInfo: ) _LOGGER.info( - "Fetched cast details for unknown model '%s' manufacturer: '%s', type: '%s'. Please %s", + ( + "Fetched cast details for unknown model '%s' manufacturer:" + " '%s', type: '%s'. Please %s" + ), cast_info.model_name, cast_info.manufacturer, cast_info.cast_type, diff --git a/homeassistant/components/cast/home_assistant_cast.py b/homeassistant/components/cast/home_assistant_cast.py index dc15bc3440e..14aa454c2e0 100644 --- a/homeassistant/components/cast/home_assistant_cast.py +++ b/homeassistant/components/cast/home_assistant_cast.py @@ -16,7 +16,10 @@ from .const import DOMAIN, SIGNAL_HASS_CAST_SHOW_VIEW SERVICE_SHOW_VIEW = "show_lovelace_view" ATTR_VIEW_PATH = "view_path" ATTR_URL_PATH = "dashboard_path" -NO_URL_AVAILABLE_ERROR = "Home Assistant Cast requires your instance to be reachable via HTTPS. Enable Home Assistant Cloud or set up an external URL with valid SSL certificates" +NO_URL_AVAILABLE_ERROR = ( + "Home Assistant Cast requires your instance to be reachable via HTTPS. Enable Home" + " Assistant Cloud or set up an external URL with valid SSL certificates" +) async def async_setup_ha_cast( diff --git a/homeassistant/components/cast/media_player.py b/homeassistant/components/cast/media_player.py index ee39cbd2868..b18c2ccb133 100644 --- a/homeassistant/components/cast/media_player.py +++ b/homeassistant/components/cast/media_player.py @@ -396,9 +396,11 @@ class CastMediaPlayerEntity(CastDevice, MediaPlayerEntity): url_description = f" from internal_url ({internal_url})" _LOGGER.error( - "Failed to cast media %s%s. Please make sure the URL is: " - "Reachable from the cast device and either a publicly resolvable " - "hostname or an IP address", + ( + "Failed to cast media %s%s. Please make sure the URL is: " + "Reachable from the cast device and either a publicly resolvable " + "hostname or an IP address" + ), media_status.content_id, url_description, ) diff --git a/homeassistant/components/cloud/alexa_config.py b/homeassistant/components/cloud/alexa_config.py index 1e59c9a6512..8f9c1775721 100644 --- a/homeassistant/components/cloud/alexa_config.py +++ b/homeassistant/components/cloud/alexa_config.py @@ -178,9 +178,11 @@ class CloudAlexaConfig(alexa_config.AbstractConfig): if self.should_report_state: persistent_notification.async_create( self.hass, - f"There was an error reporting state to Alexa ({body['reason']}). " - "Please re-link your Alexa skill via the Alexa app to " - "continue using it.", + ( + "There was an error reporting state to Alexa" + f" ({body['reason']}). Please re-link your Alexa skill via" + " the Alexa app to continue using it." + ), "Alexa state reporting disabled", "cloud_alexa_report", ) diff --git a/homeassistant/components/cloud/client.py b/homeassistant/components/cloud/client.py index 04b9a9aab97..08d43644249 100644 --- a/homeassistant/components/cloud/client.py +++ b/homeassistant/components/cloud/client.py @@ -142,7 +142,10 @@ class CloudClient(Interface): except aiohttp.ClientError as err: # If no internet available yet if self._hass.is_running: logging.getLogger(__package__).warning( - "Unable to activate Alexa Report State: %s. Retrying in 30 seconds", + ( + "Unable to activate Alexa Report State: %s. Retrying in 30" + " seconds" + ), err, ) async_call_later(self._hass, 30, enable_alexa) diff --git a/homeassistant/components/cloud/http_api.py b/homeassistant/components/cloud/http_api.py index 4345afae746..ea1a0aa27e6 100644 --- a/homeassistant/components/cloud/http_api.py +++ b/homeassistant/components/cloud/http_api.py @@ -386,8 +386,10 @@ async def websocket_update_prefs( connection.send_error( msg["id"], "alexa_relink", - "Please go to the Alexa app and re-link the Home Assistant " - "skill and then try to enable state reporting.", + ( + "Please go to the Alexa app and re-link the Home Assistant " + "skill and then try to enable state reporting." + ), ) await alexa_config.set_authorized(False) return diff --git a/homeassistant/components/cloud/stt.py b/homeassistant/components/cloud/stt.py index b1798b2f3be..70618ab38ef 100644 --- a/homeassistant/components/cloud/stt.py +++ b/homeassistant/components/cloud/stt.py @@ -91,7 +91,10 @@ class CloudProvider(Provider): self, metadata: SpeechMetadata, stream: StreamReader ) -> SpeechResult: """Process an audio stream to STT service.""" - content = f"audio/{metadata.format!s}; codecs=audio/{metadata.codec!s}; samplerate=16000" + content = ( + f"audio/{metadata.format!s}; codecs=audio/{metadata.codec!s};" + " samplerate=16000" + ) # Process STT try: diff --git a/homeassistant/components/cloud/subscription.py b/homeassistant/components/cloud/subscription.py index 4c18b4f0253..b85a50b20cd 100644 --- a/homeassistant/components/cloud/subscription.py +++ b/homeassistant/components/cloud/subscription.py @@ -21,7 +21,10 @@ async def async_subscription_info(cloud: Cloud) -> dict[str, Any] | None: return await cloud_api.async_subscription_info(cloud) except asyncio.TimeoutError: _LOGGER.error( - "A timeout of %s was reached while trying to fetch subscription information", + ( + "A timeout of %s was reached while trying to fetch subscription" + " information" + ), REQUEST_TIMEOUT, ) except ClientError: diff --git a/homeassistant/components/coinbase/sensor.py b/homeassistant/components/coinbase/sensor.py index e264fed0215..abd113e71ad 100644 --- a/homeassistant/components/coinbase/sensor.py +++ b/homeassistant/components/coinbase/sensor.py @@ -75,8 +75,10 @@ async def async_setup_entry( for currency in desired_currencies: if currency not in provided_currencies: _LOGGER.warning( - "The currency %s is no longer provided by your account, please check " - "your settings in Coinbase's developer tools", + ( + "The currency %s is no longer provided by your account, please" + " check your settings in Coinbase's developer tools" + ), currency, ) continue diff --git a/homeassistant/components/color_extractor/__init__.py b/homeassistant/components/color_extractor/__init__.py index b0884643be9..61ec27b3241 100644 --- a/homeassistant/components/color_extractor/__init__.py +++ b/homeassistant/components/color_extractor/__init__.py @@ -104,7 +104,10 @@ async def async_setup(hass: HomeAssistant, hass_config: ConfigType) -> bool: """Handle call for URL based image.""" if not hass.config.is_allowed_external_url(url): _LOGGER.error( - "External URL '%s' is not allowed, please add to 'allowlist_external_urls'", + ( + "External URL '%s' is not allowed, please add to" + " 'allowlist_external_urls'" + ), url, ) return None @@ -134,7 +137,10 @@ async def async_setup(hass: HomeAssistant, hass_config: ConfigType) -> bool: """Handle call for local file based image.""" if not hass.config.is_allowed_path(file_path): _LOGGER.error( - "File path '%s' is not allowed, please add to 'allowlist_external_dirs'", + ( + "File path '%s' is not allowed, please add to" + " 'allowlist_external_dirs'" + ), file_path, ) return None diff --git a/homeassistant/components/compensation/__init__.py b/homeassistant/components/compensation/__init__.py index 9fb5b8e9b2b..e36737c7d35 100644 --- a/homeassistant/components/compensation/__init__.py +++ b/homeassistant/components/compensation/__init__.py @@ -35,7 +35,8 @@ def datapoints_greater_than_degree(value: dict) -> dict: """Validate data point list is greater than polynomial degrees.""" if len(value[CONF_DATAPOINTS]) <= value[CONF_DEGREE]: raise vol.Invalid( - f"{CONF_DATAPOINTS} must have at least {value[CONF_DEGREE]+1} {CONF_DATAPOINTS}" + f"{CONF_DATAPOINTS} must have at least" + f" {value[CONF_DEGREE]+1} {CONF_DATAPOINTS}" ) return value diff --git a/homeassistant/components/control4/__init__.py b/homeassistant/components/control4/__init__.py index 4253a4eca02..c99af1f89ce 100644 --- a/homeassistant/components/control4/__init__.py +++ b/homeassistant/components/control4/__init__.py @@ -60,7 +60,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: raise ConfigEntryNotReady from exception except BadCredentials as exception: _LOGGER.error( - "Error authenticating with Control4 account API, incorrect username or password: %s", + ( + "Error authenticating with Control4 account API, incorrect username or" + " password: %s" + ), exception, ) return False diff --git a/homeassistant/components/control4/light.py b/homeassistant/components/control4/light.py index 1f738803c2e..2c92010901b 100644 --- a/homeassistant/components/control4/light.py +++ b/homeassistant/components/control4/light.py @@ -115,7 +115,10 @@ async def async_setup_entry( director = entry_data[CONF_DIRECTOR] item_variables = await director.getItemVariables(item_id) _LOGGER.warning( - "Couldn't get light state data for %s, skipping setup. Available variables from Control4: %s", + ( + "Couldn't get light state data for %s, skipping setup. Available" + " variables from Control4: %s" + ), item_name, item_variables, ) diff --git a/homeassistant/components/daikin/config_flow.py b/homeassistant/components/daikin/config_flow.py index e8ac9950a51..a64f2059972 100644 --- a/homeassistant/components/daikin/config_flow.py +++ b/homeassistant/components/daikin/config_flow.py @@ -134,8 +134,10 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): devices = Discovery().poll(ip=discovery_info.host) if not devices: _LOGGER.debug( - "Could not find MAC-address for %s," - " make sure the required UDP ports are open (see integration documentation)", + ( + "Could not find MAC-address for %s, make sure the required UDP" + " ports are open (see integration documentation)" + ), discovery_info.host, ) return self.async_abort(reason="cannot_connect") diff --git a/homeassistant/components/deconz/logbook.py b/homeassistant/components/deconz/logbook.py index 42620cf3df6..67801b84344 100644 --- a/homeassistant/components/deconz/logbook.py +++ b/homeassistant/components/deconz/logbook.py @@ -185,7 +185,9 @@ def async_describe_events( return { LOGBOOK_ENTRY_NAME: name, - LOGBOOK_ENTRY_MESSAGE: f"'{ACTIONS[action]}' event for '{INTERFACES[interface]}' was fired", + LOGBOOK_ENTRY_MESSAGE: ( + f"'{ACTIONS[action]}' event for '{INTERFACES[interface]}' was fired" + ), } async_describe_event( diff --git a/homeassistant/components/deluge/__init__.py b/homeassistant/components/deluge/__init__.py index 566b97b5b04..97605d08fe9 100644 --- a/homeassistant/components/deluge/__init__.py +++ b/homeassistant/components/deluge/__init__.py @@ -80,7 +80,9 @@ class DelugeEntity(CoordinatorEntity[DelugeDataUpdateCoordinator]): super().__init__(coordinator) self._server_unique_id = coordinator.config_entry.entry_id self._attr_device_info = DeviceInfo( - configuration_url=f"http://{coordinator.api.host}:{coordinator.api.web_port}", + configuration_url=( + f"http://{coordinator.api.host}:{coordinator.api.web_port}" + ), entry_type=DeviceEntryType.SERVICE, identifiers={(DOMAIN, coordinator.config_entry.entry_id)}, manufacturer=DEFAULT_NAME, diff --git a/homeassistant/components/denonavr/config_flow.py b/homeassistant/components/denonavr/config_flow.py index 2ec58df8126..2afe5828530 100644 --- a/homeassistant/components/denonavr/config_flow.py +++ b/homeassistant/components/denonavr/config_flow.py @@ -199,8 +199,10 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): self._abort_if_unique_id_configured() else: _LOGGER.error( - "Could not get serial number of host %s, " - "unique_id's will not be available", + ( + "Could not get serial number of host %s, " + "unique_id's will not be available" + ), self.host, ) self._async_abort_entries_match({CONF_HOST: self.host}) diff --git a/homeassistant/components/denonavr/media_player.py b/homeassistant/components/denonavr/media_player.py index aa1fb7361e2..e1bd0f41808 100644 --- a/homeassistant/components/denonavr/media_player.py +++ b/homeassistant/components/denonavr/media_player.py @@ -159,8 +159,10 @@ def async_log_errors( available = False if self.available: _LOGGER.warning( - "Timeout connecting to Denon AVR receiver at host %s. " - "Device is unavailable", + ( + "Timeout connecting to Denon AVR receiver at host %s. " + "Device is unavailable" + ), self._receiver.host, ) self._attr_available = False @@ -168,8 +170,10 @@ def async_log_errors( available = False if self.available: _LOGGER.warning( - "Network error connecting to Denon AVR receiver at host %s. " - "Device is unavailable", + ( + "Network error connecting to Denon AVR receiver at host %s. " + "Device is unavailable" + ), self._receiver.host, ) self._attr_available = False @@ -177,9 +181,11 @@ def async_log_errors( available = False if self.available: _LOGGER.warning( - "Denon AVR receiver at host %s responded with HTTP 403 error. " - "Device is unavailable. Please consider power cycling your " - "receiver", + ( + "Denon AVR receiver at host %s responded with HTTP 403 error. " + "Device is unavailable. Please consider power cycling your " + "receiver" + ), self._receiver.host, ) self._attr_available = False diff --git a/homeassistant/components/denonavr/receiver.py b/homeassistant/components/denonavr/receiver.py index 28969d25792..7ea461f4e6f 100644 --- a/homeassistant/components/denonavr/receiver.py +++ b/homeassistant/components/denonavr/receiver.py @@ -51,7 +51,10 @@ class ConnectDenonAVR: or self._receiver.receiver_type is None ): _LOGGER.error( - "Missing receiver information: manufacturer '%s', name '%s', model '%s', type '%s'", + ( + "Missing receiver information: manufacturer '%s', name '%s', model" + " '%s', type '%s'" + ), self._receiver.manufacturer, self._receiver.name, self._receiver.model_name, diff --git a/homeassistant/components/device_tracker/legacy.py b/homeassistant/components/device_tracker/legacy.py index 09fd5dce432..bc792ee8920 100644 --- a/homeassistant/components/device_tracker/legacy.py +++ b/homeassistant/components/device_tracker/legacy.py @@ -379,8 +379,10 @@ def async_setup_scanner_platform( """Handle interval matches.""" if update_lock.locked(): LOGGER.warning( - "Updating device list from %s took longer than the scheduled " - "scan interval %s", + ( + "Updating device list from %s took longer than the scheduled " + "scan interval %s" + ), platform, interval, ) @@ -954,6 +956,6 @@ def get_gravatar_for_email(email: str) -> str: """ return ( - f"https://www.gravatar.com/avatar/" + "https://www.gravatar.com/avatar/" f"{hashlib.md5(email.encode('utf-8').lower()).hexdigest()}.jpg?s=80&d=wavatar" ) diff --git a/homeassistant/components/dialogflow/__init__.py b/homeassistant/components/dialogflow/__init__.py index 30c85ac7599..d34b27233be 100644 --- a/homeassistant/components/dialogflow/__init__.py +++ b/homeassistant/components/dialogflow/__init__.py @@ -106,7 +106,8 @@ async def async_handle_message(hass, message): _api_version = get_api_version(message) if _api_version is V1: _LOGGER.warning( - "Dialogflow V1 API will be removed on October 23, 2019. Please change your DialogFlow settings to use the V2 api" + "Dialogflow V1 API will be removed on October 23, 2019. Please change your" + " DialogFlow settings to use the V2 api" ) req = message.get("result") if req.get("actionIncomplete", True): diff --git a/homeassistant/components/discogs/sensor.py b/homeassistant/components/discogs/sensor.py index 51c69449d22..5e2d4bfa770 100644 --- a/homeassistant/components/discogs/sensor.py +++ b/homeassistant/components/discogs/sensor.py @@ -127,7 +127,9 @@ class DiscogsSensor(SensorEntity): return { "cat_no": self._attrs["labels"][0]["catno"], "cover_image": self._attrs["cover_image"], - "format": f"{self._attrs['formats'][0]['name']} ({self._attrs['formats'][0]['descriptions'][0]})", + "format": ( + f"{self._attrs['formats'][0]['name']} ({self._attrs['formats'][0]['descriptions'][0]})" + ), "label": self._attrs["labels"][0]["name"], "released": self._attrs["year"], ATTR_IDENTITY: self._discogs_data["user"], @@ -146,7 +148,10 @@ class DiscogsSensor(SensorEntity): random_record = collection.releases[random_index].release self._attrs = random_record.data - return f"{random_record.data['artists'][0]['name']} - {random_record.data['title']}" + return ( + f"{random_record.data['artists'][0]['name']} -" + f" {random_record.data['title']}" + ) return None diff --git a/homeassistant/components/discord/notify.py b/homeassistant/components/discord/notify.py index 8fcab7cefba..43301290490 100644 --- a/homeassistant/components/discord/notify.py +++ b/homeassistant/components/discord/notify.py @@ -87,7 +87,10 @@ class DiscordNotificationService(BaseNotificationService): if content_length is not None and int(content_length) > max_file_size: _LOGGER.error( - "Attachment too large (Content-Length reports %s). Max size: %s bytes", + ( + "Attachment too large (Content-Length reports %s). Max size: %s" + " bytes" + ), int(content_length), max_file_size, ) diff --git a/homeassistant/components/discovery/__init__.py b/homeassistant/components/discovery/__init__.py index 75016c28048..0ffd6fe49ef 100644 --- a/homeassistant/components/discovery/__init__.py +++ b/homeassistant/components/discovery/__init__.py @@ -146,8 +146,10 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: for platform in enabled_platforms: if platform in DEFAULT_ENABLED: logger.warning( - "Please remove %s from your discovery.enable configuration " - "as it is now enabled by default", + ( + "Please remove %s from your discovery.enable configuration " + "as it is now enabled by default" + ), platform, ) diff --git a/homeassistant/components/doods/image_processing.py b/homeassistant/components/doods/image_processing.py index 0265736c143..677aafc0b52 100644 --- a/homeassistant/components/doods/image_processing.py +++ b/homeassistant/components/doods/image_processing.py @@ -297,7 +297,10 @@ class Doods(ImageProcessingEntity): if self._aspect and abs((img_width / img_height) - self._aspect) > 0.1: _LOGGER.debug( - "The image aspect: %s and the detector aspect: %s differ by more than 0.1", + ( + "The image aspect: %s and the detector aspect: %s differ by more" + " than 0.1" + ), (img_width / img_height), self._aspect, ) diff --git a/homeassistant/components/doorbird/__init__.py b/homeassistant/components/doorbird/__init__.py index 62554f9662c..f5b2d2aad32 100644 --- a/homeassistant/components/doorbird/__init__.py +++ b/homeassistant/components/doorbird/__init__.py @@ -175,10 +175,12 @@ async def _async_register_events( except requests.exceptions.HTTPError: persistent_notification.async_create( hass, - "Doorbird configuration failed. Please verify that API " - "Operator permission is enabled for the Doorbird user. " - "A restart will be required once permissions have been " - "verified.", + ( + "Doorbird configuration failed. Please verify that API " + "Operator permission is enabled for the Doorbird user. " + "A restart will be required once permissions have been " + "verified." + ), title="Doorbird Configuration Failure", notification_id="doorbird_schedule_error", ) diff --git a/homeassistant/components/ecobee/climate.py b/homeassistant/components/ecobee/climate.py index b5512ce3c88..24609bcd0af 100644 --- a/homeassistant/components/ecobee/climate.py +++ b/homeassistant/components/ecobee/climate.py @@ -181,11 +181,13 @@ async def async_setup_entry( thermostat = data.ecobee.get_thermostat(index) if not thermostat["modelNumber"] in ECOBEE_MODEL_TO_NAME: _LOGGER.error( - "Model number for ecobee thermostat %s not recognized. " - "Please visit this link to open a new issue: " - "https://github.com/home-assistant/core/issues " - "and include the following information: " - "Unrecognized model number: %s", + ( + "Model number for ecobee thermostat %s not recognized. " + "Please visit this link to open a new issue: " + "https://github.com/home-assistant/core/issues " + "and include the following information: " + "Unrecognized model number: %s" + ), thermostat["name"], thermostat["modelNumber"], ) @@ -794,8 +796,10 @@ class Thermostat(ClimateEntity): } _LOGGER.debug( - "Creating a vacation on thermostat %s with name %s, cool temp %s, heat temp %s, " - "and the following other parameters: %s", + ( + "Creating a vacation on thermostat %s with name %s, cool temp %s, heat" + " temp %s, and the following other parameters: %s" + ), self.name, vacation_name, cool_temp, diff --git a/homeassistant/components/ecobee/config_flow.py b/homeassistant/components/ecobee/config_flow.py index 0bc9df2ea78..304730e6dbf 100644 --- a/homeassistant/components/ecobee/config_flow.py +++ b/homeassistant/components/ecobee/config_flow.py @@ -94,7 +94,8 @@ class EcobeeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): } except (HomeAssistantError, KeyError): _LOGGER.debug( - "No valid ecobee.conf configuration found for import, delegating to user step" + "No valid ecobee.conf configuration found for import, delegating to" + " user step" ) return await self.async_step_user( user_input={ @@ -106,7 +107,8 @@ class EcobeeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): if await self.hass.async_add_executor_job(ecobee.refresh_tokens): # Credentials found and validated; create the entry. _LOGGER.debug( - "Valid ecobee configuration found for import, creating configuration entry" + "Valid ecobee configuration found for import, creating configuration" + " entry" ) return self.async_create_entry( title=DOMAIN, diff --git a/homeassistant/components/ecobee/humidifier.py b/homeassistant/components/ecobee/humidifier.py index 93d658a9ddc..502e84b7866 100644 --- a/homeassistant/components/ecobee/humidifier.py +++ b/homeassistant/components/ecobee/humidifier.py @@ -137,7 +137,8 @@ class EcobeeHumidifier(HumidifierEntity): """Set humidifier mode (auto, off, manual).""" if mode.lower() not in (self.available_modes): raise ValueError( - f"Invalid mode value: {mode} Valid values are {', '.join(self.available_modes)}." + f"Invalid mode value: {mode} Valid values are" + f" {', '.join(self.available_modes)}." ) self.data.ecobee.set_humidifier_mode(self.thermostat_index, mode) diff --git a/homeassistant/components/eddystone_temperature/sensor.py b/homeassistant/components/eddystone_temperature/sensor.py index 8e5e7ce48da..d3f70730a48 100644 --- a/homeassistant/components/eddystone_temperature/sensor.py +++ b/homeassistant/components/eddystone_temperature/sensor.py @@ -101,8 +101,10 @@ def get_from_conf(config: dict[str, str], config_key: str, length: int) -> str | string = config[config_key] if len(string) != length: _LOGGER.error( - "Error in configuration parameter %s: Must be exactly %d " - "bytes. Device will not be added", + ( + "Error in configuration parameter %s: Must be exactly %d " + "bytes. Device will not be added" + ), config_key, length / 2, ) diff --git a/homeassistant/components/egardia/alarm_control_panel.py b/homeassistant/components/egardia/alarm_control_panel.py index de179c248bb..60b80fffd23 100644 --- a/homeassistant/components/egardia/alarm_control_panel.py +++ b/homeassistant/components/egardia/alarm_control_panel.py @@ -145,8 +145,7 @@ class EgardiaAlarm(alarm.AlarmControlPanelEntity): self._egardiasystem.alarm_arm_home() except requests.exceptions.RequestException as err: _LOGGER.error( - "Egardia device exception occurred when " - "sending arm home command: %s", + "Egardia device exception occurred when sending arm home command: %s", err, ) @@ -156,7 +155,6 @@ class EgardiaAlarm(alarm.AlarmControlPanelEntity): self._egardiasystem.alarm_arm_away() except requests.exceptions.RequestException as err: _LOGGER.error( - "Egardia device exception occurred when " - "sending arm away command: %s", + "Egardia device exception occurred when sending arm away command: %s", err, ) diff --git a/homeassistant/components/elmax/common.py b/homeassistant/components/elmax/common.py index 80738478a49..f1ffe87fde9 100644 --- a/homeassistant/components/elmax/common.py +++ b/homeassistant/components/elmax/common.py @@ -96,7 +96,8 @@ class ElmaxCoordinator(DataUpdateCoordinator[PanelStatus]): # reconfigure it in order to make it work again if not panel: raise ConfigEntryAuthFailed( - f"Panel ID {self._panel_id} is no more linked to this user account" + f"Panel ID {self._panel_id} is no more linked to this user" + " account" ) self._panel_entry = panel diff --git a/homeassistant/components/emoncms/sensor.py b/homeassistant/components/emoncms/sensor.py index f91be8da556..f9382d1060b 100644 --- a/homeassistant/components/emoncms/sensor.py +++ b/homeassistant/components/emoncms/sensor.py @@ -290,8 +290,10 @@ class EmonCmsData: self.data = req.json() else: _LOGGER.error( - "Please verify if the specified configuration value " - "'%s' is correct! (HTTP Status_code = %d)", + ( + "Please verify if the specified configuration value " + "'%s' is correct! (HTTP Status_code = %d)" + ), CONF_URL, req.status_code, ) diff --git a/homeassistant/components/esphome/__init__.py b/homeassistant/components/esphome/__init__.py index b7251ef761c..53ad1fd267c 100644 --- a/homeassistant/components/esphome/__init__.py +++ b/homeassistant/components/esphome/__init__.py @@ -480,7 +480,10 @@ async def _register_service( ) service_desc = { - "description": f"Calls the service {service.name} of the node {entry_data.device_info.name}", + "description": ( + f"Calls the service {service.name} of the node" + f" {entry_data.device_info.name}" + ), "fields": fields, } @@ -706,10 +709,7 @@ class EsphomeEntity(Entity, Generic[_InfoT, _StateT]): self.async_on_remove( async_dispatcher_connect( self.hass, - ( - f"esphome_{self._entry_id}_remove_" - f"{self._component_key}_{self._key}" - ), + f"esphome_{self._entry_id}_remove_{self._component_key}_{self._key}", functools.partial(self.async_remove, force_remove=True), ) ) diff --git a/homeassistant/components/esphome/bluetooth/__init__.py b/homeassistant/components/esphome/bluetooth/__init__.py index 2ec321336ee..4a70b906b1f 100644 --- a/homeassistant/components/esphome/bluetooth/__init__.py +++ b/homeassistant/components/esphome/bluetooth/__init__.py @@ -33,7 +33,10 @@ def _async_can_connect_factory( """Check if a given source can make another connection.""" can_connect = bool(entry_data.available and entry_data.ble_connections_free) _LOGGER.debug( - "%s [%s]: Checking can connect, available=%s, ble_connections_free=%s result=%s", + ( + "%s [%s]: Checking can connect, available=%s, ble_connections_free=%s" + " result=%s" + ), entry_data.name, source, entry_data.available, diff --git a/homeassistant/components/esphome/bluetooth/client.py b/homeassistant/components/esphome/bluetooth/client.py index 073c3f2ca6a..6aa21c315a3 100644 --- a/homeassistant/components/esphome/bluetooth/client.py +++ b/homeassistant/components/esphome/bluetooth/client.py @@ -168,7 +168,10 @@ class ESPHomeClient(BaseBleakClient): self._cancel_connection_state() except (AssertionError, ValueError) as ex: _LOGGER.debug( - "%s: %s - %s: Failed to unsubscribe from connection state (likely connection dropped): %s", + ( + "%s: %s - %s: Failed to unsubscribe from connection state (likely" + " connection dropped): %s" + ), self._source_name, self._ble_device.name, self._ble_device.address, @@ -278,7 +281,8 @@ class ESPHomeClient(BaseBleakClient): ) connected_future.set_exception( BleakError( - f"Error {ble_connection_error_name} while connecting: {human_error}" + f"Error {ble_connection_error_name} while connecting:" + f" {human_error}" ) ) return @@ -587,7 +591,8 @@ class ESPHomeClient(BaseBleakClient): and "indicate" not in characteristic.properties ): raise BleakError( - f"Characteristic {characteristic.uuid} does not have notify or indicate property set." + f"Characteristic {characteristic.uuid} does not have notify or indicate" + " property set." ) self._notify_cancels[ @@ -614,7 +619,10 @@ class ESPHomeClient(BaseBleakClient): ) _LOGGER.debug( - "%s: %s - %s: Writing to CCD descriptor %s for notifications with properties=%s", + ( + "%s: %s - %s: Writing to CCD descriptor %s for notifications with" + " properties=%s" + ), self._source_name, self._ble_device.name, self._ble_device.address, @@ -652,7 +660,10 @@ class ESPHomeClient(BaseBleakClient): """Destructor to make sure the connection state is unsubscribed.""" if self._cancel_connection_state: _LOGGER.warning( - "%s: %s - %s: ESPHomeClient bleak client was not properly disconnected before destruction", + ( + "%s: %s - %s: ESPHomeClient bleak client was not properly" + " disconnected before destruction" + ), self._source_name, self._ble_device.name, self._ble_device.address, diff --git a/homeassistant/components/evohome/__init__.py b/homeassistant/components/evohome/__init__.py index b4010c435ee..162a56e837a 100644 --- a/homeassistant/components/evohome/__init__.py +++ b/homeassistant/components/evohome/__init__.py @@ -146,19 +146,23 @@ def _handle_exception(err) -> None: except evohomeasync2.AuthenticationError: _LOGGER.error( - "Failed to authenticate with the vendor's server. " - "Check your username and password. NB: Some special password characters " - "that work correctly via the website will not work via the web API. " - "Message is: %s", + ( + "Failed to authenticate with the vendor's server. Check your username" + " and password. NB: Some special password characters that work" + " correctly via the website will not work via the web API. Message" + " is: %s" + ), err, ) except aiohttp.ClientConnectionError: # this appears to be a common occurrence with the vendor's servers _LOGGER.warning( - "Unable to connect with the vendor's server. " - "Check your network and the vendor's service status page. " - "Message is: %s", + ( + "Unable to connect with the vendor's server. " + "Check your network and the vendor's service status page. " + "Message is: %s" + ), err, ) @@ -171,8 +175,10 @@ def _handle_exception(err) -> None: elif err.status == HTTPStatus.TOO_MANY_REQUESTS: _LOGGER.warning( - "The vendor's API rate limit has been exceeded. " - "If this message persists, consider increasing the %s", + ( + "The vendor's API rate limit has been exceeded. " + "If this message persists, consider increasing the %s" + ), CONF_SCAN_INTERVAL, ) @@ -224,8 +230,10 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: loc_config = client_v2.installation_info[loc_idx] except IndexError: _LOGGER.error( - "Config error: '%s' = %s, but the valid range is 0-%s. " - "Unable to continue. Fix any configuration errors and restart HA", + ( + "Config error: '%s' = %s, but the valid range is 0-%s. " + "Unable to continue. Fix any configuration errors and restart HA" + ), CONF_LOCATION_IDX, loc_idx, len(client_v2.installation_info) - 1, @@ -469,10 +477,12 @@ class EvoBroker: except aiohttp.ClientError as err: _LOGGER.warning( - "Unable to obtain the latest high-precision temperatures. " - "Check your network and the vendor's service status page. " - "Proceeding with low-precision temperatures. " - "Message is: %s", + ( + "Unable to obtain the latest high-precision temperatures. " + "Check your network and the vendor's service status page. " + "Proceeding with low-precision temperatures. " + "Message is: %s" + ), err, ) self.temps = None # these are now stale, will fall back to v2 temps diff --git a/homeassistant/components/evohome/climate.py b/homeassistant/components/evohome/climate.py index a7b8b19ce47..d4ee8f3d5df 100644 --- a/homeassistant/components/evohome/climate.py +++ b/homeassistant/components/evohome/climate.py @@ -112,8 +112,10 @@ async def async_setup_platform( else: _LOGGER.warning( - "Ignoring: %s (%s), id=%s, name=%s: unknown/invalid zone type, " - "report as an issue if you feel this zone type should be supported", + ( + "Ignoring: %s (%s), id=%s, name=%s: unknown/invalid zone type, " + "report as an issue if you feel this zone type should be supported" + ), zone.zoneType, zone.modelType, zone.zoneId, diff --git a/homeassistant/components/ezviz/camera.py b/homeassistant/components/ezviz/camera.py index 1f9de4f611c..9fb7c1f8b5a 100644 --- a/homeassistant/components/ezviz/camera.py +++ b/homeassistant/components/ezviz/camera.py @@ -108,7 +108,10 @@ async def async_setup_entry( ) _LOGGER.warning( - "Found camera with serial %s without configuration. Please go to integration to complete setup", + ( + "Found camera with serial %s without configuration. Please go to" + " integration to complete setup" + ), camera, ) diff --git a/homeassistant/components/fan/__init__.py b/homeassistant/components/fan/__init__.py index e143b93258e..6aa29d8b804 100644 --- a/homeassistant/components/fan/__init__.py +++ b/homeassistant/components/fan/__init__.py @@ -244,7 +244,8 @@ class FanEntity(ToggleEntity): preset_modes = self.preset_modes if not preset_modes or preset_mode not in preset_modes: raise NotValidPresetModeError( - f"The preset_mode {preset_mode} is not a valid preset_mode: {preset_modes}" + f"The preset_mode {preset_mode} is not a valid preset_mode:" + f" {preset_modes}" ) def set_direction(self, direction: str) -> None: diff --git a/homeassistant/components/fibaro/climate.py b/homeassistant/components/fibaro/climate.py index 0323f9dabd2..43bd99520e1 100644 --- a/homeassistant/components/fibaro/climate.py +++ b/homeassistant/components/fibaro/climate.py @@ -217,11 +217,13 @@ class FibaroThermostat(FibaroDevice, ClimateEntity): async def async_added_to_hass(self) -> None: """Call when entity is added to hass.""" _LOGGER.debug( - "Climate %s\n" - "- _temp_sensor_device %s\n" - "- _target_temp_device %s\n" - "- _op_mode_device %s\n" - "- _fan_mode_device %s", + ( + "Climate %s\n" + "- _temp_sensor_device %s\n" + "- _target_temp_device %s\n" + "- _op_mode_device %s\n" + "- _fan_mode_device %s" + ), self.ha_id, self._temp_sensor_device.ha_id if self._temp_sensor_device else "None", self._target_temp_device.ha_id if self._target_temp_device else "None", diff --git a/homeassistant/components/file/notify.py b/homeassistant/components/file/notify.py index eb9a512b230..4a0b4c11ca6 100644 --- a/homeassistant/components/file/notify.py +++ b/homeassistant/components/file/notify.py @@ -57,7 +57,10 @@ class FileNotificationService(BaseNotificationService): filepath: str = os.path.join(self.hass.config.config_dir, self.filename) with open(filepath, "a", encoding="utf8") as file: if os.stat(filepath).st_size == 0: - title = f"{kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)} notifications (Log started: {dt_util.utcnow().isoformat()})\n{'-' * 80}\n" + title = ( + f"{kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)} notifications (Log" + f" started: {dt_util.utcnow().isoformat()})\n{'-' * 80}\n" + ) file.write(title) if self.add_timestamp: diff --git a/homeassistant/components/firmata/board.py b/homeassistant/components/firmata/board.py index 002775edb0c..8b5c76e2582 100644 --- a/homeassistant/components/firmata/board.py +++ b/homeassistant/components/firmata/board.py @@ -92,8 +92,7 @@ class FirmataBoard: ) except RuntimeError as err: _LOGGER.error( - "Error setting sampling interval for PyMata \ -board %s: %s", + "Error setting sampling interval for PyMata board %s: %s", self.name, err, ) diff --git a/homeassistant/config.py b/homeassistant/config.py index e203c45f795..a4205461b30 100644 --- a/homeassistant/config.py +++ b/homeassistant/config.py @@ -277,8 +277,10 @@ CORE_CONFIG_SCHEMA = vol.All( { CONF_TYPE: vol.NotIn( ["insecure_example"], - "The insecure_example auth provider" - " is for testing only.", + ( + "The insecure_example auth provider" + " is for testing only." + ), ) } ) @@ -900,7 +902,10 @@ async def async_process_component_config( # noqa: C901 continue except Exception: # pylint: disable=broad-except _LOGGER.exception( - "Unknown error validating %s platform config with %s component platform schema", + ( + "Unknown error validating %s platform config with %s component" + " platform schema" + ), p_name, domain, ) @@ -940,7 +945,10 @@ async def async_process_component_config( # noqa: C901 continue except Exception: # pylint: disable=broad-except _LOGGER.exception( - "Unknown error validating config for %s platform for %s component with PLATFORM_SCHEMA", + ( + "Unknown error validating config for %s platform for %s" + " component with PLATFORM_SCHEMA" + ), p_name, domain, ) diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index baad04d6378..0f3fb0a3aea 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -278,9 +278,11 @@ class ConfigEntry: disabled_by, ConfigEntryDisabler ): report( # type: ignore[unreachable] - "uses str for config entry disabled_by. This is deprecated and will " - "stop working in Home Assistant 2022.3, it should be updated to use " - "ConfigEntryDisabler instead", + ( + "uses str for config entry disabled_by. This is deprecated and will" + " stop working in Home Assistant 2022.3, it should be updated to" + " use ConfigEntryDisabler instead" + ), error_if_core=False, ) disabled_by = ConfigEntryDisabler(disabled_by) @@ -353,7 +355,10 @@ class ConfigEntry: integration.get_platform("config_flow") except ImportError as err: _LOGGER.error( - "Error importing platform config_flow from integration %s to set up %s configuration entry: %s", + ( + "Error importing platform config_flow from integration %s to" + " set up %s configuration entry: %s" + ), integration.domain, self.domain, err, @@ -410,14 +415,20 @@ class ConfigEntry: ready_message = f"ready yet: {message}" if message else "ready yet" if tries == 1: _LOGGER.warning( - "Config entry '%s' for %s integration not %s; Retrying in background", + ( + "Config entry '%s' for %s integration not %s; Retrying in" + " background" + ), self.title, self.domain, ready_message, ) else: _LOGGER.debug( - "Config entry '%s' for %s integration not %s; Retrying in %d seconds", + ( + "Config entry '%s' for %s integration not %s; Retrying in %d" + " seconds" + ), self.title, self.domain, ready_message, @@ -1065,8 +1076,9 @@ class ConfigEntries: if entry.state is not ConfigEntryState.NOT_LOADED: raise OperationNotAllowed( - f"The config entry {entry.title} ({entry.domain}) with entry_id {entry.entry_id}" - f" cannot be setup because is already loaded in the {entry.state} state" + f"The config entry {entry.title} ({entry.domain}) with entry_id" + f" {entry.entry_id} cannot be setup because is already loaded in the" + f" {entry.state} state" ) # Setup Component if not set up yet @@ -1090,8 +1102,9 @@ class ConfigEntries: if not entry.state.recoverable: raise OperationNotAllowed( - f"The config entry {entry.title} ({entry.domain}) with entry_id " - f"{entry.entry_id} cannot be unloaded because it is not in a recoverable state ({entry.state})" + f"The config entry {entry.title} ({entry.domain}) with entry_id" + f" {entry.entry_id} cannot be unloaded because it is not in a" + f" recoverable state ({entry.state})" ) return await entry.async_unload(self.hass) @@ -1126,9 +1139,11 @@ class ConfigEntries: disabled_by, ConfigEntryDisabler ): report( # type: ignore[unreachable] - "uses str for config entry disabled_by. This is deprecated and will " - "stop working in Home Assistant 2022.3, it should be updated to use " - "ConfigEntryDisabler instead", + ( + "uses str for config entry disabled_by. This is deprecated and will" + " stop working in Home Assistant 2022.3, it should be updated to" + " use ConfigEntryDisabler instead" + ), error_if_core=False, ) disabled_by = ConfigEntryDisabler(disabled_by) @@ -1225,8 +1240,10 @@ class ConfigEntries: ) -> None: """Forward the setup of an entry to platforms.""" report( - "called async_setup_platforms instead of awaiting async_forward_entry_setups; " - "this will fail in version 2022.12", + ( + "called async_setup_platforms instead of awaiting" + " async_forward_entry_setups; this will fail in version 2022.12" + ), # Raise this to warning once all core integrations have been migrated level=logging.DEBUG, error_if_core=False, @@ -1777,7 +1794,10 @@ class EntityRegistryDisabledHandler: self.changed = set() _LOGGER.info( - "Reloading configuration entries because disabled_by changed in entity registry: %s", + ( + "Reloading configuration entries because disabled_by changed in entity" + " registry: %s" + ), ", ".join(to_reload), ) diff --git a/homeassistant/core.py b/homeassistant/core.py index 82ee5216f4f..fee2e482e91 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -357,9 +357,12 @@ class HomeAssistant: await self.async_block_till_done() except asyncio.TimeoutError: _LOGGER.warning( - "Something is blocking Home Assistant from wrapping up the " - "start up phase. We're going to continue anyway. Please " - "report the following info at https://github.com/home-assistant/core/issues: %s", + ( + "Something is blocking Home Assistant from wrapping up the start up" + " phase. We're going to continue anyway. Please report the" + " following info at" + " https://github.com/home-assistant/core/issues: %s" + ), ", ".join(self.config.components), ) @@ -705,7 +708,8 @@ class HomeAssistant: await self.async_block_till_done() except asyncio.TimeoutError: _LOGGER.warning( - "Timed out waiting for shutdown stage 1 to complete, the shutdown will continue" + "Timed out waiting for shutdown stage 1 to complete, the shutdown will" + " continue" ) # stage 2 @@ -716,7 +720,8 @@ class HomeAssistant: await self.async_block_till_done() except asyncio.TimeoutError: _LOGGER.warning( - "Timed out waiting for shutdown stage 2 to complete, the shutdown will continue" + "Timed out waiting for shutdown stage 2 to complete, the shutdown will" + " continue" ) # stage 3 @@ -735,7 +740,8 @@ class HomeAssistant: await self.async_block_till_done() except asyncio.TimeoutError: _LOGGER.warning( - "Timed out waiting for shutdown stage 3 to complete, the shutdown will continue" + "Timed out waiting for shutdown stage 3 to complete, the shutdown will" + " continue" ) self.exit_code = exit_code @@ -825,7 +831,10 @@ class Event: def __repr__(self) -> str: """Return the representation.""" if self.data: - return f"" + return ( + f"" + ) return f"" @@ -1419,7 +1428,8 @@ class StateMachine: entity_id = entity_id.lower() if entity_id in self._states or entity_id in self._reservations: raise HomeAssistantError( - "async_reserve must not be called once the state is in the state machine." + "async_reserve must not be called once the state is in the state" + " machine." ) self._reservations.add(entity_id) diff --git a/homeassistant/data_entry_flow.py b/homeassistant/data_entry_flow.py index 1e568ad2c32..a98c616ffbc 100644 --- a/homeassistant/data_entry_flow.py +++ b/homeassistant/data_entry_flow.py @@ -308,7 +308,8 @@ class FlowManager(abc.ABC): FlowResultType.SHOW_PROGRESS_DONE, ): raise ValueError( - "Show progress can only transition to show progress or show progress done." + "Show progress can only transition to show progress or show" + " progress done." ) # If the result has changed from last result, fire event to update @@ -386,8 +387,10 @@ class FlowManager(abc.ABC): if not isinstance(result["type"], FlowResultType): result["type"] = FlowResultType(result["type"]) # type: ignore[unreachable] report( - "does not use FlowResultType enum for data entry flow result type. " - "This is deprecated and will stop working in Home Assistant 2022.9", + ( + "does not use FlowResultType enum for data entry flow result type. " + "This is deprecated and will stop working in Home Assistant 2022.9" + ), error_if_core=False, ) diff --git a/homeassistant/loader.py b/homeassistant/loader.py index d43eecda778..da3f2aaa6d3 100644 --- a/homeassistant/loader.py +++ b/homeassistant/loader.py @@ -318,7 +318,11 @@ def async_process_zeroconf_match_dict(entry: dict[str, Any]) -> dict[str, Any]: for moved_prop in MOVED_ZEROCONF_PROPS: if value := entry_without_type.pop(moved_prop, None): _LOGGER.warning( - 'Matching the zeroconf property "%s" at top-level is deprecated and should be moved into a properties dict; Check the developer documentation', + ( + 'Matching the zeroconf property "%s" at top-level is deprecated and' + " should be moved into a properties dict; Check the developer" + " documentation" + ), moved_prop, ) if "properties" not in entry_without_type: @@ -489,9 +493,12 @@ class Integration: _LOGGER.warning(CUSTOM_WARNING, integration.domain) if integration.version is None: _LOGGER.error( - "The custom integration '%s' does not have a " - "version key in the manifest file and was blocked from loading. " - "See https://developers.home-assistant.io/blog/2021/01/29/custom-integration-changes#versions for more details", + ( + "The custom integration '%s' does not have a version key in the" + " manifest file and was blocked from loading. See" + " https://developers.home-assistant.io/blog/2021/01/29/custom-integration-changes#versions" + " for more details" + ), integration.domain, ) return None @@ -508,9 +515,12 @@ class Integration: ) except AwesomeVersionException: _LOGGER.error( - "The custom integration '%s' does not have a " - "valid version key (%s) in the manifest file and was blocked from loading. " - "See https://developers.home-assistant.io/blog/2021/01/29/custom-integration-changes#versions for more details", + ( + "The custom integration '%s' does not have a valid version key" + " (%s) in the manifest file and was blocked from loading. See" + " https://developers.home-assistant.io/blog/2021/01/29/custom-integration-changes#versions" + " for more details" + ), integration.domain, integration.version, ) @@ -683,14 +693,20 @@ class Integration: self._all_dependencies_resolved = True except IntegrationNotFound as err: _LOGGER.error( - "Unable to resolve dependencies for %s: we are unable to resolve (sub)dependency %s", + ( + "Unable to resolve dependencies for %s: we are unable to resolve" + " (sub)dependency %s" + ), self.domain, err.domain, ) self._all_dependencies_resolved = False except CircularDependency as err: _LOGGER.error( - "Unable to resolve dependencies for %s: it contains a circular dependency: %s -> %s", + ( + "Unable to resolve dependencies for %s: it contains a circular" + " dependency: %s -> %s" + ), self.domain, err.from_domain, err.to_domain, @@ -919,7 +935,7 @@ def _load_file( if str(err) not in white_listed_errors: _LOGGER.exception( - ("Error loading %s. Make sure all dependencies are installed"), path + "Error loading %s. Make sure all dependencies are installed", path ) return None diff --git a/homeassistant/requirements.py b/homeassistant/requirements.py index 27472a2bbd8..5710c313903 100644 --- a/homeassistant/requirements.py +++ b/homeassistant/requirements.py @@ -261,7 +261,10 @@ class RequirementsManager: for req in missing: if req in self.install_failure_history: _LOGGER.info( - "Multiple attempts to install %s failed, install will be retried after next configuration check or restart", + ( + "Multiple attempts to install %s failed, install will be" + " retried after next configuration check or restart" + ), req, ) raise RequirementsNotFound(integration, [req]) diff --git a/homeassistant/setup.py b/homeassistant/setup.py index 1172ab00bd7..13467713e2d 100644 --- a/homeassistant/setup.py +++ b/homeassistant/setup.py @@ -253,8 +253,10 @@ async def _async_setup_component( result = await task except asyncio.TimeoutError: _LOGGER.error( - "Setup of %s is taking longer than %s seconds." - " Startup will proceed without waiting any longer", + ( + "Setup of %s is taking longer than %s seconds." + " Startup will proceed without waiting any longer" + ), domain, SLOW_SETUP_MAX_WAIT, )