Cleanup strings (#26243)

This commit is contained in:
Andrew Sayre 2019-08-27 18:08:09 -05:00 committed by Aaron Bach
parent 6525f8704a
commit 3c07a9b4c7
5 changed files with 11 additions and 21 deletions

View File

@ -78,8 +78,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
"""Initialize config entry which represents an installed SmartApp.""" """Initialize config entry which represents an installed SmartApp."""
if not validate_webhook_requirements(hass): if not validate_webhook_requirements(hass):
_LOGGER.warning( _LOGGER.warning(
"The 'base_url' of the 'http' integration must be " "The 'base_url' of the 'http' integration must be configured and start with 'https://'"
"configured and start with 'https://'"
) )
return False return False
@ -121,8 +120,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
await device.status.refresh() await device.status.refresh()
except ClientResponseError: except ClientResponseError:
_LOGGER.debug( _LOGGER.debug(
"Unable to update status for device: %s (%s), " "Unable to update status for device: %s (%s), the device will be excluded",
"the device will be excluded",
device.label, device.label,
device.device_id, device.device_id,
exc_info=True, exc_info=True,
@ -148,8 +146,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
except ClientResponseError as ex: except ClientResponseError as ex:
if ex.status in (401, 403): if ex.status in (401, 403):
_LOGGER.exception( _LOGGER.exception(
"Unable to setup config entry '%s' - please " "Unable to setup config entry '%s' - please reconfigure the integration",
"reconfigure the integration",
entry.title, entry.title,
) )
remove_entry = True remove_entry = True
@ -186,9 +183,7 @@ async def async_get_entry_scenes(entry: ConfigEntry, api):
except ClientResponseError as ex: except ClientResponseError as ex:
if ex.status == 403: if ex.status == 403:
_LOGGER.exception( _LOGGER.exception(
"Unable to load scenes for config entry '%s' " "Unable to load scenes for config entry '%s' because the access token does not have the required access",
"because the access token does not have the "
"required access",
entry.title, entry.title,
) )
else: else:
@ -235,7 +230,7 @@ async def async_remove_entry(hass: HomeAssistantType, entry: ConfigEntry) -> Non
app_count = sum(1 for entry in all_entries if entry.data[CONF_APP_ID] == app_id) app_count = sum(1 for entry in all_entries if entry.data[CONF_APP_ID] == app_id)
if app_count > 1: if app_count > 1:
_LOGGER.debug( _LOGGER.debug(
"App %s was not removed because it is in use by other" "config entries", "App %s was not removed because it is in use by other config entries",
app_id, app_id,
) )
return return

View File

@ -406,7 +406,7 @@ class SmartThingsAirConditioner(SmartThingsEntity, ClimateDevice):
modes.add(state) modes.add(state)
else: else:
_LOGGER.debug( _LOGGER.debug(
"Device %s (%s) returned an invalid supported " "AC mode: %s", "Device %s (%s) returned an invalid supported AC mode: %s",
self._device.label, self._device.label,
self._device.device_id, self._device.device_id,
mode, mode,

View File

@ -37,8 +37,5 @@ SUPPORTED_PLATFORMS = [
"scene", "scene",
] ]
TOKEN_REFRESH_INTERVAL = timedelta(days=14) TOKEN_REFRESH_INTERVAL = timedelta(days=14)
VAL_UID = ( VAL_UID = "^(?:([0-9a-fA-F]{32})|([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}))$"
"^(?:([0-9a-fA-F]{32})|([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]"
"{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}))$"
)
VAL_UID_MATCHER = re.compile(VAL_UID) VAL_UID_MATCHER = re.compile(VAL_UID)

View File

@ -77,8 +77,7 @@ async def validate_installed_app(api, installed_app_id: str):
installed_app = await api.installed_app(installed_app_id) installed_app = await api.installed_app(installed_app_id)
if installed_app.installed_app_status != InstalledAppStatus.AUTHORIZED: if installed_app.installed_app_status != InstalledAppStatus.AUTHORIZED:
raise RuntimeWarning( raise RuntimeWarning(
"Installed SmartApp instance '{}' ({}) is not " "Installed SmartApp instance '{}' ({}) is not AUTHORIZED but instead {}".format(
"AUTHORIZED but instead {}".format(
installed_app.display_name, installed_app.display_name,
installed_app.installed_app_id, installed_app.installed_app_id,
installed_app.installed_app_status, installed_app.installed_app_status,
@ -321,7 +320,7 @@ async def smartapp_sync_subscriptions(
) )
except Exception as error: # pylint:disable=broad-except except Exception as error: # pylint:disable=broad-except
_LOGGER.error( _LOGGER.error(
"Failed to create subscription for '%s' under app " "'%s': %s", "Failed to create subscription for '%s' under app '%s': %s",
target, target,
installed_app_id, installed_app_id,
error, error,
@ -331,8 +330,7 @@ async def smartapp_sync_subscriptions(
try: try:
await api.delete_subscription(installed_app_id, sub.subscription_id) await api.delete_subscription(installed_app_id, sub.subscription_id)
_LOGGER.debug( _LOGGER.debug(
"Removed subscription for '%s' under app '%s' " "Removed subscription for '%s' under app '%s' because it was no longer needed",
"because it was no longer needed",
sub.capability, sub.capability,
installed_app_id, installed_app_id,
) )

View File

@ -371,7 +371,7 @@ async def test_broker_regenerates_token(hass, config_entry):
stored_action = action stored_action = action
with patch( with patch(
"homeassistant.components.smartthings" ".async_track_time_interval", "homeassistant.components.smartthings.async_track_time_interval",
new=async_track_time_interval, new=async_track_time_interval,
): ):
broker = smartthings.DeviceBroker(hass, config_entry, token, Mock(), [], []) broker = smartthings.DeviceBroker(hass, config_entry, token, Mock(), [], [])