Use f-strings in integrations starting with "A" (#32110)

* Use f-strings in integrations starting with A

* Use f-strings in tests for integrations starting with A

* Fix pylint by renaming variable

* Fix nested for loop in f-string for aprs device_tracker

* Break long lines into multiple short lines

* Break long lines into multiple short lines v2
This commit is contained in:
springstan 2020-02-23 22:38:05 +01:00 committed by GitHub
parent a85808e325
commit 524a1a7587
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 162 additions and 229 deletions

View file

@ -57,7 +57,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
if sensor_type in ("temperature", "humidity", "air_quality"):
continue
name = "{0} {1}".format(SENSOR_TYPES[sensor_type][0], camera.name)
name = f"{SENSOR_TYPES[sensor_type][0]} {camera.name}"
sensors.append(ArloSensor(name, camera, sensor_type))
for base_station in arlo.base_stations:
@ -65,9 +65,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
sensor_type in ("temperature", "humidity", "air_quality")
and base_station.model_id == "ABC1000"
):
name = "{0} {1}".format(
SENSOR_TYPES[sensor_type][0], base_station.name
)
name = f"{SENSOR_TYPES[sensor_type][0]} {base_station.name}"
sensors.append(ArloSensor(name, base_station, sensor_type))
add_entities(sensors, True)
@ -83,7 +81,7 @@ class ArloSensor(Entity):
self._data = device
self._sensor_type = sensor_type
self._state = None
self._icon = "mdi:{}".format(SENSOR_TYPES.get(self._sensor_type)[2])
self._icon = f"mdi:{SENSOR_TYPES.get(self._sensor_type)[2]}"
@property
def name(self):
@ -141,8 +139,9 @@ class ArloSensor(Entity):
video = self._data.last_video
self._state = video.created_at_pretty("%m-%d-%Y %H:%M:%S")
except (AttributeError, IndexError):
error_msg = "Video not found for {0}. Older than {1} days?".format(
self.name, self._data.min_days_vdo_cache
error_msg = (
f"Video not found for {self.name}. "
f"Older than {self._data.min_days_vdo_cache} days?"
)
_LOGGER.debug(error_msg)
self._state = None