Skip to content

Commit

Permalink
Update ruff rules
Browse files Browse the repository at this point in the history
  • Loading branch information
SukramJ committed Mar 21, 2024
1 parent 55668ea commit 76bd51e
Show file tree
Hide file tree
Showing 20 changed files with 98 additions and 89 deletions.
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,14 @@ line-length = 99

lint.select = [
"B002", # Python does not support the unary prefix increment
"B005", # Using .strip() with multi-character strings is misleading
"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 =)?
"B904", # Use raise from to specify exception cause
"C", # complexity
"COM818", # Trailing comma on bare tuple prohibited
Expand All @@ -425,6 +429,7 @@ lint.select = [
"G", # flake8-logging-format
"I", # isort
"ICN001", # import concentions; {name} should be imported as {asname}
"LOG", # flake8-logging
"N804", # First argument of a class method should be named cls
"N805", # First argument of a method should be named self
"N815", # Variable {name} in class scope should not be mixedCase
Expand All @@ -435,7 +440,9 @@ lint.select = [
"PLE", # pylint
"PLR", # pylint
"PLW", # pylint
"PT", # flake8-pytest-style
"Q000", # Double quotes found but single quotes preferred
"RSE", # flake8-raise
"RUF006", # Store a reference to the return value of asyncio.create_task
"S102", # Use of exec detected
"S103", # bad-file-permissions
Expand Down Expand Up @@ -488,6 +495,8 @@ lint.ignore = [
"PLR0911", # Too many return statements ({returns} > {max_returns})
"PLR0912", # Too many branches ({branches} > {max_branches})
"PLR0913", # Too many arguments to function call ({c_args} > {max_args})
"PT004", # Fixture {fixture} does not return anything, add leading underscore
"PT011", # pytest.raises({exception}) is too broad, set the `match` parameter or use a more specific exception
"PLR0915", # Too many statements ({statements} > {max_statements})
"PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
"PLW2901", # Outer {outer_kind} variable {name} overwritten by inner {inner_kind} target
Expand Down
2 changes: 1 addition & 1 deletion tests/test_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# pylint: disable=protected-access


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_hmaction(factory: helper.Factory) -> None:
"""Test HmAction."""
central, mock_client = await factory.get_default_central(TEST_DEVICES)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# pylint: disable=protected-access


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_hmbinarysensor(factory: helper.Factory) -> None:
"""Test HmBinarySensor."""
central, mock_client = await factory.get_default_central(TEST_DEVICES)
Expand All @@ -43,7 +43,7 @@ async def test_hmbinarysensor(factory: helper.Factory) -> None:
assert call_count == len(mock_client.method_calls)


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_hmsysvarbinarysensor(factory: helper.Factory) -> None:
"""Test HmSysvarBinarySensor."""
central, _ = await factory.get_default_central({}, add_sysvars=True)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# pylint: disable=protected-access


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_hmbutton(factory: helper.Factory) -> None:
"""Test HmButton."""
central, mock_client = await factory.get_default_central(TEST_DEVICES)
Expand All @@ -47,7 +47,7 @@ async def test_hmbutton(factory: helper.Factory) -> None:
assert (call_count + 1) == len(mock_client.method_calls)


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_hmprogrambutton(factory: helper.Factory) -> None:
"""Test HmProgramButton."""
central, mock_client = await factory.get_default_central({}, add_programs=True)
Expand Down
50 changes: 25 additions & 25 deletions tests/test_central.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# pylint: disable=protected-access


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_central_basics(factory: helper.Factory) -> None:
"""Test central basics."""
central, client = await factory.get_default_central(TEST_DEVICES)
Expand All @@ -47,7 +47,7 @@ async def test_central_basics(factory: helper.Factory) -> None:
assert entities


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_device_get_entities(factory: helper.Factory) -> None:
"""Test central/device get_entities."""
central, _ = await factory.get_default_central(
Expand All @@ -60,15 +60,15 @@ async def test_device_get_entities(factory: helper.Factory) -> None:
assert entities_reg == ()


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_device_export(factory: helper.Factory) -> None:
"""Test device export."""
central, _ = await factory.get_default_central(TEST_DEVICES)
device = central.get_device(address="VCU6354483")
await device.export_device_definition()


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_identify_callback_ip(factory: helper.Factory) -> None:
"""Test identify_callback_ip."""
central, _ = await factory.get_default_central(TEST_DEVICES)
Expand Down Expand Up @@ -98,7 +98,7 @@ async def test_identify_callback_ip(factory: helper.Factory) -> None:
("LEVEL:VALUES@all::1", "LEVEL", 1, "VALUES", False),
],
)
@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_device_unignore_etrv(
factory: helper.Factory,
line: str,
Expand Down Expand Up @@ -136,7 +136,7 @@ async def test_device_unignore_etrv(
("LEVEL:VALUES@HmIP-BROLL:all", "LEVEL", 3, "VALUES", True),
],
)
@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_device_unignore_broll(
factory: helper.Factory,
line: str,
Expand Down Expand Up @@ -197,7 +197,7 @@ async def test_device_unignore_broll(
),
],
)
@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_device_unignore_hm(
factory: helper.Factory,
line: str,
Expand Down Expand Up @@ -281,7 +281,7 @@ async def test_device_unignore_hm(
),
],
)
@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_device_unignore_hm2(
factory: helper.Factory,
lines: list[str],
Expand Down Expand Up @@ -335,7 +335,7 @@ async def test_device_unignore_hm2(
),
],
)
@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_ignore_deviec_type(
factory: helper.Factory,
lines: list[str],
Expand All @@ -359,7 +359,7 @@ async def test_ignore_deviec_type(
assert len(device.custom_entities) > 0


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_all_parameters(factory: helper.Factory) -> None:
"""Test all_parameters."""
central, _ = await factory.get_default_central(TEST_DEVICES)
Expand All @@ -368,7 +368,7 @@ async def test_all_parameters(factory: helper.Factory) -> None:
assert len(parameters) == 43


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_entities_by_platform(factory: helper.Factory) -> None:
"""Test entities_by_platform."""
central, _ = await factory.get_default_central(TEST_DEVICES)
Expand All @@ -385,7 +385,7 @@ def _device_changed(self, *args: Any, **kwargs: Any) -> None:
assert len(ebp_sensor2) == 11


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_hub_entities_by_platform(factory: helper.Factory) -> None:
"""Test hub_entities_by_platform."""
central, _ = await factory.get_default_central({}, add_programs=True, add_sysvars=True)
Expand Down Expand Up @@ -413,7 +413,7 @@ def _device_changed(self, *args: Any, **kwargs: Any) -> None:
assert len(ebp_sensor4) == 1


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_add_device(factory: helper.Factory) -> None:
"""Test add_device."""
central, _ = await factory.get_default_central(
Expand All @@ -437,7 +437,7 @@ async def test_add_device(factory: helper.Factory) -> None:
assert len(central._devices) == 2


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_delete_device(factory: helper.Factory) -> None:
"""Test device delete_device."""
central, _ = await factory.get_default_central(TEST_DEVICES)
Expand All @@ -457,7 +457,7 @@ async def test_delete_device(factory: helper.Factory) -> None:
)


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_virtual_remote_delete(factory: helper.Factory) -> None:
"""Test device delete."""
central, _ = await factory.get_default_central(
Expand Down Expand Up @@ -488,7 +488,7 @@ async def test_virtual_remote_delete(factory: helper.Factory) -> None:
await central.delete_device(interface_id=const.INTERFACE_ID, device_address="NOT_A_DEVICE_ID")


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_central_not_alive(factory: helper.Factory) -> None:
"""Test central other methods."""
central, client = await factory.get_unpatched_default_central({}, do_mock_client=False)
Expand All @@ -506,7 +506,7 @@ async def test_central_not_alive(factory: helper.Factory) -> None:
assert central.is_alive is False


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_central_callbacks(factory: helper.Factory) -> None:
"""Test central other methods."""
central, _ = await factory.get_default_central(TEST_DEVICES)
Expand All @@ -525,7 +525,7 @@ async def test_central_callbacks(factory: helper.Factory) -> None:
)


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_central_services(factory: helper.Factory) -> None:
"""Test central fetch sysvar and programs."""
central, mock_client = await factory.get_default_central(
Expand Down Expand Up @@ -610,7 +610,7 @@ async def test_central_services(factory: helper.Factory) -> None:
assert central.get_generic_entity(channel_address="VCU6354483", parameter="DUTY_CYCLE") is None


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_central_direct(factory: helper.Factory) -> None:
"""Test central other methods."""
central, client = await factory.get_unpatched_default_central(
Expand All @@ -632,7 +632,7 @@ async def test_central_direct(factory: helper.Factory) -> None:
await central.stop()


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_central_without_interface_config(factory: helper.Factory) -> None:
"""Test central other methods."""
central = await factory.get_raw_central(interface_config=None)
Expand Down Expand Up @@ -661,7 +661,7 @@ async def test_central_without_interface_config(factory: helper.Factory) -> None
await central.stop()


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_ping_pong(factory: helper.Factory) -> None:
"""Test central other methods."""
central, client = await factory.get_default_central(TEST_DEVICES, do_mock_client=False)
Expand All @@ -678,7 +678,7 @@ async def test_ping_pong(factory: helper.Factory) -> None:
assert client.ping_pong_cache.pending_pong_count == 0


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_pending_pong_failure(factory: helper.Factory) -> None:
"""Test central other methods."""
central, client = await factory.get_default_central(TEST_DEVICES, do_mock_client=False)
Expand All @@ -702,7 +702,7 @@ async def test_pending_pong_failure(factory: helper.Factory) -> None:
assert len(factory.ha_event_mock.mock_calls) == 9


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_unknown_pong_failure(factory: helper.Factory) -> None:
"""Test central other methods."""
central, client = await factory.get_default_central(TEST_DEVICES, do_mock_client=False)
Expand All @@ -721,7 +721,7 @@ async def test_unknown_pong_failure(factory: helper.Factory) -> None:
assert client.ping_pong_cache.unknown_pong_count == 16


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_central_caches(factory: helper.Factory) -> None:
"""Test central cache."""
central, client = await factory.get_default_central(TEST_DEVICES)
Expand All @@ -734,7 +734,7 @@ async def test_central_caches(factory: helper.Factory) -> None:
)


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_central_getter(factory: helper.Factory) -> None:
"""Test central getter."""
central, _ = await factory.get_default_central(TEST_DEVICES)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_central_pydevccu.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# pylint: disable=protected-access


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_central_mini(central_unit_mini) -> None:
"""Test the central."""
assert central_unit_mini
Expand All @@ -31,7 +31,7 @@ async def test_central_mini(central_unit_mini) -> None:
assert len(central_unit_mini.get_entities(exclude_no_create=False)) == 29


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_central_full(central_unit_full) -> None:
"""Test the central."""
assert central_unit_full
Expand Down
6 changes: 3 additions & 3 deletions tests/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
# pylint: disable=protected-access


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_cesimplerfthermostat(factory: helper.Factory) -> None:
"""Test CeSimpleRfThermostat."""
central, mock_client = await factory.get_default_central(TEST_DEVICES)
Expand Down Expand Up @@ -92,7 +92,7 @@ async def test_cesimplerfthermostat(factory: helper.Factory) -> None:
assert mock_client.method_calls[-1] == last_call


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_cerfthermostat(factory: helper.Factory) -> None:
"""Test CeRfThermostat."""
central, mock_client = await factory.get_default_central(TEST_DEVICES)
Expand Down Expand Up @@ -225,7 +225,7 @@ async def test_cerfthermostat(factory: helper.Factory) -> None:
)


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_ceipthermostat(factory: helper.Factory) -> None:
"""Test CeIpThermostat."""
central, mock_client = await factory.get_default_central(TEST_DEVICES)
Expand Down
Loading

0 comments on commit 76bd51e

Please sign in to comment.