mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 15:57:06 +00:00
Enable Ruff SIM201 (#88171)
This commit is contained in:
parent
443d446cbf
commit
f67ebcade1
@ -61,7 +61,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
raise ConfigEntryNotReady
|
||||
|
||||
board: str | None
|
||||
if (board := os_info.get("board")) is None or not board == "yellow":
|
||||
if (board := os_info.get("board")) is None or board != "yellow":
|
||||
# Not running on a Home Assistant Yellow, Home Assistant may have been migrated
|
||||
hass.async_create_task(hass.config_entries.async_remove(entry.entry_id))
|
||||
return False
|
||||
|
@ -332,7 +332,7 @@ class Schedule(CollectionEntity):
|
||||
possible_next_event := (
|
||||
datetime.combine(now.date(), timestamp, tzinfo=now.tzinfo)
|
||||
+ timedelta(days=day)
|
||||
if not timestamp == time.max
|
||||
if timestamp != time.max
|
||||
# Special case for midnight of the following day.
|
||||
else datetime.combine(now.date(), time(), tzinfo=now.tzinfo)
|
||||
+ timedelta(days=day + 1)
|
||||
|
@ -204,7 +204,7 @@ async def async_setup_entry(
|
||||
entities: list[FanEntity] = []
|
||||
entity: FanEntity
|
||||
|
||||
if not config_entry.data[CONF_FLOW_TYPE] == CONF_DEVICE:
|
||||
if config_entry.data[CONF_FLOW_TYPE] != CONF_DEVICE:
|
||||
return
|
||||
|
||||
hass.data.setdefault(DATA_KEY, {})
|
||||
|
@ -71,7 +71,7 @@ async def async_setup_entry(
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the Humidifier from a config entry."""
|
||||
if not config_entry.data[CONF_FLOW_TYPE] == CONF_DEVICE:
|
||||
if config_entry.data[CONF_FLOW_TYPE] != CONF_DEVICE:
|
||||
return
|
||||
|
||||
entities: list[HumidifierEntity] = []
|
||||
|
@ -292,7 +292,7 @@ async def async_setup_entry(
|
||||
) -> None:
|
||||
"""Set up the Selectors from a config entry."""
|
||||
entities = []
|
||||
if not config_entry.data[CONF_FLOW_TYPE] == CONF_DEVICE:
|
||||
if config_entry.data[CONF_FLOW_TYPE] != CONF_DEVICE:
|
||||
return
|
||||
model = config_entry.data[CONF_MODEL]
|
||||
device = hass.data[DOMAIN][config_entry.entry_id][KEY_DEVICE]
|
||||
|
@ -204,7 +204,7 @@ async def async_setup_entry(
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the Selectors from a config entry."""
|
||||
if not config_entry.data[CONF_FLOW_TYPE] == CONF_DEVICE:
|
||||
if config_entry.data[CONF_FLOW_TYPE] != CONF_DEVICE:
|
||||
return
|
||||
|
||||
model = config_entry.data[CONF_MODEL]
|
||||
|
@ -250,6 +250,7 @@ select = [
|
||||
"SIM105", # Use contextlib.suppress({exception}) instead of try-except-pass
|
||||
"SIM117", # Merge with-statements that use the same scope
|
||||
"SIM118", # Use {key} in {dict} instead of {key} in {dict}.keys()
|
||||
"SIM201", # Use {left} != {right} instead of not {left} == {right}
|
||||
"SIM300", # Yoda conditions. Use 'age == 42' instead of '42 == age'.
|
||||
"SIM401", # Use get from dict with default instead of an if block
|
||||
"T20", # flake8-print
|
||||
|
@ -2123,7 +2123,7 @@ async def test_live_stream_with_one_second_commit_interval(
|
||||
|
||||
hass.bus.async_fire("mock_event", {"device_id": device.id, "message": "7"})
|
||||
|
||||
while not len(recieved_rows) == 7:
|
||||
while len(recieved_rows) != 7:
|
||||
msg = await asyncio.wait_for(websocket_client.receive_json(), 2.5)
|
||||
assert msg["id"] == 7
|
||||
assert msg["type"] == "event"
|
||||
|
@ -20,7 +20,7 @@ from tests.common import get_test_config_dir, patch_yaml_files
|
||||
@pytest.fixture(params=["enable_c_loader", "disable_c_loader"])
|
||||
def try_both_loaders(request):
|
||||
"""Disable the yaml c loader."""
|
||||
if not request.param == "disable_c_loader":
|
||||
if request.param != "disable_c_loader":
|
||||
yield
|
||||
return
|
||||
try:
|
||||
@ -37,7 +37,7 @@ def try_both_loaders(request):
|
||||
@pytest.fixture(params=["enable_c_dumper", "disable_c_dumper"])
|
||||
def try_both_dumpers(request):
|
||||
"""Disable the yaml c dumper."""
|
||||
if not request.param == "disable_c_dumper":
|
||||
if request.param != "disable_c_dumper":
|
||||
yield
|
||||
return
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user