Use list literals (#33659)

This commit is contained in:
springstan 2020-04-04 23:14:47 +02:00 committed by GitHub
parent dde93304d3
commit db72039b8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 18 additions and 18 deletions

View File

@ -56,7 +56,7 @@ class DiscordNotificationService(BaseNotificationService):
data = kwargs.get(ATTR_DATA) or {} data = kwargs.get(ATTR_DATA) or {}
if ATTR_IMAGES in data: if ATTR_IMAGES in data:
images = list() images = []
for image in data.get(ATTR_IMAGES): for image in data.get(ATTR_IMAGES):
image_exists = await self.hass.async_add_executor_job( image_exists = await self.hass.async_add_executor_job(
@ -84,7 +84,7 @@ class DiscordNotificationService(BaseNotificationService):
# Must create new instances of File for each channel. # Must create new instances of File for each channel.
files = None files = None
if images: if images:
files = list() files = []
for image in images: for image in images:
files.append(discord.File(image)) files.append(discord.File(image))

View File

@ -10,7 +10,7 @@ from .const import _LOGGER, DOMAIN, ECOBEE_MODEL_TO_NAME, MANUFACTURER
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up ecobee binary (occupancy) sensors.""" """Set up ecobee binary (occupancy) sensors."""
data = hass.data[DOMAIN] data = hass.data[DOMAIN]
dev = list() dev = []
for index in range(len(data.ecobee.thermostats)): for index in range(len(data.ecobee.thermostats)):
for sensor in data.ecobee.get_remote_sensors(index): for sensor in data.ecobee.get_remote_sensors(index):
for item in sensor["capability"]: for item in sensor["capability"]:

View File

@ -20,7 +20,7 @@ SENSOR_TYPES = {
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up ecobee (temperature and humidity) sensors.""" """Set up ecobee (temperature and humidity) sensors."""
data = hass.data[DOMAIN] data = hass.data[DOMAIN]
dev = list() dev = []
for index in range(len(data.ecobee.thermostats)): for index in range(len(data.ecobee.thermostats)):
for sensor in data.ecobee.get_remote_sensors(index): for sensor in data.ecobee.get_remote_sensors(index):
for item in sensor["capability"]: for item in sensor["capability"]:

View File

@ -26,7 +26,7 @@ from .const import (
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the ecobee weather platform.""" """Set up the ecobee weather platform."""
data = hass.data[DOMAIN] data = hass.data[DOMAIN]
dev = list() dev = []
for index in range(len(data.ecobee.thermostats)): for index in range(len(data.ecobee.thermostats)):
thermostat = data.ecobee.get_thermostat(index) thermostat = data.ecobee.get_thermostat(index)
if "weather" in thermostat: if "weather" in thermostat:
@ -164,7 +164,7 @@ class EcobeeWeather(WeatherEntity):
if "forecasts" not in self.weather: if "forecasts" not in self.weather:
return None return None
forecasts = list() forecasts = []
for day in range(1, 5): for day in range(1, 5):
forecast = _process_forecast(self.weather["forecasts"][day]) forecast = _process_forecast(self.weather["forecasts"][day])
if forecast is None: if forecast is None:

View File

@ -107,12 +107,12 @@ class BanLogParser:
def __init__(self, log_file): def __init__(self, log_file):
"""Initialize the parser.""" """Initialize the parser."""
self.log_file = log_file self.log_file = log_file
self.data = list() self.data = []
self.ip_regex = {} self.ip_regex = {}
def read_log(self, jail): def read_log(self, jail):
"""Read the fail2ban log and find entries for jail.""" """Read the fail2ban log and find entries for jail."""
self.data = list() self.data = []
try: try:
with open(self.log_file, encoding="utf-8") as file_data: with open(self.log_file, encoding="utf-8") as file_data:
self.data = self.ip_regex[jail].findall(file_data.read()) self.data = self.ip_regex[jail].findall(file_data.read())

View File

@ -195,7 +195,7 @@ def devices_with_push(hass):
def enabled_push_ids(hass): def enabled_push_ids(hass):
"""Return a list of push enabled target push IDs.""" """Return a list of push enabled target push IDs."""
push_ids = list() push_ids = []
for device in hass.data[DOMAIN][ATTR_DEVICES].values(): for device in hass.data[DOMAIN][ATTR_DEVICES].values():
if device.get(ATTR_PUSH_ID) is not None: if device.get(ATTR_PUSH_ID) is not None:
push_ids.append(device.get(ATTR_PUSH_ID)) push_ids.append(device.get(ATTR_PUSH_ID))

View File

@ -20,7 +20,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up iOS from a config entry.""" """Set up iOS from a config entry."""
dev = list() dev = []
for device_name, device in ios.devices(hass).items(): for device_name, device in ios.devices(hass).items():
for sensor_type in ("level", "state"): for sensor_type in ("level", "state"):
dev.append(IOSSensor(sensor_type, device_name, device)) dev.append(IOSSensor(sensor_type, device_name, device))

View File

@ -333,7 +333,7 @@ class KodiDevice(MediaPlayerDevice):
self._turn_on_action = turn_on_action self._turn_on_action = turn_on_action
self._turn_off_action = turn_off_action self._turn_off_action = turn_off_action
self._enable_websocket = websocket self._enable_websocket = websocket
self._players = list() self._players = []
self._properties = {} self._properties = {}
self._item = {} self._item = {}
self._app_properties = {} self._app_properties = {}

View File

@ -18,7 +18,7 @@ from .entity import MobileAppEntity, sensor_id
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up mobile app binary sensor from a config entry.""" """Set up mobile app binary sensor from a config entry."""
entities = list() entities = []
webhook_id = config_entry.data[CONF_WEBHOOK_ID] webhook_id = config_entry.data[CONF_WEBHOOK_ID]

View File

@ -18,7 +18,7 @@ from .entity import MobileAppEntity, sensor_id
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up mobile app sensor from a config entry.""" """Set up mobile app sensor from a config entry."""
entities = list() entities = []
webhook_id = config_entry.data[CONF_WEBHOOK_ID] webhook_id = config_entry.data[CONF_WEBHOOK_ID]

View File

@ -64,7 +64,7 @@ class OpenhomeDevice(MediaPlayerDevice):
self._volume_level = None self._volume_level = None
self._volume_muted = None self._volume_muted = None
self._supported_features = SUPPORT_OPENHOME self._supported_features = SUPPORT_OPENHOME
self._source_names = list() self._source_names = []
self._source_index = {} self._source_index = {}
self._source = {} self._source = {}
self._name = None self._name = None
@ -79,7 +79,7 @@ class OpenhomeDevice(MediaPlayerDevice):
self._name = self._device.Room().decode("utf-8") self._name = self._device.Room().decode("utf-8")
self._supported_features = SUPPORT_OPENHOME self._supported_features = SUPPORT_OPENHOME
source_index = {} source_index = {}
source_names = list() source_names = []
if self._device.VolumeEnabled(): if self._device.VolumeEnabled():
self._supported_features |= ( self._supported_features |= (

View File

@ -11,7 +11,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
data = sleepiq.DATA data = sleepiq.DATA
data.update() data.update()
dev = list() dev = []
for bed_id, bed in data.beds.items(): for bed_id, bed in data.beds.items():
for side in sleepiq.SIDES: for side in sleepiq.SIDES:
if getattr(bed, side) is not None: if getattr(bed, side) is not None:

View File

@ -12,7 +12,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
data = sleepiq.DATA data = sleepiq.DATA
data.update() data.update()
dev = list() dev = []
for bed_id, bed in data.beds.items(): for bed_id, bed in data.beds.items():
for side in sleepiq.SIDES: for side in sleepiq.SIDES:
if getattr(bed, side) is not None: if getattr(bed, side) is not None:

View File

@ -679,7 +679,7 @@ class YeelightGenericLight(Light):
red, green, blue = color_util.color_hs_to_RGB(*self._hs) red, green, blue = color_util.color_hs_to_RGB(*self._hs)
transitions = list() transitions = []
transitions.append( transitions.append(
RGBTransition(255, 0, 0, brightness=10, duration=duration) RGBTransition(255, 0, 0, brightness=10, duration=duration)
) )