Replace pylint pointless-statement with ruff B018 (#113582)

* Replace pylint pointless-statement with ruff B018

* fix occurrences of B018

* disable pylint expression-not-assigned as well

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
pull/113678/head
Sid 2024-03-17 10:58:14 +01:00 committed by GitHub
parent 7b20641651
commit 6113b99ddd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 15 additions and 15 deletions

View File

@ -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 asyncio event loop. By primeing the cache of uname we can
avoid the blocking call in the event loop. 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 # Load the registries and cache the result of platform.uname().processor
translation.async_setup(hass) translation.async_setup(hass)

View File

@ -183,7 +183,7 @@ def _parse_client_id(client_id: str) -> ParseResult:
# MAY contain a port # MAY contain a port
try: try:
# parts raises ValueError when port cannot be parsed as int # parts raises ValueError when port cannot be parsed as int
parts.port _ = parts.port
except ValueError as ex: except ValueError as ex:
raise ValueError("Client ID contains invalid port") from ex raise ValueError("Client ID contains invalid port") from ex

View File

@ -70,7 +70,7 @@ class LutronCover(LutronDevice, CoverEntity):
def _request_state(self) -> None: def _request_state(self) -> None:
"""Request the state from the device.""" """Request the state from the device."""
self._lutron_device.level # pylint: disable=pointless-statement _ = self._lutron_device.level
def _update_attrs(self) -> None: def _update_attrs(self) -> None:
"""Update the state attributes.""" """Update the state attributes."""

View File

@ -79,7 +79,7 @@ class LutronFan(LutronDevice, FanEntity):
def _request_state(self) -> None: def _request_state(self) -> None:
"""Request the state from the device.""" """Request the state from the device."""
self._lutron_device.level # pylint: disable=pointless-statement _ = self._lutron_device.level
def _update_attrs(self) -> None: def _update_attrs(self) -> None:
"""Update the state attributes.""" """Update the state attributes."""

View File

@ -171,7 +171,7 @@ class LutronLight(LutronDevice, LightEntity):
def _request_state(self) -> None: def _request_state(self) -> None:
"""Request the state from the device.""" """Request the state from the device."""
self._lutron_device.level # pylint: disable=pointless-statement _ = self._lutron_device.level
def _update_attrs(self) -> None: def _update_attrs(self) -> None:
"""Update the state attributes.""" """Update the state attributes."""

View File

@ -61,7 +61,7 @@ class LutronSwitch(LutronDevice, SwitchEntity):
def _request_state(self) -> None: def _request_state(self) -> None:
"""Request the state from the device.""" """Request the state from the device."""
self._lutron_device.level # pylint: disable=pointless-statement _ = self._lutron_device.level
def _update_attrs(self) -> None: def _update_attrs(self) -> None:
"""Update the state attributes.""" """Update the state attributes."""
@ -105,7 +105,7 @@ class LutronLed(LutronKeypad, SwitchEntity):
def _request_state(self) -> None: def _request_state(self) -> None:
"""Request the state from the device.""" """Request the state from the device."""
self._lutron_device.state # pylint: disable=pointless-statement _ = self._lutron_device.state
def _update_attrs(self) -> None: def _update_attrs(self) -> None:
"""Update the state attributes.""" """Update the state attributes."""

View File

@ -231,7 +231,7 @@ disable = [
"duplicate-value", # F "duplicate-value", # F
"eval-used", # S307 "eval-used", # S307
"exec-used", # S102 "exec-used", # S102
# "expression-not-assigned", # B018, ruff catches new occurrences, needs more work "expression-not-assigned", # B018
"f-string-without-interpolation", # F541 "f-string-without-interpolation", # F541
"forgotten-debug-statement", # T100 "forgotten-debug-statement", # T100
"format-string-without-interpolation", # F "format-string-without-interpolation", # F
@ -248,7 +248,7 @@ disable = [
"misplaced-future", # F404 "misplaced-future", # F404
"named-expr-without-context", # PLW0131 "named-expr-without-context", # PLW0131
"nested-min-max", # PLW3301 "nested-min-max", # PLW3301
# "pointless-statement", # B018, ruff catches new occurrences, needs more work "pointless-statement", # B018
"raise-missing-from", # B904 "raise-missing-from", # B904
# "redefined-builtin", # A001, ruff is way more stricter, needs work # "redefined-builtin", # A001, ruff is way more stricter, needs work
"try-except-raise", # TRY302 "try-except-raise", # TRY302
@ -585,6 +585,7 @@ select = [
"B007", # Loop control variable {name} not used within loop body "B007", # Loop control variable {name} not used within loop body
"B014", # Exception handler with duplicate exception "B014", # Exception handler with duplicate exception
"B015", # Pointless comparison. Did you mean to assign a value? Otherwise, prepend assert or remove it. "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} "B023", # Function definition does not bind loop variable {name}
"B026", # Star-arg unpacking after a keyword argument is strongly discouraged "B026", # Star-arg unpacking after a keyword argument is strongly discouraged
"B032", # Possible unintentional type annotation (using :). Did you mean to assign (using =)? "B032", # Possible unintentional type annotation (using :). Did you mean to assign (using =)?

View File

@ -49,7 +49,7 @@ async def test_event() -> None:
# No event types defined, should raise # No event types defined, should raise
with pytest.raises(AttributeError): with pytest.raises(AttributeError):
event.event_types _ = event.event_types
# Test retrieving data from entity description # Test retrieving data from entity description
event.entity_description = EventEntityDescription( event.entity_description = EventEntityDescription(

View File

@ -1835,7 +1835,6 @@ async def test_history_stream_historical_only_with_start_time_state_past(
await async_setup_component(hass, "sensor", {}) await async_setup_component(hass, "sensor", {})
hass.states.async_set("sensor.one", "first", attributes={"any": "attr"}) 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 async_recorder_block_till_done(hass)
await asyncio.sleep(0.00002) await asyncio.sleep(0.00002)

View File

@ -39,7 +39,7 @@ def test_kira_sensor_callback(
codeTuple = (codeName, deviceName) codeTuple = (codeName, deviceName)
sensor._update_callback(codeTuple) sensor._update_callback(codeTuple)
mock_schedule_update_ha_state.assert_called mock_schedule_update_ha_state.assert_called()
assert sensor.state == codeName assert sensor.state == codeName
assert sensor.extra_state_attributes == {kira.CONF_DEVICE: deviceName} assert sensor.extra_state_attributes == {kira.CONF_DEVICE: deviceName}

View File

@ -298,7 +298,7 @@ async def test_valve_report_position(hass: HomeAssistant) -> None:
default_valve.hass = hass default_valve.hass = hass
with pytest.raises(ValueError): with pytest.raises(ValueError):
default_valve.reports_position _ = default_valve.reports_position
second_valve = MockValveEntity(reports_position=True) second_valve = MockValveEntity(reports_position=True)
second_valve.hass = hass second_valve.hass = hass

View File

@ -2422,7 +2422,7 @@ async def test_hassjob_forbid_coroutine() -> None:
coro = bla() coro = bla()
with pytest.raises(ValueError): with pytest.raises(ValueError):
ha.HassJob(coro).job_type _ = ha.HassJob(coro).job_type
# To avoid warning about unawaited coro # To avoid warning about unawaited coro
await coro await coro

View File

@ -72,7 +72,7 @@ def test_component_loader_non_existing(hass: HomeAssistant) -> None:
"""Test loading components.""" """Test loading components."""
components = loader.Components(hass) components = loader.Components(hass)
with pytest.raises(ImportError): with pytest.raises(ImportError):
components.non_existing _ = components.non_existing
async def test_component_wrapper(hass: HomeAssistant) -> None: async def test_component_wrapper(hass: HomeAssistant) -> None: