Remove device tracker unnecessary separate except clause (#24081)

Handle exception where it can be thrown.
This commit is contained in:
Joakim Plate 2019-05-25 11:29:20 +02:00 committed by Martin Hjelmare
parent 02f927ae2d
commit 9d7aa8f05d

View File

@ -478,7 +478,6 @@ async def async_load_config(path: str, hass: HomeAssistantType,
vol.Optional(CONF_CONSIDER_HOME, default=consider_home): vol.All( vol.Optional(CONF_CONSIDER_HOME, default=consider_home): vol.All(
cv.time_period, cv.positive_timedelta), cv.time_period, cv.positive_timedelta),
}) })
try:
result = [] result = []
try: try:
devices = await hass.async_add_job( devices = await hass.async_add_job(
@ -486,6 +485,8 @@ async def async_load_config(path: str, hass: HomeAssistantType,
except HomeAssistantError as err: except HomeAssistantError as err:
LOGGER.error("Unable to load %s: %s", path, str(err)) LOGGER.error("Unable to load %s: %s", path, str(err))
return [] return []
except FileNotFoundError:
return []
for dev_id, device in devices.items(): for dev_id, device in devices.items():
# Deprecated option. We just ignore it to avoid breaking change # Deprecated option. We just ignore it to avoid breaking change
@ -498,9 +499,6 @@ async def async_load_config(path: str, hass: HomeAssistantType,
else: else:
result.append(Device(hass, **device)) result.append(Device(hass, **device))
return result return result
except (HomeAssistantError, FileNotFoundError):
# When YAML file could not be loaded/did not contain a dict
return []
def update_config(path: str, dev_id: str, device: Device): def update_config(path: str, dev_id: str, device: Device):