From 0fdf037ba03c223677d4c8a3e7b5f163f8810cd2 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Fri, 28 Jun 2024 11:56:49 +0200 Subject: [PATCH] Fix ruff type comparison E721 (#120731) Fix E721 --- homeassistant/components/insteon/api/properties.py | 6 +++--- tests/auth/mfa_modules/test_insecure_example.py | 2 +- tests/auth/mfa_modules/test_notify.py | 4 ++-- tests/auth/mfa_modules/test_totp.py | 2 +- tests/components/number/test_init.py | 2 +- tests/components/plaato/test_config_flow.py | 6 +++--- tests/components/python_script/test_init.py | 6 +++--- tests/components/rtsp_to_webrtc/test_config_flow.py | 4 ++-- tests/components/sensor/test_init.py | 4 ++-- tests/components/zwave_js/test_helpers.py | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/homeassistant/components/insteon/api/properties.py b/homeassistant/components/insteon/api/properties.py index 20e798dded0..4d36f1d71e5 100644 --- a/homeassistant/components/insteon/api/properties.py +++ b/homeassistant/components/insteon/api/properties.py @@ -85,11 +85,11 @@ def get_schema(prop, name, groups): if name == LOAD_BUTTON: button_list = {group: groups[group].name for group in groups} return _list_schema(name, button_list) - if prop.value_type == bool: + if prop.value_type is bool: return _bool_schema(name) - if prop.value_type == int: + if prop.value_type is int: return _byte_schema(name) - if prop.value_type == float: + if prop.value_type is float: return _float_schema(name) if prop.value_type == ToggleMode: return _list_schema(name, TOGGLE_MODES) diff --git a/tests/auth/mfa_modules/test_insecure_example.py b/tests/auth/mfa_modules/test_insecure_example.py index f7f8a327059..8caca780ecb 100644 --- a/tests/auth/mfa_modules/test_insecure_example.py +++ b/tests/auth/mfa_modules/test_insecure_example.py @@ -121,7 +121,7 @@ async def test_login(hass: HomeAssistant) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["step_id"] == "mfa" - assert result["data_schema"].schema.get("pin") == str + assert result["data_schema"].schema.get("pin") is str result = await hass.auth.login_flow.async_configure( result["flow_id"], {"pin": "invalid-code"} diff --git a/tests/auth/mfa_modules/test_notify.py b/tests/auth/mfa_modules/test_notify.py index 23b8811dbf9..d6f4d80f99e 100644 --- a/tests/auth/mfa_modules/test_notify.py +++ b/tests/auth/mfa_modules/test_notify.py @@ -155,7 +155,7 @@ async def test_login_flow_validates_mfa(hass: HomeAssistant) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["step_id"] == "mfa" - assert result["data_schema"].schema.get("code") == str + assert result["data_schema"].schema.get("code") is str # wait service call finished await hass.async_block_till_done() @@ -214,7 +214,7 @@ async def test_login_flow_validates_mfa(hass: HomeAssistant) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["step_id"] == "mfa" - assert result["data_schema"].schema.get("code") == str + assert result["data_schema"].schema.get("code") is str # wait service call finished await hass.async_block_till_done() diff --git a/tests/auth/mfa_modules/test_totp.py b/tests/auth/mfa_modules/test_totp.py index 961db3f44ca..fadc3214712 100644 --- a/tests/auth/mfa_modules/test_totp.py +++ b/tests/auth/mfa_modules/test_totp.py @@ -114,7 +114,7 @@ async def test_login_flow_validates_mfa(hass: HomeAssistant) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["step_id"] == "mfa" - assert result["data_schema"].schema.get("code") == str + assert result["data_schema"].schema.get("code") is str with patch("pyotp.TOTP.verify", return_value=False): result = await hass.auth.login_flow.async_configure( diff --git a/tests/components/number/test_init.py b/tests/components/number/test_init.py index 6f74a3126c0..aa5df5d737f 100644 --- a/tests/components/number/test_init.py +++ b/tests/components/number/test_init.py @@ -646,7 +646,7 @@ async def test_restore_number_restore_state( assert entity0.native_min_value == native_min_value assert entity0.native_step == native_step assert entity0.native_value == native_value - assert type(entity0.native_value) == native_value_type + assert type(entity0.native_value) is native_value_type assert entity0.native_unit_of_measurement == uom diff --git a/tests/components/plaato/test_config_flow.py b/tests/components/plaato/test_config_flow.py index efda354f20d..ceadab7f832 100644 --- a/tests/components/plaato/test_config_flow.py +++ b/tests/components/plaato/test_config_flow.py @@ -64,8 +64,8 @@ async def test_show_config_form_device_type_airlock(hass: HomeAssistant) -> None assert result["type"] is FlowResultType.FORM assert result["step_id"] == "api_method" - assert result["data_schema"].schema.get(CONF_TOKEN) == str - assert result["data_schema"].schema.get(CONF_USE_WEBHOOK) == bool + assert result["data_schema"].schema.get(CONF_TOKEN) is str + assert result["data_schema"].schema.get(CONF_USE_WEBHOOK) is bool async def test_show_config_form_device_type_keg(hass: HomeAssistant) -> None: @@ -78,7 +78,7 @@ async def test_show_config_form_device_type_keg(hass: HomeAssistant) -> None: assert result["type"] is FlowResultType.FORM assert result["step_id"] == "api_method" - assert result["data_schema"].schema.get(CONF_TOKEN) == str + assert result["data_schema"].schema.get(CONF_TOKEN) is str assert result["data_schema"].schema.get(CONF_USE_WEBHOOK) is None diff --git a/tests/components/python_script/test_init.py b/tests/components/python_script/test_init.py index 03fa73f076e..c4dc00c448a 100644 --- a/tests/components/python_script/test_init.py +++ b/tests/components/python_script/test_init.py @@ -155,7 +155,7 @@ raise Exception('boom') task = hass.async_add_executor_job(execute, hass, "test.py", source, {}, True) await hass.async_block_till_done(wait_background_tasks=True) - assert type(task.exception()) == HomeAssistantError + assert type(task.exception()) is HomeAssistantError assert "Error executing script (Exception): boom" in str(task.exception()) @@ -183,7 +183,7 @@ hass.async_stop() task = hass.async_add_executor_job(execute, hass, "test.py", source, {}, True) await hass.async_block_till_done(wait_background_tasks=True) - assert type(task.exception()) == ServiceValidationError + assert type(task.exception()) is ServiceValidationError assert "Not allowed to access async methods" in str(task.exception()) @@ -233,7 +233,7 @@ async def test_accessing_forbidden_methods_with_response(hass: HomeAssistant) -> task = hass.async_add_executor_job(execute, hass, "test.py", source, {}, True) await hass.async_block_till_done(wait_background_tasks=True) - assert type(task.exception()) == ServiceValidationError + assert type(task.exception()) is ServiceValidationError assert f"Not allowed to access {name}" in str(task.exception()) diff --git a/tests/components/rtsp_to_webrtc/test_config_flow.py b/tests/components/rtsp_to_webrtc/test_config_flow.py index 504ede68ac7..5daf9400396 100644 --- a/tests/components/rtsp_to_webrtc/test_config_flow.py +++ b/tests/components/rtsp_to_webrtc/test_config_flow.py @@ -25,7 +25,7 @@ async def test_web_full_flow(hass: HomeAssistant) -> None: ) assert result.get("type") is FlowResultType.FORM assert result.get("step_id") == "user" - assert result.get("data_schema").schema.get("server_url") == str + assert result.get("data_schema").schema.get("server_url") is str assert not result.get("errors") with ( patch("rtsp_to_webrtc.client.Client.heartbeat"), @@ -64,7 +64,7 @@ async def test_invalid_url(hass: HomeAssistant) -> None: ) assert result.get("type") is FlowResultType.FORM assert result.get("step_id") == "user" - assert result.get("data_schema").schema.get("server_url") == str + assert result.get("data_schema").schema.get("server_url") is str assert not result.get("errors") result = await hass.config_entries.flow.async_configure( result["flow_id"], {"server_url": "not-a-url"} diff --git a/tests/components/sensor/test_init.py b/tests/components/sensor/test_init.py index 126e327f364..689a91f770d 100644 --- a/tests/components/sensor/test_init.py +++ b/tests/components/sensor/test_init.py @@ -418,7 +418,7 @@ async def test_restore_sensor_save_state( assert state["entity_id"] == entity0.entity_id extra_data = hass_storage[RESTORE_STATE_KEY]["data"][0]["extra_data"] assert extra_data == expected_extra_data - assert type(extra_data["native_value"]) == native_value_type + assert type(extra_data["native_value"]) is native_value_type @pytest.mark.parametrize( @@ -479,7 +479,7 @@ async def test_restore_sensor_restore_state( assert hass.states.get(entity0.entity_id) assert entity0.native_value == native_value - assert type(entity0.native_value) == native_value_type + assert type(entity0.native_value) is native_value_type assert entity0.native_unit_of_measurement == uom diff --git a/tests/components/zwave_js/test_helpers.py b/tests/components/zwave_js/test_helpers.py index 016a2d718ac..2df2e134f49 100644 --- a/tests/components/zwave_js/test_helpers.py +++ b/tests/components/zwave_js/test_helpers.py @@ -42,4 +42,4 @@ async def test_get_value_state_schema_boolean_config_value( aeon_smart_switch_6.values["102-112-0-255"] ) assert isinstance(schema_validator, vol.Coerce) - assert schema_validator.type == bool + assert schema_validator.type is bool