diff --git a/homeassistant/components/binary_sensor/isy994.py b/homeassistant/components/binary_sensor/isy994.py index deaa118f51c..b6d582b7793 100644 --- a/homeassistant/components/binary_sensor/isy994.py +++ b/homeassistant/components/binary_sensor/isy994.py @@ -55,7 +55,7 @@ def setup_platform(hass, config: ConfigType, else: device_type = _detect_device_type(node) subnode_id = int(node.nid[-1]) - if (device_type == 'opening' or device_type == 'moisture'): + if device_type in ('opening', 'moisture'): # These sensors use an optional "negative" subnode 2 to snag # all state changes if subnode_id == 2: diff --git a/homeassistant/components/camera/proxy.py b/homeassistant/components/camera/proxy.py index 447f4e1e56a..6fe891b6b24 100644 --- a/homeassistant/components/camera/proxy.py +++ b/homeassistant/components/camera/proxy.py @@ -69,7 +69,7 @@ def _resize_image(image, opts): img = Image.open(io.BytesIO(image)) imgfmt = str(img.format) - if imgfmt != 'PNG' and imgfmt != 'JPEG': + if imgfmt not in ('PNG', 'JPEG'): _LOGGER.debug("Image is of unsupported type: %s", imgfmt) return image diff --git a/homeassistant/components/camera/verisure.py b/homeassistant/components/camera/verisure.py index b637858303e..554f877d0bd 100644 --- a/homeassistant/components/camera/verisure.py +++ b/homeassistant/components/camera/verisure.py @@ -66,8 +66,7 @@ class VerisureSmartcam(Camera): if not image_ids: return new_image_id = image_ids[0] - if (new_image_id == '-1' or - self._image_id == new_image_id): + if new_image_id in ('-1', self._image_id): _LOGGER.debug("The image is the same, or loading image_id") return _LOGGER.debug("Download new image %s", new_image_id) diff --git a/homeassistant/components/climate/daikin.py b/homeassistant/components/climate/daikin.py index 2c49b25a39d..50501025f0c 100644 --- a/homeassistant/components/climate/daikin.py +++ b/homeassistant/components/climate/daikin.py @@ -145,7 +145,7 @@ class DaikinClimate(ClimateDevice): if value is None: _LOGGER.error("Invalid value requested for key %s", key) else: - if value == "-" or value == "--": + if value in ("-", "--"): value = None elif cast_to_float: try: diff --git a/homeassistant/components/climate/radiotherm.py b/homeassistant/components/climate/radiotherm.py index 032d85637ef..b3043689f8c 100644 --- a/homeassistant/components/climate/radiotherm.py +++ b/homeassistant/components/climate/radiotherm.py @@ -308,7 +308,7 @@ class RadioThermostat(ClimateDevice): def set_operation_mode(self, operation_mode): """Set operation mode (auto, cool, heat, off).""" - if operation_mode == STATE_OFF or operation_mode == STATE_AUTO: + if operation_mode in (STATE_OFF, STATE_AUTO): self.device.tmode = TEMP_MODE_TO_CODE[operation_mode] # Setting t_cool or t_heat automatically changes tmode. diff --git a/homeassistant/components/device_tracker/tomato.py b/homeassistant/components/device_tracker/tomato.py index 01ae2977f6d..12e1cb0099a 100644 --- a/homeassistant/components/device_tracker/tomato.py +++ b/homeassistant/components/device_tracker/tomato.py @@ -102,7 +102,7 @@ class TomatoDeviceScanner(DeviceScanner): for param, value in \ self.parse_api_pattern.findall(response.text): - if param == 'wldev' or param == 'dhcpd_lease': + if param in ('wldev', 'dhcpd_lease'): self.last_results[param] = \ json.loads(value.replace("'", '"')) return True diff --git a/homeassistant/components/device_tracker/ubus.py b/homeassistant/components/device_tracker/ubus.py index f265014657b..94e3b407d13 100644 --- a/homeassistant/components/device_tracker/ubus.py +++ b/homeassistant/components/device_tracker/ubus.py @@ -56,7 +56,7 @@ def _refresh_on_access_denied(func): try: return func(self, *args, **kwargs) except PermissionError: - _LOGGER.warning("Invalid session detected." + + _LOGGER.warning("Invalid session detected." " Trying to refresh session_id and re-run RPC") self.session_id = _get_session_id( self.url, self.username, self.password) diff --git a/homeassistant/components/egardia.py b/homeassistant/components/egardia.py index f350ea56bb4..b7da671bb15 100644 --- a/homeassistant/components/egardia.py +++ b/homeassistant/components/egardia.py @@ -81,7 +81,7 @@ def setup(hass, config): device = hass.data[EGARDIA_DEVICE] = egardiadevice.EgardiaDevice( host, port, username, password, '', version) except requests.exceptions.RequestException: - _LOGGER.error("An error occurred accessing your Egardia device. " + + _LOGGER.error("An error occurred accessing your Egardia device. " "Please check config.") return False except egardiadevice.UnauthorizedError: @@ -108,7 +108,7 @@ def setup(hass, config): hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, handle_stop_event) except IOError: - _LOGGER.error("Binding error occurred while starting " + + _LOGGER.error("Binding error occurred while starting " "EgardiaServer.") return False diff --git a/homeassistant/components/fan/template.py b/homeassistant/components/fan/template.py index a40437e719b..e72d82eff08 100644 --- a/homeassistant/components/fan/template.py +++ b/homeassistant/components/fan/template.py @@ -250,8 +250,7 @@ class TemplateFan(FanEntity): await self._set_speed_script.async_run({ATTR_SPEED: speed}) else: _LOGGER.error( - 'Received invalid speed: %s. ' + - 'Expected: %s.', + 'Received invalid speed: %s. Expected: %s.', speed, self._speed_list) async def async_oscillate(self, oscillating: bool) -> None: @@ -265,8 +264,7 @@ class TemplateFan(FanEntity): {ATTR_OSCILLATING: oscillating}) else: _LOGGER.error( - 'Received invalid oscillating value: %s. ' + - 'Expected: %s.', + 'Received invalid oscillating value: %s. Expected: %s.', oscillating, ', '.join(_VALID_OSC)) async def async_set_direction(self, direction: str) -> None: @@ -280,8 +278,7 @@ class TemplateFan(FanEntity): {ATTR_DIRECTION: direction}) else: _LOGGER.error( - 'Received invalid direction: %s. ' + - 'Expected: %s.', + 'Received invalid direction: %s. Expected: %s.', direction, ', '.join(_VALID_DIRECTIONS)) async def async_added_to_hass(self): @@ -319,8 +316,7 @@ class TemplateFan(FanEntity): self._state = None else: _LOGGER.error( - 'Received invalid fan is_on state: %s. ' + - 'Expected: %s.', + 'Received invalid fan is_on state: %s. Expected: %s.', state, ', '.join(_VALID_STATES)) self._state = None @@ -340,8 +336,7 @@ class TemplateFan(FanEntity): self._speed = None else: _LOGGER.error( - 'Received invalid speed: %s. ' + - 'Expected: %s.', + 'Received invalid speed: %s. Expected: %s.', speed, self._speed_list) self._speed = None @@ -363,8 +358,8 @@ class TemplateFan(FanEntity): self._oscillating = None else: _LOGGER.error( - 'Received invalid oscillating: %s. ' + - 'Expected: True/False.', oscillating) + 'Received invalid oscillating: %s. Expected: True/False.', + oscillating) self._oscillating = None # Update direction if 'direction_template' is configured @@ -383,7 +378,6 @@ class TemplateFan(FanEntity): self._direction = None else: _LOGGER.error( - 'Received invalid direction: %s. ' + - 'Expected: %s.', + 'Received invalid direction: %s. Expected: %s.', direction, ', '.join(_VALID_DIRECTIONS)) self._direction = None diff --git a/homeassistant/components/feedreader.py b/homeassistant/components/feedreader.py index 73ab9e8123c..56f153517cf 100644 --- a/homeassistant/components/feedreader.py +++ b/homeassistant/components/feedreader.py @@ -189,7 +189,7 @@ class StoredData(object): with self._lock, open(self._data_file, 'rb') as myfile: self._data = pickle.load(myfile) or {} self._cache_outdated = False - except: # noqa: E722 # pylint: disable=bare-except + except: # noqa: E722 pylint: disable=bare-except _LOGGER.error("Error loading data from pickled file %s", self._data_file) @@ -207,7 +207,7 @@ class StoredData(object): feed_id, self._data_file) try: pickle.dump(self._data, myfile) - except: # noqa: E722 # pylint: disable=bare-except + except: # noqa: E722 pylint: disable=bare-except _LOGGER.error( "Error saving pickled data to %s", self._data_file) self._cache_outdated = True diff --git a/homeassistant/components/homekit/__init__.py b/homeassistant/components/homekit/__init__.py index cb9387fb2c0..81f66880943 100644 --- a/homeassistant/components/homekit/__init__.py +++ b/homeassistant/components/homekit/__init__.py @@ -168,7 +168,7 @@ def get_accessory(hass, driver, state, aid, config): def generate_aid(entity_id): """Generate accessory aid with zlib adler32.""" aid = adler32(entity_id.encode('utf-8')) - if aid == 0 or aid == 1: + if aid in (0, 1): return None return aid diff --git a/homeassistant/components/homekit/type_sensors.py b/homeassistant/components/homekit/type_sensors.py index 373c1188f2d..d4c2cb58209 100644 --- a/homeassistant/components/homekit/type_sensors.py +++ b/homeassistant/components/homekit/type_sensors.py @@ -181,6 +181,6 @@ class BinarySensor(HomeAccessory): def update_state(self, new_state): """Update accessory after state change.""" state = new_state.state - detected = (state == STATE_ON) or (state == STATE_HOME) + detected = state in (STATE_ON, STATE_HOME) self.char_detected.set_value(detected) _LOGGER.debug('%s: Set to %d', self.entity_id, detected) diff --git a/homeassistant/components/light/template.py b/homeassistant/components/light/template.py index 38cac649a1a..ad77b734fbb 100644 --- a/homeassistant/components/light/template.py +++ b/homeassistant/components/light/template.py @@ -248,8 +248,7 @@ class LightTemplate(Light): self._state = state in ('true', STATE_ON) else: _LOGGER.error( - 'Received invalid light is_on state: %s. ' + - 'Expected: %s', + 'Received invalid light is_on state: %s. Expected: %s', state, ', '.join(_VALID_STATES)) self._state = None @@ -264,8 +263,7 @@ class LightTemplate(Light): self._brightness = int(brightness) else: _LOGGER.error( - 'Received invalid brightness : %s' + - 'Expected: 0-255', + 'Received invalid brightness : %s. Expected: 0-255', brightness) self._brightness = None diff --git a/homeassistant/components/media_player/apple_tv.py b/homeassistant/components/media_player/apple_tv.py index 37a50b39e95..97b9b64c7cb 100644 --- a/homeassistant/components/media_player/apple_tv.py +++ b/homeassistant/components/media_player/apple_tv.py @@ -100,15 +100,14 @@ class AppleTvDevice(MediaPlayerDevice): if self._playing: from pyatv import const state = self._playing.play_state - if state == const.PLAY_STATE_IDLE or \ - state == const.PLAY_STATE_NO_MEDIA or \ - state == const.PLAY_STATE_LOADING: + if state in (const.PLAY_STATE_IDLE, const.PLAY_STATE_NO_MEDIA, + const.PLAY_STATE_LOADING): return STATE_IDLE elif state == const.PLAY_STATE_PLAYING: return STATE_PLAYING - elif state == const.PLAY_STATE_PAUSED or \ - state == const.PLAY_STATE_FAST_FORWARD or \ - state == const.PLAY_STATE_FAST_BACKWARD: + elif state in (const.PLAY_STATE_PAUSED, + const.PLAY_STATE_FAST_FORWARD, + const.PLAY_STATE_FAST_BACKWARD): # Catch fast forward/backward here so "play" is default action return STATE_PAUSED return STATE_STANDBY # Bad or unknown state? @@ -162,7 +161,7 @@ class AppleTvDevice(MediaPlayerDevice): def media_position_updated_at(self): """Last valid time of media position.""" state = self.state - if state == STATE_PLAYING or state == STATE_PAUSED: + if state in (STATE_PLAYING, STATE_PAUSED): return dt_util.utcnow() @asyncio.coroutine diff --git a/homeassistant/components/media_player/bluesound.py b/homeassistant/components/media_player/bluesound.py index 283c4af032e..ec878e5c043 100644 --- a/homeassistant/components/media_player/bluesound.py +++ b/homeassistant/components/media_player/bluesound.py @@ -528,9 +528,9 @@ class BluesoundPlayer(MediaPlayerDevice): return STATE_GROUPED status = self._status.get('state', None) - if status == 'pause' or status == 'stop': + if status in ('pause', 'stop'): return STATE_PAUSED - elif status == 'stream' or status == 'play': + elif status in ('stream', 'play'): return STATE_PLAYING return STATE_IDLE diff --git a/homeassistant/components/media_player/pandora.py b/homeassistant/components/media_player/pandora.py index 90638cd9dfc..30e307fd117 100644 --- a/homeassistant/components/media_player/pandora.py +++ b/homeassistant/components/media_player/pandora.py @@ -294,8 +294,7 @@ class PandoraMediaPlayer(MediaPlayerDevice): time_remaining = int(cur_minutes) * 60 + int(cur_seconds) self._media_duration = int(total_minutes) * 60 + int(total_seconds) - if (time_remaining != self._time_remaining and - time_remaining != self._media_duration): + if time_remaining not in (self._time_remaining, self._media_duration): self._player_state = STATE_PLAYING elif self._player_state == STATE_PLAYING: self._player_state = STATE_PAUSED diff --git a/homeassistant/components/media_player/samsungtv.py b/homeassistant/components/media_player/samsungtv.py index c3de341d607..55b3fb0ea4f 100644 --- a/homeassistant/components/media_player/samsungtv.py +++ b/homeassistant/components/media_player/samsungtv.py @@ -153,7 +153,7 @@ class SamsungTVDevice(MediaPlayerDevice): def send_key(self, key): """Send a key to the tv and handles exceptions.""" if self._power_off_in_progress() \ - and not (key == 'KEY_POWER' or key == 'KEY_POWEROFF'): + and key not in ('KEY_POWER', 'KEY_POWEROFF'): _LOGGER.info("TV is powering off, not sending command: %s", key) return try: diff --git a/homeassistant/components/remote/xiaomi_miio.py b/homeassistant/components/remote/xiaomi_miio.py index 59a2dc861a6..eda09e3af64 100644 --- a/homeassistant/components/remote/xiaomi_miio.py +++ b/homeassistant/components/remote/xiaomi_miio.py @@ -232,13 +232,13 @@ class XiaomiMiioRemote(RemoteDevice): @asyncio.coroutine def async_turn_on(self, **kwargs): """Turn the device on.""" - _LOGGER.error("Device does not support turn_on, " + + _LOGGER.error("Device does not support turn_on, " "please use 'remote.send_command' to send commands.") @asyncio.coroutine def async_turn_off(self, **kwargs): """Turn the device off.""" - _LOGGER.error("Device does not support turn_off, " + + _LOGGER.error("Device does not support turn_off, " "please use 'remote.send_command' to send commands.") def _send_command(self, payload): diff --git a/homeassistant/components/sensor/arlo.py b/homeassistant/components/sensor/arlo.py index 609887e9690..eeb0c966ab4 100644 --- a/homeassistant/components/sensor/arlo.py +++ b/homeassistant/components/sensor/arlo.py @@ -56,9 +56,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): SENSOR_TYPES[sensor_type][0], arlo, sensor_type)) else: for camera in arlo.cameras: - if sensor_type == 'temperature' or \ - sensor_type == 'humidity' or \ - sensor_type == 'air_quality': + if sensor_type in ('temperature', 'humidity', 'air_quality'): continue name = '{0} {1}'.format( @@ -66,10 +64,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None): sensors.append(ArloSensor(name, camera, sensor_type)) for base_station in arlo.base_stations: - if ((sensor_type == 'temperature' or - sensor_type == 'humidity' or - sensor_type == 'air_quality') and - base_station.model_id == 'ABC1000'): + if 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) sensors.append(ArloSensor(name, base_station, sensor_type)) diff --git a/homeassistant/components/sensor/daikin.py b/homeassistant/components/sensor/daikin.py index e045043e09c..2da5cb5cdf0 100644 --- a/homeassistant/components/sensor/daikin.py +++ b/homeassistant/components/sensor/daikin.py @@ -85,7 +85,7 @@ class DaikinClimateSensor(Entity): if value is None: _LOGGER.warning("Invalid value requested for key %s", key) else: - if value == "-" or value == "--": + if value in ("-", "--"): value = None elif cast_to_float: try: diff --git a/homeassistant/components/sensor/fritzbox_callmonitor.py b/homeassistant/components/sensor/fritzbox_callmonitor.py index b443bd56f03..304489f99b7 100644 --- a/homeassistant/components/sensor/fritzbox_callmonitor.py +++ b/homeassistant/components/sensor/fritzbox_callmonitor.py @@ -70,7 +70,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): phonebook = FritzBoxPhonebook( host=host, port=port, username=username, password=password, phonebook_id=phonebook_id, prefixes=prefixes) - except: # noqa: E722 # pylint: disable=bare-except + except: # noqa: E722 pylint: disable=bare-except phonebook = None _LOGGER.warning("Phonebook with ID %s not found on Fritz!Box", phonebook_id) diff --git a/homeassistant/components/sensor/ios.py b/homeassistant/components/sensor/ios.py index 398c0b350ee..1fd556b17c0 100644 --- a/homeassistant/components/sensor/ios.py +++ b/homeassistant/components/sensor/ios.py @@ -86,8 +86,8 @@ class IOSSensor(Entity): battery_level = device_battery[ios.ATTR_BATTERY_LEVEL] charging = True icon_state = DEFAULT_ICON_STATE - if (battery_state == ios.ATTR_BATTERY_STATE_FULL or - battery_state == ios.ATTR_BATTERY_STATE_UNPLUGGED): + if battery_state in (ios.ATTR_BATTERY_STATE_FULL, + ios.ATTR_BATTERY_STATE_UNPLUGGED): charging = False icon_state = "{}-off".format(DEFAULT_ICON_STATE) elif battery_state == ios.ATTR_BATTERY_STATE_UNKNOWN: diff --git a/homeassistant/components/sensor/isy994.py b/homeassistant/components/sensor/isy994.py index 1048c04d43d..3eabce9458c 100644 --- a/homeassistant/components/sensor/isy994.py +++ b/homeassistant/components/sensor/isy994.py @@ -259,8 +259,7 @@ class ISYSensorDevice(ISYDevice): if len(self._node.uom) == 1: if self._node.uom[0] in UOM_FRIENDLY_NAME: friendly_name = UOM_FRIENDLY_NAME.get(self._node.uom[0]) - if friendly_name == TEMP_CELSIUS or \ - friendly_name == TEMP_FAHRENHEIT: + if friendly_name in (TEMP_CELSIUS, TEMP_FAHRENHEIT): friendly_name = self.hass.config.units.temperature_unit return friendly_name else: diff --git a/homeassistant/components/sensor/miflora.py b/homeassistant/components/sensor/miflora.py index f1f8adab062..6f50a57b3ab 100644 --- a/homeassistant/components/sensor/miflora.py +++ b/homeassistant/components/sensor/miflora.py @@ -62,7 +62,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the MiFlora sensor.""" from miflora import miflora_poller try: - import bluepy.btle # noqa: F401 # pylint: disable=unused-variable + import bluepy.btle # noqa: F401 pylint: disable=unused-variable from btlewrap import BluepyBackend backend = BluepyBackend except ImportError: diff --git a/homeassistant/components/sensor/mitemp_bt.py b/homeassistant/components/sensor/mitemp_bt.py index 3628765293b..249a69578db 100644 --- a/homeassistant/components/sensor/mitemp_bt.py +++ b/homeassistant/components/sensor/mitemp_bt.py @@ -60,7 +60,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the MiTempBt sensor.""" from mitemp_bt import mitemp_bt_poller try: - import bluepy.btle # noqa: F401 # pylint: disable=unused-variable + import bluepy.btle # noqa: F401 pylint: disable=unused-variable from btlewrap import BluepyBackend backend = BluepyBackend except ImportError: diff --git a/homeassistant/components/sensor/octoprint.py b/homeassistant/components/sensor/octoprint.py index 20d00267dee..df181c67c03 100644 --- a/homeassistant/components/sensor/octoprint.py +++ b/homeassistant/components/sensor/octoprint.py @@ -107,7 +107,7 @@ class OctoPrintSensor(Entity): def state(self): """Return the state of the sensor.""" sensor_unit = self.unit_of_measurement - if sensor_unit == TEMP_CELSIUS or sensor_unit == "%": + if sensor_unit in (TEMP_CELSIUS, "%"): # API sometimes returns null and not 0 if self._state is None: self._state = 0 diff --git a/homeassistant/components/sensor/qnap.py b/homeassistant/components/sensor/qnap.py index 3d9704875c9..97cf948ff9f 100644 --- a/homeassistant/components/sensor/qnap.py +++ b/homeassistant/components/sensor/qnap.py @@ -192,7 +192,7 @@ class QNAPStatsAPI(object): self.data["smart_drive_health"] = self._api.get_smart_disk_health() self.data["volumes"] = self._api.get_volumes() self.data["bandwidth"] = self._api.get_bandwidth() - except: # noqa: E722 # pylint: disable=bare-except + except: # noqa: E722 pylint: disable=bare-except _LOGGER.exception("Failed to fetch QNAP stats from the NAS") diff --git a/homeassistant/components/sensor/synologydsm.py b/homeassistant/components/sensor/synologydsm.py index e3c3a0cf5ca..e70dd482f1e 100644 --- a/homeassistant/components/sensor/synologydsm.py +++ b/homeassistant/components/sensor/synologydsm.py @@ -140,7 +140,7 @@ class SynoApi(object): try: self._api = SynologyDSM(host, port, username, password, use_https=use_ssl) - except: # noqa: E722 # pylint: disable=bare-except + except: # noqa: E722 pylint: disable=bare-except _LOGGER.error("Error setting up Synology DSM") # Will be updated when update() gets called. diff --git a/homeassistant/components/spc.py b/homeassistant/components/spc.py index 9742bc25c63..52d4165f3fa 100644 --- a/homeassistant/components/spc.py +++ b/homeassistant/components/spc.py @@ -151,7 +151,7 @@ def _ws_process_message(message, async_callback, *args): "Unsuccessful websocket message delivered, ignoring: %s", message) try: yield from async_callback(message['data']['sia'], *args) - except: # noqa: E722 # pylint: disable=bare-except + except: # noqa: E722 pylint: disable=bare-except _LOGGER.exception("Exception in callback, ignoring") diff --git a/homeassistant/components/wink/__init__.py b/homeassistant/components/wink/__init__.py index 7c171d74967..a8acc437546 100644 --- a/homeassistant/components/wink/__init__.py +++ b/homeassistant/components/wink/__init__.py @@ -452,7 +452,7 @@ def setup(hass, config): _man = siren.wink.device_manufacturer() if (service.service != SERVICE_SET_AUTO_SHUTOFF and service.service != SERVICE_ENABLE_SIREN and - (_man != 'dome' and _man != 'wink')): + _man not in ('dome', 'wink')): _LOGGER.error("Service only valid for Dome or Wink sirens") return @@ -487,7 +487,7 @@ def setup(hass, config): has_dome_or_wink_siren = False for siren in pywink.get_sirens(): _man = siren.device_manufacturer() - if _man == "dome" or _man == "wink": + if _man in ("dome", "wink"): has_dome_or_wink_siren = True _id = siren.object_id() + siren.name() if _id not in hass.data[DOMAIN]['unique_ids']: diff --git a/homeassistant/helpers/condition.py b/homeassistant/helpers/condition.py index 921b3bcf06b..504c9d4b067 100644 --- a/homeassistant/helpers/condition.py +++ b/homeassistant/helpers/condition.py @@ -246,13 +246,11 @@ def sun(hass, before=None, after=None, before_offset=None, after_offset=None): sunrise = get_astral_event_date(hass, 'sunrise', today) sunset = get_astral_event_date(hass, 'sunset', today) - if sunrise is None and (before == SUN_EVENT_SUNRISE or - after == SUN_EVENT_SUNRISE): + if sunrise is None and SUN_EVENT_SUNRISE in (before, after): # There is no sunrise today return False - if sunset is None and (before == SUN_EVENT_SUNSET or - after == SUN_EVENT_SUNSET): + if sunset is None and SUN_EVENT_SUNSET in (before, after): # There is no sunset today return False diff --git a/tests/components/emulated_hue/test_upnp.py b/tests/components/emulated_hue/test_upnp.py index 555802f9a2c..8315de34e06 100644 --- a/tests/components/emulated_hue/test_upnp.py +++ b/tests/components/emulated_hue/test_upnp.py @@ -89,7 +89,7 @@ class TestEmulatedHue(unittest.TestCase): # Make sure the XML is parsable try: ET.fromstring(result.text) - except: # noqa: E722 # pylint: disable=bare-except + except: # noqa: E722 pylint: disable=bare-except self.fail('description.xml is not valid XML!') def test_create_username(self): diff --git a/tests/components/test_system_log.py b/tests/components/test_system_log.py index 59e99e5c1b5..5d48fd88127 100644 --- a/tests/components/test_system_log.py +++ b/tests/components/test_system_log.py @@ -28,7 +28,7 @@ async def get_error_log(hass, aiohttp_client, expected_count): def _generate_and_log_exception(exception, log): try: raise Exception(exception) - except: # noqa: E722 # pylint: disable=bare-except + except: # noqa: E722 pylint: disable=bare-except _LOGGER.exception(log)