diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index 89e36e7e557..85ee15e3aa0 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -340,7 +340,7 @@ async def async_load_base_functionality(hass: core.HomeAssistant) -> None: asyncio event loop. By primeing the cache of uname we can avoid the blocking call in the event loop. """ - platform.uname().processor # pylint: disable=expression-not-assigned + _ = platform.uname().processor # Load the registries and cache the result of platform.uname().processor translation.async_setup(hass) diff --git a/homeassistant/components/auth/indieauth.py b/homeassistant/components/auth/indieauth.py index 9284c232d38..2c90d33b1d8 100644 --- a/homeassistant/components/auth/indieauth.py +++ b/homeassistant/components/auth/indieauth.py @@ -183,7 +183,7 @@ def _parse_client_id(client_id: str) -> ParseResult: # MAY contain a port try: # parts raises ValueError when port cannot be parsed as int - parts.port + _ = parts.port except ValueError as ex: raise ValueError("Client ID contains invalid port") from ex diff --git a/homeassistant/components/lutron/cover.py b/homeassistant/components/lutron/cover.py index 247ead3ccec..2f80798aee4 100644 --- a/homeassistant/components/lutron/cover.py +++ b/homeassistant/components/lutron/cover.py @@ -70,7 +70,7 @@ class LutronCover(LutronDevice, CoverEntity): def _request_state(self) -> None: """Request the state from the device.""" - self._lutron_device.level # pylint: disable=pointless-statement + _ = self._lutron_device.level def _update_attrs(self) -> None: """Update the state attributes.""" diff --git a/homeassistant/components/lutron/fan.py b/homeassistant/components/lutron/fan.py index 07e0bb444b2..c350e70b222 100644 --- a/homeassistant/components/lutron/fan.py +++ b/homeassistant/components/lutron/fan.py @@ -79,7 +79,7 @@ class LutronFan(LutronDevice, FanEntity): def _request_state(self) -> None: """Request the state from the device.""" - self._lutron_device.level # pylint: disable=pointless-statement + _ = self._lutron_device.level def _update_attrs(self) -> None: """Update the state attributes.""" diff --git a/homeassistant/components/lutron/light.py b/homeassistant/components/lutron/light.py index f4088d687cd..18b5edd1039 100644 --- a/homeassistant/components/lutron/light.py +++ b/homeassistant/components/lutron/light.py @@ -171,7 +171,7 @@ class LutronLight(LutronDevice, LightEntity): def _request_state(self) -> None: """Request the state from the device.""" - self._lutron_device.level # pylint: disable=pointless-statement + _ = self._lutron_device.level def _update_attrs(self) -> None: """Update the state attributes.""" diff --git a/homeassistant/components/lutron/switch.py b/homeassistant/components/lutron/switch.py index 9ffce0aa530..c8b93dd7398 100644 --- a/homeassistant/components/lutron/switch.py +++ b/homeassistant/components/lutron/switch.py @@ -61,7 +61,7 @@ class LutronSwitch(LutronDevice, SwitchEntity): def _request_state(self) -> None: """Request the state from the device.""" - self._lutron_device.level # pylint: disable=pointless-statement + _ = self._lutron_device.level def _update_attrs(self) -> None: """Update the state attributes.""" @@ -105,7 +105,7 @@ class LutronLed(LutronKeypad, SwitchEntity): def _request_state(self) -> None: """Request the state from the device.""" - self._lutron_device.state # pylint: disable=pointless-statement + _ = self._lutron_device.state def _update_attrs(self) -> None: """Update the state attributes.""" diff --git a/pyproject.toml b/pyproject.toml index 0bd8e592d86..5c6fbd2c1e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -231,7 +231,7 @@ disable = [ "duplicate-value", # F "eval-used", # S307 "exec-used", # S102 - # "expression-not-assigned", # B018, ruff catches new occurrences, needs more work + "expression-not-assigned", # B018 "f-string-without-interpolation", # F541 "forgotten-debug-statement", # T100 "format-string-without-interpolation", # F @@ -248,7 +248,7 @@ disable = [ "misplaced-future", # F404 "named-expr-without-context", # PLW0131 "nested-min-max", # PLW3301 - # "pointless-statement", # B018, ruff catches new occurrences, needs more work + "pointless-statement", # B018 "raise-missing-from", # B904 # "redefined-builtin", # A001, ruff is way more stricter, needs work "try-except-raise", # TRY302 @@ -585,6 +585,7 @@ select = [ "B007", # Loop control variable {name} not used within loop body "B014", # Exception handler with duplicate exception "B015", # Pointless comparison. Did you mean to assign a value? Otherwise, prepend assert or remove it. + "B018", # Found useless attribute access. Either assign it to a variable or remove it. "B023", # Function definition does not bind loop variable {name} "B026", # Star-arg unpacking after a keyword argument is strongly discouraged "B032", # Possible unintentional type annotation (using :). Did you mean to assign (using =)? diff --git a/tests/components/event/test_init.py b/tests/components/event/test_init.py index 41bdac5e6bd..25cb5af3e08 100644 --- a/tests/components/event/test_init.py +++ b/tests/components/event/test_init.py @@ -49,7 +49,7 @@ async def test_event() -> None: # No event types defined, should raise with pytest.raises(AttributeError): - event.event_types + _ = event.event_types # Test retrieving data from entity description event.entity_description = EventEntityDescription( diff --git a/tests/components/history/test_websocket_api.py b/tests/components/history/test_websocket_api.py index 72fd9420a61..154e29a0989 100644 --- a/tests/components/history/test_websocket_api.py +++ b/tests/components/history/test_websocket_api.py @@ -1835,7 +1835,6 @@ async def test_history_stream_historical_only_with_start_time_state_past( await async_setup_component(hass, "sensor", {}) hass.states.async_set("sensor.one", "first", attributes={"any": "attr"}) - hass.states.get("sensor.one").last_updated await async_recorder_block_till_done(hass) await asyncio.sleep(0.00002) diff --git a/tests/components/kira/test_sensor.py b/tests/components/kira/test_sensor.py index 8619c6953ab..fe0fc95a918 100644 --- a/tests/components/kira/test_sensor.py +++ b/tests/components/kira/test_sensor.py @@ -39,7 +39,7 @@ def test_kira_sensor_callback( codeTuple = (codeName, deviceName) sensor._update_callback(codeTuple) - mock_schedule_update_ha_state.assert_called + mock_schedule_update_ha_state.assert_called() assert sensor.state == codeName assert sensor.extra_state_attributes == {kira.CONF_DEVICE: deviceName} diff --git a/tests/components/valve/test_init.py b/tests/components/valve/test_init.py index 314819c4cc8..23071718724 100644 --- a/tests/components/valve/test_init.py +++ b/tests/components/valve/test_init.py @@ -298,7 +298,7 @@ async def test_valve_report_position(hass: HomeAssistant) -> None: default_valve.hass = hass with pytest.raises(ValueError): - default_valve.reports_position + _ = default_valve.reports_position second_valve = MockValveEntity(reports_position=True) second_valve.hass = hass diff --git a/tests/test_core.py b/tests/test_core.py index da4a87702f5..78229c4b445 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -2422,7 +2422,7 @@ async def test_hassjob_forbid_coroutine() -> None: coro = bla() with pytest.raises(ValueError): - ha.HassJob(coro).job_type + _ = ha.HassJob(coro).job_type # To avoid warning about unawaited coro await coro diff --git a/tests/test_loader.py b/tests/test_loader.py index a2868976876..ae21d75a6e1 100644 --- a/tests/test_loader.py +++ b/tests/test_loader.py @@ -72,7 +72,7 @@ def test_component_loader_non_existing(hass: HomeAssistant) -> None: """Test loading components.""" components = loader.Components(hass) with pytest.raises(ImportError): - components.non_existing + _ = components.non_existing async def test_component_wrapper(hass: HomeAssistant) -> None: