Rewrite of not a == b occurances (#48132)

pull/48147/head
Franck Nijhof 2021-03-20 01:27:04 +01:00 committed by GitHub
parent 26bceae99d
commit fb849b81b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 31 additions and 31 deletions

View File

@ -15,7 +15,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
dev = []
for sensor_type, sensor_details in SENSOR_TYPES.items():
if not sensor_details[0] in client.api.data:
if sensor_details[0] not in client.api.data:
continue
if sensor_details[0] in client.api.data:
if sensor_details[0] == "fs":

View File

@ -326,7 +326,7 @@ def _categorize_programs(hass_isy_data: dict, programs: Programs) -> None:
actions = None
status = entity_folder.get_by_name(KEY_STATUS)
if not status or not status.protocol == PROTO_PROGRAM:
if not status or status.protocol != PROTO_PROGRAM:
_LOGGER.warning(
"Program %s entity '%s' not loaded, invalid/missing status program",
platform,
@ -336,7 +336,7 @@ def _categorize_programs(hass_isy_data: dict, programs: Programs) -> None:
if platform != BINARY_SENSOR:
actions = entity_folder.get_by_name(KEY_ACTIONS)
if not actions or not actions.protocol == PROTO_PROGRAM:
if not actions or actions.protocol != PROTO_PROGRAM:
_LOGGER.warning(
"Program %s entity '%s' not loaded, invalid/missing actions program",
platform,

View File

@ -174,7 +174,7 @@ def async_setup_services(hass: HomeAssistantType):
for config_entry_id in hass.data[DOMAIN]:
isy = hass.data[DOMAIN][config_entry_id][ISY994_ISY]
if isy_name and not isy_name == isy.configuration["name"]:
if isy_name and isy_name != isy.configuration["name"]:
continue
# If an address is provided, make sure we query the correct ISY.
# Otherwise, query the whole system on all ISY's connected.
@ -199,7 +199,7 @@ def async_setup_services(hass: HomeAssistantType):
for config_entry_id in hass.data[DOMAIN]:
isy = hass.data[DOMAIN][config_entry_id][ISY994_ISY]
if isy_name and not isy_name == isy.configuration["name"]:
if isy_name and isy_name != isy.configuration["name"]:
continue
if not hasattr(isy, "networking") or isy.networking is None:
continue
@ -224,7 +224,7 @@ def async_setup_services(hass: HomeAssistantType):
for config_entry_id in hass.data[DOMAIN]:
isy = hass.data[DOMAIN][config_entry_id][ISY994_ISY]
if isy_name and not isy_name == isy.configuration["name"]:
if isy_name and isy_name != isy.configuration["name"]:
continue
program = None
if address:
@ -247,7 +247,7 @@ def async_setup_services(hass: HomeAssistantType):
for config_entry_id in hass.data[DOMAIN]:
isy = hass.data[DOMAIN][config_entry_id][ISY994_ISY]
if isy_name and not isy_name == isy.configuration["name"]:
if isy_name and isy_name != isy.configuration["name"]:
continue
variable = None
if name:

View File

@ -139,7 +139,7 @@ class OpenhomeDevice(MediaPlayerEntity):
def play_media(self, media_type, media_id, **kwargs):
"""Send the play_media command to the media player."""
if not media_type == MEDIA_TYPE_MUSIC:
if media_type != MEDIA_TYPE_MUSIC:
_LOGGER.error(
"Invalid media type %s. Only %s is supported",
media_type,

View File

@ -77,7 +77,7 @@ def _precheck_image(image, opts):
if imgfmt not in ("PNG", "JPEG"):
_LOGGER.warning("Image is of unsupported type: %s", imgfmt)
raise ValueError()
if not img.mode == "RGB":
if img.mode != "RGB":
img = img.convert("RGB")
return img

View File

@ -73,7 +73,7 @@ class PALoopbackSwitch(SwitchEntity):
self._pa_svr.connect()
for module in self._pa_svr.module_list():
if not module.name == "module-loopback":
if module.name != "module-loopback":
continue
if f"sink={self._sink_name}" not in module.argument:

View File

@ -465,7 +465,7 @@ class RoonDevice(MediaPlayerEntity):
return
for source in self.player_data["source_controls"]:
if source["supports_standby"] and not source["status"] == "indeterminate":
if source["supports_standby"] and source["status"] != "indeterminate":
self._server.roonapi.standby(self.output_id, source["control_key"])
return

View File

@ -159,7 +159,7 @@ class VlcDevice(MediaPlayerEntity):
def play_media(self, media_type, media_id, **kwargs):
"""Play media from a URL or file."""
if not media_type == MEDIA_TYPE_MUSIC:
if media_type != MEDIA_TYPE_MUSIC:
_LOGGER.error(
"Invalid media type %s. Only %s is supported",
media_type,

View File

@ -83,7 +83,7 @@ class ZHADeviceScannerEntity(ScannerEntity, ZhaEntity):
@callback
def async_battery_percentage_remaining_updated(self, attr_id, attr_name, value):
"""Handle tracking."""
if not attr_name == "battery_percentage_remaining":
if attr_name != "battery_percentage_remaining":
return
self.debug("battery_percentage_remaining updated: %s", value)
self._connected = True

View File

@ -197,8 +197,8 @@ class ZWaveListSensor(ZwaveSensorBase):
if self.info.primary_value.value is None:
return None
if (
not str(self.info.primary_value.value)
in self.info.primary_value.metadata.states
str(self.info.primary_value.value)
not in self.info.primary_value.metadata.states
):
return str(self.info.primary_value.value)
return str(

View File

@ -1439,7 +1439,7 @@ class TemplateEnvironment(ImmutableSandboxedEnvironment):
def is_safe_attribute(self, obj, attr, value):
"""Test if attribute is safe."""
if isinstance(obj, (AllStates, DomainStates, TemplateState)):
return not attr[0] == "_"
return attr[0] != "_"
if isinstance(obj, Namespace):
return True

View File

@ -243,7 +243,7 @@ class _GlobalTaskContext:
"""Wait until zones are done."""
await self._wait_zone.wait()
await asyncio.sleep(self._cool_down) # Allow context switch
if not self.state == _State.TIMEOUT:
if self.state != _State.TIMEOUT:
return
self._cancel_task()

View File

@ -106,8 +106,8 @@ def validate(integrations: dict[str, Integration], config: Config):
if (
not line.startswith("homeassistant/components/")
or not len(path.parts) == 4
or not path.parts[-1] == "*"
or len(path.parts) != 4
or path.parts[-1] != "*"
):
continue

View File

@ -525,9 +525,9 @@ async def test_current_cover_position(hass, mqtt_mock):
await hass.async_block_till_done()
state_attributes_dict = hass.states.get("cover.test").attributes
assert not (ATTR_CURRENT_POSITION in state_attributes_dict)
assert not (ATTR_CURRENT_TILT_POSITION in state_attributes_dict)
assert not (4 & hass.states.get("cover.test").attributes["supported_features"] == 4)
assert ATTR_CURRENT_POSITION not in state_attributes_dict
assert ATTR_CURRENT_TILT_POSITION not in state_attributes_dict
assert 4 & hass.states.get("cover.test").attributes["supported_features"] != 4
async_fire_mqtt_message(hass, "get-position-topic", "0")
current_cover_position = hass.states.get("cover.test").attributes[
@ -576,9 +576,9 @@ async def test_current_cover_position_inverted(hass, mqtt_mock):
await hass.async_block_till_done()
state_attributes_dict = hass.states.get("cover.test").attributes
assert not (ATTR_CURRENT_POSITION in state_attributes_dict)
assert not (ATTR_CURRENT_TILT_POSITION in state_attributes_dict)
assert not (4 & hass.states.get("cover.test").attributes["supported_features"] == 4)
assert ATTR_CURRENT_POSITION not in state_attributes_dict
assert ATTR_CURRENT_TILT_POSITION not in state_attributes_dict
assert 4 & hass.states.get("cover.test").attributes["supported_features"] != 4
async_fire_mqtt_message(hass, "get-position-topic", "100")
current_percentage_cover_position = hass.states.get("cover.test").attributes[
@ -659,14 +659,14 @@ async def test_position_update(hass, mqtt_mock):
await hass.async_block_till_done()
state_attributes_dict = hass.states.get("cover.test").attributes
assert not (ATTR_CURRENT_POSITION in state_attributes_dict)
assert not (ATTR_CURRENT_TILT_POSITION in state_attributes_dict)
assert ATTR_CURRENT_POSITION not in state_attributes_dict
assert ATTR_CURRENT_TILT_POSITION not in state_attributes_dict
assert 4 & hass.states.get("cover.test").attributes["supported_features"] == 4
async_fire_mqtt_message(hass, "get-position-topic", "22")
state_attributes_dict = hass.states.get("cover.test").attributes
assert ATTR_CURRENT_POSITION in state_attributes_dict
assert not (ATTR_CURRENT_TILT_POSITION in state_attributes_dict)
assert ATTR_CURRENT_TILT_POSITION not in state_attributes_dict
current_cover_position = hass.states.get("cover.test").attributes[
ATTR_CURRENT_POSITION
]

View File

@ -360,7 +360,7 @@ async def test_whitelist_no_match(mock_debug, hass):
await hass.async_block_till_done()
debug_log_call = mock_debug.call_args_list[-3]
assert not ("Event pilight_received" in debug_log_call)
assert "Event pilight_received" not in debug_log_call
async def test_call_rate_delay_throttle_enabled(hass):

View File

@ -157,7 +157,7 @@ async def test_purge_method(
assert runs[1] == runs_before_purge[5]
assert runs[2] == runs_before_purge[6]
assert not ("EVENT_TEST_PURGE" in (event.event_type for event in events.all()))
assert "EVENT_TEST_PURGE" not in (event.event_type for event in events.all())
# run purge method - correct service data, with repack
service_data["repack"] = True

View File

@ -333,7 +333,7 @@ class TestMediaPlayer(unittest.TestCase):
config = {"name": "test", "asdf": 5, "platform": "universal"}
config = validate_config(config)
assert not ("asdf" in config)
assert "asdf" not in config
def test_platform_setup(self):
"""Test platform setup."""