From 477caebfcb3ac62fb4baa0105e4e0ff1db81700b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 20:03:41 +0000 Subject: [PATCH] style: auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .pre-commit-config.yaml | 4 +- custom_components/alexa_media/__init__.py | 46 ++++++++++++----------- custom_components/alexa_media/sensor.py | 18 ++++----- 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a9d648d17..f3775d5c1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,14 +50,14 @@ repos: - hooks: - id: black repo: https://github.com/psf/black - rev: 24.4.2 + rev: 23.11.0 - repo: https://github.com/pre-commit/mirrors-prettier hooks: - id: prettier exclude: ^custom_components/alexa_media/translations|CHANGELOG.md rev: v4.0.0-alpha.8 - repo: https://github.com/asottile/pyupgrade - rev: v3.17.0 + rev: v3.15.0 hooks: - id: pyupgrade args: [--py39-plus] diff --git a/custom_components/alexa_media/__init__.py b/custom_components/alexa_media/__init__.py index 67e3c4de8..c974f9aaa 100644 --- a/custom_components/alexa_media/__init__.py +++ b/custom_components/alexa_media/__init__.py @@ -1125,9 +1125,9 @@ async def http2_handler(message_obj): ) ): _LOGGER.debug("Discovered new media_player %s", hide_serial(serial)) - ( - hass.data[DATA_ALEXAMEDIA]["accounts"][email]["new_devices"] - ) = True + (hass.data[DATA_ALEXAMEDIA]["accounts"][email]["new_devices"]) = ( + True + ) coordinator = hass.data[DATA_ALEXAMEDIA]["accounts"][email].get( "coordinator" ) @@ -1182,9 +1182,9 @@ async def http2_close_handler(): hass.data[DATA_ALEXAMEDIA]["accounts"][email][ "http2_lastattempt" ] = time.time() - http2_enabled = hass.data[DATA_ALEXAMEDIA]["accounts"][email][ - "http2" - ] = await http2_connect() + http2_enabled = hass.data[DATA_ALEXAMEDIA]["accounts"][email]["http2"] = ( + await http2_connect() + ) errors = hass.data[DATA_ALEXAMEDIA]["accounts"][email]["http2error"] = ( hass.data[DATA_ALEXAMEDIA]["accounts"][email]["http2error"] + 1 ) @@ -1243,24 +1243,24 @@ async def http2_error_handler(message): else config.get(CONF_SCAN_INTERVAL) ) hass.data[DATA_ALEXAMEDIA]["accounts"][email]["login_obj"] = login_obj - http2_enabled = hass.data[DATA_ALEXAMEDIA]["accounts"][email][ - "http2" - ] = await http2_connect() + http2_enabled = hass.data[DATA_ALEXAMEDIA]["accounts"][email]["http2"] = ( + await http2_connect() + ) coordinator = hass.data[DATA_ALEXAMEDIA]["accounts"][email].get("coordinator") if coordinator is None: _LOGGER.debug("%s: Creating coordinator", hide_email(email)) - hass.data[DATA_ALEXAMEDIA]["accounts"][email][ - "coordinator" - ] = coordinator = DataUpdateCoordinator( - hass, - _LOGGER, - # Name of the data. For logging purposes. - name="alexa_media", - update_method=async_update_data, - # Polling interval. Will only be polled if there are subscribers. - update_interval=timedelta( - seconds=scan_interval * 10 if http2_enabled else scan_interval - ), + hass.data[DATA_ALEXAMEDIA]["accounts"][email]["coordinator"] = coordinator = ( + DataUpdateCoordinator( + hass, + _LOGGER, + # Name of the data. For logging purposes. + name="alexa_media", + update_method=async_update_data, + # Polling interval. Will only be polled if there are subscribers. + update_interval=timedelta( + seconds=scan_interval * 10 if http2_enabled else scan_interval + ), + ) ) else: _LOGGER.debug("%s: Reusing coordinator", hide_email(email)) @@ -1382,7 +1382,9 @@ async def test_login_status(hass, config_entry, login) -> bool: account = config_entry.data _LOGGER.debug("Logging in: %s %s", obfuscate(account), in_progess_instances(hass)) _LOGGER.debug("Login stats: %s", login.stats) - message: str = f"Reauthenticate {login.email} on the [Integrations](/config/integrations) page. " + message: str = ( + f"Reauthenticate {login.email} on the [Integrations](/config/integrations) page. " + ) if login.stats.get("login_timestamp") != datetime(1, 1, 1): elaspsed_time: str = str(datetime.now() - login.stats.get("login_timestamp")) api_calls: int = login.stats.get("api_calls") diff --git a/custom_components/alexa_media/sensor.py b/custom_components/alexa_media/sensor.py index c788ba4db..6ad68bbad 100644 --- a/custom_components/alexa_media/sensor.py +++ b/custom_components/alexa_media/sensor.py @@ -257,9 +257,9 @@ def __init__(self, coordinator, entity_id, name, media_player_device_id): self._attr_name = name + " Temperature" self._attr_device_class = SensorDeviceClass.TEMPERATURE self._attr_state_class = SensorStateClass.MEASUREMENT - self._attr_native_value: Optional[ - datetime.datetime - ] = parse_temperature_from_coordinator(coordinator, entity_id) + self._attr_native_value: Optional[datetime.datetime] = ( + parse_temperature_from_coordinator(coordinator, entity_id) + ) self._attr_native_unit_of_measurement: Optional[str] = UnitOfTemperature.CELSIUS # This includes "_temperature" because the Alexa entityId is for a physical device # A single physical device could have multiple HA entities @@ -306,12 +306,12 @@ def __init__( self._attr_name = name + " " + self._sensor_name self._attr_device_class = self._sensor_name self._attr_state_class = SensorStateClass.MEASUREMENT - self._attr_native_value: Optional[ - datetime.datetime - ] = parse_air_quality_from_coordinator(coordinator, entity_id, instance) - self._attr_native_unit_of_measurement: Optional[ - str - ] = ALEXA_UNIT_CONVERSION.get(unit) + self._attr_native_value: Optional[datetime.datetime] = ( + parse_air_quality_from_coordinator(coordinator, entity_id, instance) + ) + self._attr_native_unit_of_measurement: Optional[str] = ( + ALEXA_UNIT_CONVERSION.get(unit) + ) self._attr_unique_id = entity_id + " " + self._sensor_name self._attr_icon = ALEXA_ICON_CONVERSION.get(sensor_name, ALEXA_ICON_DEFAULT) self._attr_device_info = (