FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Update ruff to 0.9 by sdb9696 · Pull Request #1482 · python-kasa/python-kasa · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .lock  (1) .py  (13) .toml  (1) .yaml  (1) All 4 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
- "--indent=4"

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.4
rev: v0.9.3
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
3 changes: 1 addition & 2 deletions devtools/parse_pcap_klap.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,7 @@ def main(
operator.local_seed = message
response = None
print(
f"got handshake1 in {packet_number}, "
f"looking for the response"
f"got handshake1 in {packet_number}, looking for the response"
)
while (
True
Expand Down
4 changes: 2 additions & 2 deletions kasa/cli/hub.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ async def hub_pair(dev: SmartDevice, timeout: int):

for child in pair_res:
echo(
f'Paired {child["name"]} ({child["device_model"]}, '
f'{pretty_category(child["category"])}) with id {child["device_id"]}'
f"Paired {child['name']} ({child['device_model']}, "
f"{pretty_category(child['category'])}) with id {child['device_id']}"
)


Expand Down
3 changes: 1 addition & 2 deletions kasa/cli/lazygroup.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def _lazy_load(self, cmd_name):
# check the result to make debugging easier
if not isinstance(cmd_object, click.BaseCommand):
raise ValueError(
f"Lazy loading of {cmd_name} failed by returning "
"a non-command object"
f"Lazy loading of {cmd_name} failed by returning a non-command object"
)
return cmd_object
4 changes: 1 addition & 3 deletions kasa/iot/iotdimmer.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ async def _set_brightness(
raise KasaException("Device is not dimmable.")

if not isinstance(brightness, int):
raise ValueError(
"Brightness must be integer, " "not of %s.", type(brightness)
)
raise ValueError("Brightness must be integer, not of %s.", type(brightness))

if not 0 <= brightness <= 100:
raise ValueError(
Expand Down
2 changes: 1 addition & 1 deletion kasa/iot/modules/lightpreset.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class LightPreset(IotModule, LightPresetInterface):
async def _post_update_hook(self) -> None:
"""Update the internal presets."""
self._presets = {
f"Light preset {index+1}": IotLightPreset.from_dict(vals)
f"Light preset {index + 1}": IotLightPreset.from_dict(vals)
for index, vals in enumerate(self.data["preferred_state"])
# Devices may list some light effects along with normal presets but these
# are handled by the LightEffect module so exclude preferred states with id
Expand Down
2 changes: 1 addition & 1 deletion kasa/protocols/iotprotocol.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _mask_children(children: list[dict[str, Any]]) -> list[dict[str, Any]]:
def mask_child(child: dict[str, Any], index: int) -> dict[str, Any]:
result = {
**child,
"id": f"SCRUBBED_CHILD_DEVICE_ID_{index+1}",
"id": f"SCRUBBED_CHILD_DEVICE_ID_{index + 1}",
}
# Will leave empty aliases as blank
if child.get("alias"):
Expand Down
2 changes: 1 addition & 1 deletion kasa/protocols/smartprotocol.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ async def _execute_multiple_query(

smart_params = {"requests": requests_step}
smart_request = self.get_smart_request(smart_method, smart_params)
batch_name = f"multi-request-batch-{batch_num+1}-of-{int(end/step)+1}"
batch_name = f"multi-request-batch-{batch_num + 1}-of-{int(end / step) + 1}"
if debug_enabled:
_LOGGER.debug(
"%s %s >> %s",
Expand Down
8 changes: 3 additions & 5 deletions kasa/transports/xortransport.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,16 @@ async def send(self, request: str) -> dict:
await self.reset()
if ex.errno in _NO_RETRY_ERRORS:
raise KasaException(
f"Unable to connect to the device:"
f" {self._host}:{self._port}: {ex}"
f"Unable to connect to the device: {self._host}:{self._port}: {ex}"
) from ex
else:
raise _RetryableError(
f"Unable to connect to the device:"
f" {self._host}:{self._port}: {ex}"
f"Unable to connect to the device: {self._host}:{self._port}: {ex}"
) from ex
except Exception as ex:
await self.reset()
raise _RetryableError(
f"Unable to connect to the device:" f" {self._host}:{self._port}: {ex}"
f"Unable to connect to the device: {self._host}:{self._port}: {ex}"
) from ex
except BaseException:
# Likely something cancelled the task so we need to close the connection
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dev-dependencies = [
"mypy~=1.0",
"pytest-xdist>=3.6.1",
"pytest-socket>=0.7.0",
"ruff==0.7.4",
"ruff>=0.9.0",
]


Expand Down Expand Up @@ -146,8 +146,6 @@ select = [
ignore = [
"D105", # Missing docstring in magic method
"D107", # Missing docstring in `__init__`
"ANN101", # Missing type annotation for `self`
"ANN102", # Missing type annotation for `cls` in classmethod
Comment on lines -149 to -150

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

No longer required as removed from ruff in 0.8.

"ANN003", # Missing type annotation for `**kwargs`
"ANN401", # allow any
]
Expand Down
6 changes: 3 additions & 3 deletions tests/fakeprotocol_smartcam.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ def _hub_remove_device(self, info, params):

@staticmethod
def _get_second_key(request_dict: dict[str, Any]) -> str:
assert (
len(request_dict) == 2
), f"Unexpected dict {request_dict}, should be length 2"
assert len(request_dict) == 2, (
f"Unexpected dict {request_dict}, should be length 2"
)
it = iter(request_dict)
next(it, None)
return next(it)
Expand Down
6 changes: 3 additions & 3 deletions tests/smart/test_smartdevice.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ async def test_update_module_update_delays(
now if mod_delay == 0 else now - (seconds % mod_delay)
)

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


async def _get_child_responses(child_requests: list[dict[str, Any]], child_protocol):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_cli.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,7 @@ async def test_light_preset(dev: Device, runner: CliRunner):

if len(light_preset.preset_states_list) == 0:
pytest.skip(
"Some fixtures do not have presets and"
" the api doesn'tsupport creating them"
"Some fixtures do not have presets and the api doesn'tsupport creating them"
)
# Start off with a known state
first_name = light_preset.preset_list[1]
Expand Down
2 changes: 1 addition & 1 deletion tests/transports/test_aestransport.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_encrypt():


status_parameters = pytest.mark.parametrize(
"status_code, error_code, inner_error_code, expectation",
("status_code", "error_code", "inner_error_code", "expectation"),
[
(200, 0, 0, does_not_raise()),
(400, 0, 0, pytest.raises(KasaException)),
Expand Down
6 changes: 3 additions & 3 deletions tests/transports/test_sslaestransport.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ async def test_unencrypted_passthrough_errors(mocker, caplog, want_default):
aiohttp.ClientSession, "post", side_effect=mock_ssl_aes_device.post
)

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

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

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

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

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

Expand Down
44 changes: 22 additions & 22 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.


Back | FazBrowse Home | New Git URL