8000 Update ruff to 0.9 (#1482) · python-kasa/python-kasa@9b7bf36 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9b7bf36

Browse files
authored
Update ruff to 0.9 (#1482)
Ruff 0.9 contains a number of formatter changes for the 2025 style guide. Update to `ruff>=0.9.0` and apply the formatter fixes. https://astral.sh/blog/ruff-v0.9.0
1 parent 09fce3f commit 9b7bf36

16 files changed

+46
-55
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ repos:
2222
- "--indent=4"
2323

2424
- repo: https://github.com/astral-sh/ruff-pre-commit
25-
rev: v0.7.4
25+
rev: v0.9.3
2626
hooks:
2727
- id: ruff
2828
args: [--fix, --exit-non-zero-on-fix]

devtools/parse_pcap_klap.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,7 @@ def main(
286286
operator.local_seed = message
287287
response = None
288288
print(
289-
f"got handshake1 in {packet_number}, "
290-
f"looking for the response"
289+
f"got handshake1 in {packet_number}, looking for the response"
291290
)
292291
while (
293292
True

kasa/cli/hub.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ async def hub_pair(dev: SmartDevice, timeout: int):
6666

6767
for child in pair_res:
6868
echo(
69-
f'Paired {child["name"]} ({child["device_model"]}, '
70-
f'{pretty_category(child["category"])}) with id {child["device_id"]}'
69+
f"Paired {child['name']} ({child['device_model']}, "
70+
f"{pretty_category(child['category'])}) with id {child['device_id']}"
7171
)
7272

7373

kasa/cli/lazygroup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def _lazy_load(self, cmd_name):
6666
# check the result to make debugging easier
6767
if not isinstance(cmd_object, click.BaseCommand):
6868
raise ValueError(
69-
f"Lazy loading of {cmd_name} failed by returning "
70-
"a non-command object"
69+
f"Lazy loading of {cmd_name} failed by returning a non-command object"
7170
)
7271
return cmd_object

kasa/iot/iotdimmer.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ async def _set_brightness(
115115
raise KasaException("Device is not dimmable.")
116116

117117
if not isinstance(brightness, int):
118-
raise ValueError(
119-
"Brightness must be integer, " "not of %s.", type(brightness)
120-
)
118+
raise ValueError("Brightness must be integer, not of %s.", type(brightness))
121119

122120
if not 0 <= brightness <= 100:
123121
raise ValueError(

kasa/iot/modules/lightpreset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class LightPreset(IotModule, LightPresetInterface):
5454
async def _post_update_hook(self) -> None:
5555
"""Update the internal presets."""
5656
self._presets = {
57-
f"Light preset {index+1}": IotLightPreset.from_dict(vals)
57+
f"Light preset {index + 1}": IotLightPreset.from_dict(vals)
5858
for index, vals in enumerate(self.data["preferred_state"])
5959
# Devices may list some light effects along with normal presets but these
6060
# are handled by the LightEffect module so exclude preferred states with id

kasa/protocols/iotprotocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _mask_children(children: list[dict[str, Any]]) -> list[dict[str, Any]]:
3030
def mask_child(child: dict[str, Any], index: int) -> dict[str, Any]:
3131
result = {
3232
**child,
33-
"id": f"SCRUBBED_CHILD_DEVICE_ID_{index+1}",
33+
"id": f"SCRUBBED_CHILD_DEVICE_ID_{index + 1}",
3434
}
3535
# Will leave empty aliases as blank
3636
if child.get("alias"):

kasa/protocols/smartprotocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ async def _execute_multiple_query(
236236

237237
smart_params = {"requests": requests_step}
238238
smart_request = self.get_smart_request(smart_method, smart_params)
239-
batch_name = f"multi-request-batch-{batch_num+1}-of-{int(end/step)+1}"
239+
batch_name = f"multi-request-batch-{batch_num + 1}-of-{int(end / step) + 1}"
240240
if debug_enabled:
241241
_LOGGER.debug(
242242
"%s %s >> %s",

kasa/transports/xortransport.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,16 @@ async def send(self, request: str) -> dict:
142142
await self.reset()
143143
if ex.errno in _NO_RETRY_ERRORS:
144144
raise KasaException(
145-
f"Unable to connect to the device:"
146-
f" {self._host}:{self._port}: {ex}"
145+
f"Unable to connect to the device: {self._host}:{self._port}: {ex}"
147146
) from ex
148147
else:
149148
raise _RetryableError(
150-
f"Unable to connect to the device:"
151-
f" {self._host}:{self._port}: {ex}"
149+
f"Unable to connect to the device: {self._host}:{self._port}: {ex}"
152150
) from ex
153151
except Exception as ex:
154152
await self.reset()
155153
raise _RetryableError(
156-
f"Unable to connect to the device:" f" {self._host}:{self._port}: {ex}"
154+
f"Unable to connect to the device: {self._host}:{self._port}: {ex}"
157155
) from ex
158156
except BaseException:
159157
# Likely something cancelled the task so we need to close the connection

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ dev-dependencies = [
6161
"mypy~=1.0",
6262
"pytest-xdist>=3.6.1",
6363
"pytest-socket>=0.7.0",
64-
"ruff==0.7.4",
64+
"ruff>=0.9.0",
6565
]
6666

6767

@@ -146,8 +146,6 @@ select = [
146146
ignore = [
147147
"D105", # Missing docstring in magic method
148148
"D107", # Missing docstring in `__init__`
149-
"ANN101", # Missing type annotation for `self`
150-
"ANN102", # Missing type annotation for `cls` in classmethod
151149
"ANN003", # Missing type annotation for `**kwargs`
152150
"ANN401", # allow any
153151
]

tests/fakeprotocol_smartcam.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ def _hub_remove_device(self, info, params):
218218

219219
@staticmethod
220220
def _get_second_key(request_dict: dict[str, Any]) -> str:
221-
assert (
222-
len(request_dict) == 2
223-
), f"Unexpected dict {request_dict}, should be length 2"
221+
assert len(request_dict) == 2, (
222+
f"Unexpected dict {request_dict}, should be length 2"
223+
)
224224
it = iter(request_dict)
225225
next(it, None)
226226
return next(it)

tests/smart/test_smartdevice.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ async def test_update_module_update_delays(
223223
now if mod_delay == 0 else now - (seconds % mod_delay)
224224
)
225225

226-
assert (
227-
module._last_update_time == expected_update_time
228-
), f"Expected update time {expected_update_time} after {seconds} seconds for {module.name} with delay {mod_delay} got {module._last_update_time}"
226+
assert module._last_update_time == expected_update_time, (
227+
f"Expected update time {expected_update_time} after {seconds} seconds for {module.name} with delay {mod_delay} got {module._last_update_time}"
228+
)
229229

230230

231231
async def _get_child_responses(child_requests: list[dict[str, Any]], child_protocol):

tests/test_cli.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,7 @@ async def test_light_preset(dev: Device, runner: CliRunner):
653653

654654
if len(light_preset.preset_states_list) == 0:
655655
pytest.skip(
656-
"Some fixtures do not have presets and"
657-
" the api doesn'tsupport creating them"
656+
"Some fixtures do not have presets and the api doesn'tsupport creating them"
658657
)
659658
# Start off with a known state
660659
first_name = light_preset.preset_list[1]

tests/transports/test_aestransport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_encrypt():
5656

5757

5858
status_parameters = pytest.mark.parametrize(
59-
"status_code, error_code, inner_error_code, expectation",
59+
("status_code", "error_code", "inner_error_code", "expectation"),
6060
[
6161
(200, 0, 0, does_not_raise()),
6262
(400, 0, 0, pytest.raises(KasaException)),

tests/transports/test_sslaestransport.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ async def test_unencrypted_passthrough_errors(mocker, caplog, want_default):
273273
aiohttp.ClientSession, "post", side_effect=mock_ssl_aes_device.post
274274
)
275275

276-
msg = f"{host} responded with an unexpected " f"status code 401 to handshake1"
276+
msg = f"{host} responded with an unexpected status code 401 to handshake1"
277277
with pytest.raises(KasaException, match=msg):
278278
await transport.send(json_dumps(request))
279279

@@ -288,7 +288,7 @@ async def test_unencrypted_passthrough_errors(mocker, caplog, want_default):
288288
aiohttp.ClientSession, "post", side_effect=mock_ssl_aes_device.post
289289
)
290290

291-
msg = f"{host} responded with an unexpected " f"status code 401 to login"
291+
msg = f"{host} responded with an unexpected status code 401 to login"
292292
with pytest.raises(KasaException, match=msg):
293293
await transport.send(json_dumps(request))
294294

@@ -303,7 +303,7 @@ async def test_unencrypted_passthrough_errors(mocker, caplog, want_default):
303303
aiohttp.ClientSession, "post", side_effect=mock_ssl_aes_device.post
304304
)
305305

306-
msg = f"{host} responded with an unexpected " f"status code 401 to unencrypted send"
306+
msg = f"{host} responded with an unexpected status code 401 to unencrypted send"
307307
with pytest.raises(KasaException, match=msg):
308308
await transport.send(json_dumps(request))
309309

uv.lock

Lines changed: 22 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
0