Skip to content

Commit 248cd9e

Browse files
committed
chore: fix ruff
1 parent 83f76e7 commit 248cd9e

File tree

7 files changed

+702
-1330
lines changed

7 files changed

+702
-1330
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ jobs:
4545
uses: astral-sh/setup-uv@v7
4646
with:
4747
python-version: ${{ matrix.python-version }}
48-
- name: Install Dependencies
49-
run: uv pip sync --all-extras
50-
shell: bash
48+
activate-environment: true
49+
5150
- name: Test with Pytest
52-
run: pytest --log-cli-level=DEBUG -vv -s
51+
run: uv run --frozen pytest --log-cli-level=DEBUG -vv -s
5352
shell: bash
5453
release:
5554
runs-on: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ repos:
2727
hooks:
2828
- id: codespell
2929
- repo: https://github.com/charliermarsh/ruff-pre-commit
30-
rev: v0.1.8
30+
rev: v0.14.0
3131
hooks:
3232
- id: ruff-format
3333
- id: ruff

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dev = [
4545
"pytest",
4646
"pre-commit>=3.5,<5.0",
4747
"mypy",
48-
"ruff",
48+
"ruff==0.14.0",
4949
"codespell",
5050
"pyshark>=0.6,<0.7",
5151
"aioresponses>=0.7.7,<0.8",
@@ -81,9 +81,9 @@ allowed_tags = [
8181
major_tags= ["refactor"]
8282

8383
[tool.ruff]
84-
ignore = ["F403", "E741"]
84+
lint.ignore = ["F403", "E741"]
8585
line-length = 120
86-
select=["E", "F", "UP", "I"]
86+
lint.select=["E", "F", "UP", "I"]
8787

8888
[tool.ruff.lint.per-file-ignores]
8989
"*/__init__.py" = ["F401"]

roborock/containers.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import re
66
import types
77
from dataclasses import asdict, dataclass, field
8-
from datetime import timezone
98
from enum import Enum
109
from functools import cached_property
1110
from typing import Any, NamedTuple, get_args, get_origin
@@ -717,11 +716,11 @@ def square_meter_area(self) -> float | None:
717716

718717
@property
719718
def begin_datetime(self) -> datetime.datetime | None:
720-
return datetime.datetime.fromtimestamp(self.begin).astimezone(timezone.utc) if self.begin else None
719+
return datetime.datetime.fromtimestamp(self.begin).astimezone(datetime.UTC) if self.begin else None
721720

722721
@property
723722
def end_datetime(self) -> datetime.datetime | None:
724-
return datetime.datetime.fromtimestamp(self.end).astimezone(timezone.utc) if self.end else None
723+
return datetime.datetime.fromtimestamp(self.end).astimezone(datetime.UTC) if self.end else None
725724

726725
def __repr__(self) -> str:
727726
return _attr_repr(self)

roborock/devices/v1_channel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
This module provides a unified channel interface for V1 protocol devices,
44
handling both MQTT and local connections with automatic fallback.
55
"""
6+
67
import asyncio
78
import datetime
89
import logging
@@ -182,7 +183,7 @@ async def _get_networking_info(self, *, use_cache: bool = True) -> NetworkInfo:
182183
except RoborockException as e:
183184
raise RoborockException(f"Network info failed for device {self._device_uid}") from e
184185
_LOGGER.debug("Network info for device %s: %s", self._device_uid, network_info)
185-
self._last_network_info_refresh = datetime.datetime.now(datetime.timezone.utc)
186+
self._last_network_info_refresh = datetime.datetime.now(datetime.UTC)
186187
cache_data.network_info[self._device_uid] = network_info
187188
await self._cache.set(cache_data)
188189
return network_info
@@ -252,8 +253,7 @@ def _should_use_cache(self, local_connect_failures: int) -> bool:
252253
if local_connect_failures == 1:
253254
return False
254255
elif self._last_network_info_refresh and (
255-
datetime.datetime.now(datetime.timezone.utc) - self._last_network_info_refresh
256-
> NETWORK_INFO_REFRESH_INTERVAL
256+
datetime.datetime.now(datetime.UTC) - self._last_network_info_refresh > NETWORK_INFO_REFRESH_INTERVAL
257257
):
258258
return False
259259
return True

roborock/protocols/v1_protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def decode_rpc_response(message: RoborockMessage) -> ResponseMessage:
157157
elif result != "ok":
158158
exc = RoborockException(f"Unexpected API Result: {result}")
159159
result = {}
160-
if not isinstance(result, (dict, list, int)):
160+
if not isinstance(result, dict | list | int):
161161
raise RoborockException(
162162
f"Invalid V1 message format: 'result' was unexpected type {type(result)}. {message.payload!r}"
163163
)

0 commit comments

Comments
 (0)