Removes unnecessary else/elif blocks (#26884)
This commit is contained in:
parent
18873d202d
commit
b1118cb8ff
13 changed files with 53 additions and 42 deletions
|
@ -60,7 +60,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
if instance is None or namespace is None:
|
if instance is None or namespace is None:
|
||||||
_LOGGER.error("Skipping %s", dev_name)
|
_LOGGER.error("Skipping %s", dev_name)
|
||||||
continue
|
continue
|
||||||
else:
|
|
||||||
devices.append(EddystoneTemp(name, namespace, instance))
|
devices.append(EddystoneTemp(name, namespace, instance))
|
||||||
|
|
||||||
if devices:
|
if devices:
|
||||||
|
|
|
@ -27,7 +27,6 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
if not hass.config.is_allowed_path(path):
|
if not hass.config.is_allowed_path(path):
|
||||||
_LOGGER.error("Filepath %s is not valid or allowed", path)
|
_LOGGER.error("Filepath %s is not valid or allowed", path)
|
||||||
continue
|
continue
|
||||||
else:
|
|
||||||
sensors.append(Filesize(path))
|
sensors.append(Filesize(path))
|
||||||
|
|
||||||
if sensors:
|
if sensors:
|
||||||
|
|
|
@ -323,7 +323,7 @@ def _categorize_nodes(
|
||||||
# determine if it should be a binary_sensor.
|
# determine if it should be a binary_sensor.
|
||||||
if _is_sensor_a_binary_sensor(hass, node):
|
if _is_sensor_a_binary_sensor(hass, node):
|
||||||
continue
|
continue
|
||||||
else:
|
|
||||||
hass.data[ISY994_NODES]["sensor"].append(node)
|
hass.data[ISY994_NODES]["sensor"].append(node)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
@ -189,17 +189,19 @@ class MVGLiveData:
|
||||||
and _departure["destination"] not in self._destinations
|
and _departure["destination"] not in self._destinations
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
elif (
|
|
||||||
|
if (
|
||||||
"" not in self._directions[:1]
|
"" not in self._directions[:1]
|
||||||
and _departure["direction"] not in self._directions
|
and _departure["direction"] not in self._directions
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
elif (
|
|
||||||
"" not in self._lines[:1] and _departure["linename"] not in self._lines
|
if "" not in self._lines[:1] and _departure["linename"] not in self._lines:
|
||||||
):
|
|
||||||
continue
|
continue
|
||||||
elif _departure["time"] < self._timeoffset:
|
|
||||||
|
if _departure["time"] < self._timeoffset:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# now select the relevant data
|
# now select the relevant data
|
||||||
_nextdep = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
_nextdep = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
||||||
for k in ["destination", "linename", "time", "direction", "product"]:
|
for k in ["destination", "linename", "time", "direction", "product"]:
|
||||||
|
|
|
@ -264,7 +264,6 @@ class OnkyoDevice(MediaPlayerDevice):
|
||||||
if source in self._source_mapping:
|
if source in self._source_mapping:
|
||||||
self._current_source = self._source_mapping[source]
|
self._current_source = self._source_mapping[source]
|
||||||
break
|
break
|
||||||
else:
|
|
||||||
self._current_source = "_".join([i for i in current_source_tuples[1]])
|
self._current_source = "_".join([i for i in current_source_tuples[1]])
|
||||||
if preset_raw and self._current_source.lower() == "radio":
|
if preset_raw and self._current_source.lower() == "radio":
|
||||||
self._attributes[ATTR_PRESET] = preset_raw[1]
|
self._attributes[ATTR_PRESET] = preset_raw[1]
|
||||||
|
@ -414,7 +413,6 @@ class OnkyoDeviceZone(OnkyoDevice):
|
||||||
if source in self._source_mapping:
|
if source in self._source_mapping:
|
||||||
self._current_source = self._source_mapping[source]
|
self._current_source = self._source_mapping[source]
|
||||||
break
|
break
|
||||||
else:
|
|
||||||
self._current_source = "_".join([i for i in current_source_tuples[1]])
|
self._current_source = "_".join([i for i in current_source_tuples[1]])
|
||||||
self._muted = bool(mute_raw[1] == "on")
|
self._muted = bool(mute_raw[1] == "on")
|
||||||
if preset_raw and self._current_source.lower() == "radio":
|
if preset_raw and self._current_source.lower() == "radio":
|
||||||
|
|
|
@ -320,10 +320,10 @@ class Recorder(threading.Thread):
|
||||||
purge.purge_old_data(self, event.keep_days, event.repack)
|
purge.purge_old_data(self, event.keep_days, event.repack)
|
||||||
self.queue.task_done()
|
self.queue.task_done()
|
||||||
continue
|
continue
|
||||||
elif event.event_type == EVENT_TIME_CHANGED:
|
if event.event_type == EVENT_TIME_CHANGED:
|
||||||
self.queue.task_done()
|
self.queue.task_done()
|
||||||
continue
|
continue
|
||||||
elif event.event_type in self.exclude_t:
|
if event.event_type in self.exclude_t:
|
||||||
self.queue.task_done()
|
self.queue.task_done()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
@ -484,9 +484,11 @@ class TodoistProjectData:
|
||||||
for proposed_event in project_tasks:
|
for proposed_event in project_tasks:
|
||||||
if event == proposed_event:
|
if event == proposed_event:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if proposed_event[COMPLETED]:
|
if proposed_event[COMPLETED]:
|
||||||
# Event is complete!
|
# Event is complete!
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if proposed_event[END] is None:
|
if proposed_event[END] is None:
|
||||||
# No end time:
|
# No end time:
|
||||||
if event[END] is None and (proposed_event[PRIORITY] < event[PRIORITY]):
|
if event[END] is None and (proposed_event[PRIORITY] < event[PRIORITY]):
|
||||||
|
@ -494,29 +496,32 @@ class TodoistProjectData:
|
||||||
# but we have a higher priority.
|
# but we have a higher priority.
|
||||||
event = proposed_event
|
event = proposed_event
|
||||||
continue
|
continue
|
||||||
else:
|
|
||||||
continue
|
if event[END] is None:
|
||||||
elif event[END] is None:
|
|
||||||
# We have an end time, they do not.
|
# We have an end time, they do not.
|
||||||
event = proposed_event
|
event = proposed_event
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if proposed_event[END].date() > event[END].date():
|
if proposed_event[END].date() > event[END].date():
|
||||||
# Event is too late.
|
# Event is too late.
|
||||||
continue
|
continue
|
||||||
elif proposed_event[END].date() < event[END].date():
|
|
||||||
|
if proposed_event[END].date() < event[END].date():
|
||||||
# Event is earlier than current, select it.
|
# Event is earlier than current, select it.
|
||||||
event = proposed_event
|
event = proposed_event
|
||||||
continue
|
continue
|
||||||
else:
|
|
||||||
if proposed_event[PRIORITY] > event[PRIORITY]:
|
if proposed_event[PRIORITY] > event[PRIORITY]:
|
||||||
# Proposed event has a higher priority.
|
# Proposed event has a higher priority.
|
||||||
event = proposed_event
|
event = proposed_event
|
||||||
continue
|
continue
|
||||||
elif proposed_event[PRIORITY] == event[PRIORITY] and (
|
|
||||||
|
if proposed_event[PRIORITY] == event[PRIORITY] and (
|
||||||
proposed_event[END] < event[END]
|
proposed_event[END] < event[END]
|
||||||
):
|
):
|
||||||
event = proposed_event
|
event = proposed_event
|
||||||
continue
|
continue
|
||||||
|
|
||||||
return event
|
return event
|
||||||
|
|
||||||
async def async_get_events(self, hass, start_date, end_date):
|
async def async_get_events(self, hass, start_date, end_date):
|
||||||
|
|
|
@ -396,10 +396,12 @@ class LgWebOSDevice(MediaPlayerDevice):
|
||||||
if media_id == channel["channelNumber"]:
|
if media_id == channel["channelNumber"]:
|
||||||
perfect_match_channel_id = channel["channelId"]
|
perfect_match_channel_id = channel["channelId"]
|
||||||
continue
|
continue
|
||||||
elif media_id.lower() == channel["channelName"].lower():
|
|
||||||
|
if media_id.lower() == channel["channelName"].lower():
|
||||||
perfect_match_channel_id = channel["channelId"]
|
perfect_match_channel_id = channel["channelId"]
|
||||||
continue
|
continue
|
||||||
elif media_id.lower() in channel["channelName"].lower():
|
|
||||||
|
if media_id.lower() in channel["channelName"].lower():
|
||||||
partial_match_channel_id = channel["channelId"]
|
partial_match_channel_id = channel["channelId"]
|
||||||
|
|
||||||
if perfect_match_channel_id is not None:
|
if perfect_match_channel_id is not None:
|
||||||
|
|
|
@ -165,7 +165,7 @@ class WebSocketHandler:
|
||||||
if msg.type in (WSMsgType.CLOSE, WSMsgType.CLOSING):
|
if msg.type in (WSMsgType.CLOSE, WSMsgType.CLOSING):
|
||||||
break
|
break
|
||||||
|
|
||||||
elif msg.type != WSMsgType.TEXT:
|
if msg.type != WSMsgType.TEXT:
|
||||||
disconnect_warn = "Received non-Text message."
|
disconnect_warn = "Received non-Text message."
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
@ -199,11 +199,13 @@ def _async_handle_single_cluster_matches(
|
||||||
zha_device.is_mains_powered or matched_power_configuration
|
zha_device.is_mains_powered or matched_power_configuration
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
elif (
|
|
||||||
|
if (
|
||||||
cluster.cluster_id == PowerConfiguration.cluster_id
|
cluster.cluster_id == PowerConfiguration.cluster_id
|
||||||
and not zha_device.is_mains_powered
|
and not zha_device.is_mains_powered
|
||||||
):
|
):
|
||||||
matched_power_configuration = True
|
matched_power_configuration = True
|
||||||
|
|
||||||
cluster_match_results.append(
|
cluster_match_results.append(
|
||||||
_async_handle_single_cluster_match(
|
_async_handle_single_cluster_match(
|
||||||
hass,
|
hass,
|
||||||
|
|
|
@ -851,7 +851,8 @@ async def async_setup_entry(hass, config_entry):
|
||||||
# Need to be in STATE_AWAKED before talking to nodes.
|
# Need to be in STATE_AWAKED before talking to nodes.
|
||||||
_LOGGER.info("Z-Wave ready after %d seconds", waited)
|
_LOGGER.info("Z-Wave ready after %d seconds", waited)
|
||||||
break
|
break
|
||||||
elif waited >= const.NETWORK_READY_WAIT_SECS:
|
|
||||||
|
if waited >= const.NETWORK_READY_WAIT_SECS:
|
||||||
# Wait up to NETWORK_READY_WAIT_SECS seconds for the Z-Wave
|
# Wait up to NETWORK_READY_WAIT_SECS seconds for the Z-Wave
|
||||||
# network to be ready.
|
# network to be ready.
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
|
@ -861,7 +862,7 @@ async def async_setup_entry(hass, config_entry):
|
||||||
"final network state: %d %s", network.state, network.state_str
|
"final network state: %d %s", network.state, network.state_str
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
else:
|
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
hass.async_add_job(_finalize_start)
|
hass.async_add_job(_finalize_start)
|
||||||
|
|
|
@ -19,7 +19,8 @@ def config_per_platform(config: ConfigType, domain: str) -> Iterable[Tuple[Any,
|
||||||
|
|
||||||
if not platform_config:
|
if not platform_config:
|
||||||
continue
|
continue
|
||||||
elif not isinstance(platform_config, list):
|
|
||||||
|
if not isinstance(platform_config, list):
|
||||||
platform_config = [platform_config]
|
platform_config = [platform_config]
|
||||||
|
|
||||||
for item in platform_config:
|
for item in platform_config:
|
||||||
|
|
|
@ -23,7 +23,8 @@ def run(args: List) -> int:
|
||||||
for fil in os.listdir(path):
|
for fil in os.listdir(path):
|
||||||
if fil == "__pycache__":
|
if fil == "__pycache__":
|
||||||
continue
|
continue
|
||||||
elif os.path.isdir(os.path.join(path, fil)):
|
|
||||||
|
if os.path.isdir(os.path.join(path, fil)):
|
||||||
scripts.append(fil)
|
scripts.append(fil)
|
||||||
elif fil != "__init__.py" and fil.endswith(".py"):
|
elif fil != "__init__.py" and fil.endswith(".py"):
|
||||||
scripts.append(fil[:-3])
|
scripts.append(fil[:-3])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue