Skip to content

Commit

Permalink
Update Ruff to v0.0.247 (home-assistant#88210)
Browse files Browse the repository at this point in the history
* Update Ruff to v0.0.247

* Fix new found violations
  • Loading branch information
frenck authored Feb 15, 2023
1 parent a1efd59 commit d3ed8de
Show file tree
Hide file tree
Showing 40 changed files with 135 additions and 106 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.241
rev: v0.0.247
hooks:
- id: ruff
args:
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/esphome/bluetooth/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def verify_connected(func: _WrapFuncType) -> _WrapFuncType:
"""Define a wrapper throw BleakError if not connected."""

async def _async_wrap_bluetooth_connected_operation(
self: "ESPHomeClient", *args: Any, **kwargs: Any
self: ESPHomeClient, *args: Any, **kwargs: Any
) -> Any:
disconnected_event = (
self._disconnected_event # pylint: disable=protected-access
Expand Down Expand Up @@ -94,7 +94,7 @@ def api_error_as_bleak_error(func: _WrapFuncType) -> _WrapFuncType:
"""Define a wrapper throw esphome api errors as BleakErrors."""

async def _async_wrap_bluetooth_operation(
self: "ESPHomeClient", *args: Any, **kwargs: Any
self: ESPHomeClient, *args: Any, **kwargs: Any
) -> Any:
try:
return await func(self, *args, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/hue/v1/device_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def _get_hue_event_from_device_id(hass, device_id):


async def async_validate_trigger_config(
bridge: "HueBridge", device_entry: DeviceEntry, config: ConfigType
bridge: HueBridge, device_entry: DeviceEntry, config: ConfigType
) -> ConfigType:
"""Validate config."""
config = TRIGGER_SCHEMA(config)
Expand All @@ -144,7 +144,7 @@ async def async_validate_trigger_config(


async def async_attach_trigger(
bridge: "HueBridge",
bridge: HueBridge,
device_entry: DeviceEntry,
config: ConfigType,
action: TriggerActionType,
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/hue/v2/device_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@


async def async_validate_trigger_config(
bridge: "HueBridge",
bridge: HueBridge,
device_entry: DeviceEntry,
config: ConfigType,
) -> ConfigType:
Expand All @@ -71,7 +71,7 @@ async def async_validate_trigger_config(


async def async_attach_trigger(
bridge: "HueBridge",
bridge: HueBridge,
device_entry: DeviceEntry,
config: ConfigType,
action: TriggerActionType,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/yeelight/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def _parse_custom_effects(effects_config) -> dict[str, dict[str, Any]]:
def _async_cmd(func):
"""Define a wrapper to catch exceptions from the bulb."""

async def _async_wrap(self: "YeelightGenericLight", *args, **kwargs):
async def _async_wrap(self: YeelightGenericLight, *args, **kwargs):
for attempts in range(2):
try:
_LOGGER.debug("Calling %s with %s %s", func, args, kwargs)
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_pre_commit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ pycodestyle==2.10.0
pydocstyle==6.2.3
pyflakes==3.0.1
pyupgrade==3.3.1
ruff==0.0.241
ruff==0.0.247
yamllint==1.28.0
2 changes: 1 addition & 1 deletion tests/components/airvisual/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
],
)
@pytest.mark.parametrize(
"response,errors",
("response", "errors"),
[
(AsyncMock(side_effect=AirVisualError), {"base": "unknown"}),
(AsyncMock(side_effect=InvalidKeyError), {CONF_API_KEY: "invalid_api_key"}),
Expand Down
2 changes: 1 addition & 1 deletion tests/components/automation/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -2202,7 +2202,7 @@ async def test_trigger_condition_explicit_id(hass: HomeAssistant, calls) -> None
),
)
@pytest.mark.parametrize(
"script_mode,script_warning_msg",
("script_mode", "script_warning_msg"),
(
(SCRIPT_MODE_PARALLEL, "script1: Maximum number of runs exceeded"),
(SCRIPT_MODE_QUEUED, "script1: Disallowed recursion detected"),
Expand Down
12 changes: 6 additions & 6 deletions tests/components/energy/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ async def test_cost_sensor_attributes(
("initial_energy", "initial_cost"), [(0, "0.0"), (None, "unknown")]
)
@pytest.mark.parametrize(
"price_entity,fixed_price", [("sensor.energy_price", None), (None, 1)]
("price_entity", "fixed_price"), [("sensor.energy_price", None), (None, 1)]
)
@pytest.mark.parametrize(
"usage_sensor_entity_id,cost_sensor_entity_id,flow_type",
("usage_sensor_entity_id", "cost_sensor_entity_id", "flow_type"),
[
("sensor.energy_consumption", "sensor.energy_consumption_cost", "flow_from"),
(
Expand Down Expand Up @@ -342,10 +342,10 @@ def _compile_statistics(_):
("initial_energy", "initial_cost"), [(0, "0.0"), (None, "unknown")]
)
@pytest.mark.parametrize(
"price_entity,fixed_price", [("sensor.energy_price", None), (None, 1)]
("price_entity", "fixed_price"), [("sensor.energy_price", None), (None, 1)]
)
@pytest.mark.parametrize(
"usage_sensor_entity_id,cost_sensor_entity_id,flow_type",
("usage_sensor_entity_id", "cost_sensor_entity_id", "flow_type"),
[
("sensor.energy_consumption", "sensor.energy_consumption_cost", "flow_from"),
(
Expand Down Expand Up @@ -550,10 +550,10 @@ def _compile_statistics(_):
("initial_energy", "initial_cost"), [(0, "0.0"), (None, "unknown")]
)
@pytest.mark.parametrize(
"price_entity,fixed_price", [("sensor.energy_price", None), (None, 1)]
("price_entity", "fixed_price"), [("sensor.energy_price", None), (None, 1)]
)
@pytest.mark.parametrize(
"usage_sensor_entity_id,cost_sensor_entity_id,flow_type",
("usage_sensor_entity_id", "cost_sensor_entity_id", "flow_type"),
[
("sensor.energy_consumption", "sensor.energy_consumption_cost", "flow_from"),
(
Expand Down
4 changes: 2 additions & 2 deletions tests/components/group/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ async def test_config_flow(
("hide_members", "hidden_by"), ((False, None), (True, "integration"))
)
@pytest.mark.parametrize(
"group_type,extra_input",
("group_type", "extra_input"),
(
("binary_sensor", {"all": False}),
("cover", {}),
Expand Down Expand Up @@ -371,7 +371,7 @@ async def test_all_options(
),
)
@pytest.mark.parametrize(
"group_type,extra_input",
("group_type", "extra_input"),
(
("binary_sensor", {"all": False}),
("cover", {}),
Expand Down
2 changes: 1 addition & 1 deletion tests/components/group/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ async def test_setup_and_remove_config_entry(
),
)
@pytest.mark.parametrize(
"group_type,extra_options",
("group_type", "extra_options"),
(
("binary_sensor", {"all": False}),
("cover", {}),
Expand Down
2 changes: 1 addition & 1 deletion tests/components/hdmi_cec/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ async def test_service_update_devices(hass: HomeAssistant, create_hdmi_network)
),
],
)
@pytest.mark.parametrize("direction,key", [("up", 65), ("down", 66)])
@pytest.mark.parametrize(("direction", "key"), [("up", 65), ("down", 66)])
async def test_service_volume_x_times(
hass: HomeAssistant, create_hdmi_network, count, calls, direction, key
) -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/components/jewish_calendar/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ async def test_jewish_calendar_sensor(

@pytest.mark.parametrize("language", ["english", "hebrew"])
@pytest.mark.parametrize(
[
(
"now",
"candle_lighting",
"havdalah",
Expand All @@ -490,7 +490,7 @@ async def test_jewish_calendar_sensor(
"latitude",
"longitude",
"result",
],
),
SHABBAT_PARAMS,
ids=SHABBAT_TEST_IDS,
)
Expand Down
6 changes: 3 additions & 3 deletions tests/components/modbus/test_binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ async def test_config_binary_sensor(hass: HomeAssistant, mock_modbus) -> None:
],
)
@pytest.mark.parametrize(
"register_words,do_exception,expected",
("register_words", "do_exception", "expected"),
[
(
[True] * 8,
Expand Down Expand Up @@ -188,7 +188,7 @@ async def test_all_binary_sensor(hass: HomeAssistant, expected, mock_do_cycle) -
],
)
@pytest.mark.parametrize(
"register_words,do_exception,start_expect,end_expect",
("register_words", "do_exception", "start_expect", "end_expect"),
[
(
[False * 16],
Expand Down Expand Up @@ -347,7 +347,7 @@ async def test_config_slave_binary_sensor(hass: HomeAssistant, mock_modbus) -> N
],
)
@pytest.mark.parametrize(
"config_addon,register_words,expected, slaves",
("config_addon", "register_words", "expected", "slaves"),
[
(
{CONF_SLAVE_COUNT: 1, CONF_UNIQUE_ID: SLAVE_UNIQUE_ID},
Expand Down
6 changes: 3 additions & 3 deletions tests/components/modbus/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async def test_config_hvac_onoff_register(hass: HomeAssistant, mock_modbus) -> N
],
)
@pytest.mark.parametrize(
"register_words,expected",
("register_words", "expected"),
[
(
[0x00, 0x00],
Expand Down Expand Up @@ -485,7 +485,7 @@ async def test_restore_state_climate(
],
)
@pytest.mark.parametrize(
"register_words,do_exception,start_expect,end_expect",
("register_words", "do_exception", "start_expect", "end_expect"),
[
(
[0x8000],
Expand Down Expand Up @@ -525,7 +525,7 @@ async def test_lazy_error_climate(
],
)
@pytest.mark.parametrize(
"config_addon,register_words",
("config_addon", "register_words"),
[
(
{
Expand Down
6 changes: 3 additions & 3 deletions tests/components/modbus/test_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async def test_config_cover(hass: HomeAssistant, mock_modbus) -> None:
],
)
@pytest.mark.parametrize(
"register_words,expected",
("register_words", "expected"),
[
(
[0x00],
Expand Down Expand Up @@ -131,7 +131,7 @@ async def test_coil_cover(hass: HomeAssistant, expected, mock_do_cycle) -> None:
],
)
@pytest.mark.parametrize(
"register_words,do_exception, start_expect,end_expect",
("register_words", "do_exception", "start_expect", "end_expect"),
[
(
[0x00],
Expand Down Expand Up @@ -168,7 +168,7 @@ async def test_lazy_error_cover(
],
)
@pytest.mark.parametrize(
"register_words,expected",
("register_words", "expected"),
[
(
[0x00],
Expand Down
2 changes: 1 addition & 1 deletion tests/components/modbus/test_fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ async def test_config_fan(hass: HomeAssistant, mock_modbus) -> None:
],
)
@pytest.mark.parametrize(
"register_words,do_exception,config_addon,expected",
("register_words", "do_exception", "config_addon", "expected"),
[
(
[0x00],
Expand Down
2 changes: 1 addition & 1 deletion tests/components/modbus/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ async def mock_modbus_read_pymodbus_fixture(
],
)
@pytest.mark.parametrize(
"do_return,do_exception,do_expect_state,do_expect_value",
("do_return", "do_exception", "do_expect_state", "do_expect_value"),
[
[ReadResult([1]), None, STATE_ON, "1"],
[IllegalFunctionRequest(0x99), None, STATE_UNAVAILABLE, STATE_UNAVAILABLE],
Expand Down
2 changes: 1 addition & 1 deletion tests/components/modbus/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ async def test_config_light(hass: HomeAssistant, mock_modbus) -> None:
],
)
@pytest.mark.parametrize(
"register_words,do_exception,config_addon,expected",
("register_words", "do_exception", "config_addon", "expected"),
[
(
[0x00],
Expand Down
14 changes: 7 additions & 7 deletions tests/components/modbus/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async def test_config_sensor(hass: HomeAssistant, mock_modbus) -> None:

@pytest.mark.parametrize("check_config_loaded", [False])
@pytest.mark.parametrize(
"do_config,error_message",
("do_config", "error_message"),
[
(
{
Expand Down Expand Up @@ -270,7 +270,7 @@ async def test_config_wrong_struct_sensor(
],
)
@pytest.mark.parametrize(
"config_addon,register_words,do_exception,expected",
("config_addon", "register_words", "do_exception", "expected"),
[
(
{
Expand Down Expand Up @@ -612,7 +612,7 @@ async def test_all_sensor(hass: HomeAssistant, mock_do_cycle, expected) -> None:
],
)
@pytest.mark.parametrize(
"config_addon,register_words,do_exception,expected",
("config_addon", "register_words", "do_exception", "expected"),
[
(
{
Expand Down Expand Up @@ -703,7 +703,7 @@ async def test_slave_sensor(hass: HomeAssistant, mock_do_cycle, expected) -> Non
],
)
@pytest.mark.parametrize(
"config_addon,register_words",
("config_addon", "register_words"),
[
(
{
Expand Down Expand Up @@ -740,7 +740,7 @@ async def test_wrong_unpack(hass: HomeAssistant, mock_do_cycle) -> None:
],
)
@pytest.mark.parametrize(
"register_words,do_exception,start_expect,end_expect",
("register_words", "do_exception", "start_expect", "end_expect"),
[
(
[0x8000],
Expand Down Expand Up @@ -779,7 +779,7 @@ async def test_lazy_error_sensor(
],
)
@pytest.mark.parametrize(
"config_addon,register_words,expected",
("config_addon", "register_words", "expected"),
[
(
{
Expand Down Expand Up @@ -833,7 +833,7 @@ async def test_struct_sensor(hass: HomeAssistant, mock_do_cycle, expected) -> No
],
)
@pytest.mark.parametrize(
"config_addon,register_words,expected",
("config_addon", "register_words", "expected"),
[
(
{
Expand Down
4 changes: 2 additions & 2 deletions tests/components/modbus/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ async def test_config_switch(hass: HomeAssistant, mock_modbus) -> None:
],
)
@pytest.mark.parametrize(
"register_words,do_exception,config_addon,expected",
("register_words", "do_exception", "config_addon", "expected"),
[
(
[0x00],
Expand Down Expand Up @@ -226,7 +226,7 @@ async def test_all_switch(hass: HomeAssistant, mock_do_cycle, expected) -> None:
],
)
@pytest.mark.parametrize(
"register_words,do_exception,start_expect,end_expect",
("register_words", "do_exception", "start_expect", "end_expect"),
[
(
[0x00],
Expand Down
2 changes: 1 addition & 1 deletion tests/components/nanoleaf/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
],
)
@pytest.mark.parametrize(
"nanoleaf_conf_file, remove_config",
("nanoleaf_conf_file", "remove_config"),
[
({TEST_DEVICE_ID: {"token": TEST_TOKEN}}, True),
({TEST_HOST: {"token": TEST_TOKEN}}, True),
Expand Down
2 changes: 1 addition & 1 deletion tests/components/purpleair/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
],
)
@pytest.mark.parametrize(
"get_nearby_sensors_mock,get_nearby_sensors_errors",
("get_nearby_sensors_mock", "get_nearby_sensors_errors"),
[
(AsyncMock(return_value=[]), {"base": "no_sensors_near_coordinates"}),
(AsyncMock(side_effect=Exception), {"base": "unknown"}),
Expand Down
Loading

0 comments on commit d3ed8de

Please sign in to comment.