From f67ebcade1d14a53f788cbbd6db9c190d943b6c9 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Wed, 15 Feb 2023 14:43:02 +0100 Subject: [PATCH] Enable Ruff SIM201 (#88171) --- homeassistant/components/homeassistant_yellow/__init__.py | 2 +- homeassistant/components/schedule/__init__.py | 2 +- homeassistant/components/xiaomi_miio/fan.py | 2 +- homeassistant/components/xiaomi_miio/humidifier.py | 2 +- homeassistant/components/xiaomi_miio/number.py | 2 +- homeassistant/components/xiaomi_miio/select.py | 2 +- pyproject.toml | 1 + tests/components/logbook/test_websocket_api.py | 2 +- tests/util/yaml/test_init.py | 4 ++-- 9 files changed, 10 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/homeassistant_yellow/__init__.py b/homeassistant/components/homeassistant_yellow/__init__.py index 48c2e74bd38..9e22736fc71 100644 --- a/homeassistant/components/homeassistant_yellow/__init__.py +++ b/homeassistant/components/homeassistant_yellow/__init__.py @@ -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 diff --git a/homeassistant/components/schedule/__init__.py b/homeassistant/components/schedule/__init__.py index d7c61798587..fb00d58c7ac 100644 --- a/homeassistant/components/schedule/__init__.py +++ b/homeassistant/components/schedule/__init__.py @@ -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) diff --git a/homeassistant/components/xiaomi_miio/fan.py b/homeassistant/components/xiaomi_miio/fan.py index 7153247e7d2..aaf471518d8 100644 --- a/homeassistant/components/xiaomi_miio/fan.py +++ b/homeassistant/components/xiaomi_miio/fan.py @@ -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, {}) diff --git a/homeassistant/components/xiaomi_miio/humidifier.py b/homeassistant/components/xiaomi_miio/humidifier.py index 2cf3944bb91..50e0cd8c72d 100644 --- a/homeassistant/components/xiaomi_miio/humidifier.py +++ b/homeassistant/components/xiaomi_miio/humidifier.py @@ -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] = [] diff --git a/homeassistant/components/xiaomi_miio/number.py b/homeassistant/components/xiaomi_miio/number.py index 61562492742..732710f7129 100644 --- a/homeassistant/components/xiaomi_miio/number.py +++ b/homeassistant/components/xiaomi_miio/number.py @@ -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] diff --git a/homeassistant/components/xiaomi_miio/select.py b/homeassistant/components/xiaomi_miio/select.py index f84b67ef3f2..74ce36ca57a 100644 --- a/homeassistant/components/xiaomi_miio/select.py +++ b/homeassistant/components/xiaomi_miio/select.py @@ -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] diff --git a/pyproject.toml b/pyproject.toml index d12f0caa3c4..e57592e9f99 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 diff --git a/tests/components/logbook/test_websocket_api.py b/tests/components/logbook/test_websocket_api.py index f07bbfa740c..48799a26ab7 100644 --- a/tests/components/logbook/test_websocket_api.py +++ b/tests/components/logbook/test_websocket_api.py @@ -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" diff --git a/tests/util/yaml/test_init.py b/tests/util/yaml/test_init.py index f02e58b7384..aa8276ea2fd 100644 --- a/tests/util/yaml/test_init.py +++ b/tests/util/yaml/test_init.py @@ -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: