Skip to content

Commit 3aa60b9

Browse files
committed
Enable ruff FURB, PERF, RSE, RET, PIE rules and fix violations
- Replace ternary with or operator (FURB110) - Use list comprehension instead of append loop (PERF401) - Remove unnecessary parentheses on raise (RSE102) - Remove explicit return None and unnecessary else after return (RET) - Remove unnecessary pass and dict spread (PIE)
1 parent efa3be4 commit 3aa60b9

File tree

6 files changed

+23
-18
lines changed

6 files changed

+23
-18
lines changed

pyoverkiz/auth/strategies.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def __init__(
6666

6767
async def login(self) -> None:
6868
"""Perform authentication; default is a no-op for subclasses to override."""
69-
return None
69+
return
7070

7171
async def refresh_if_needed(self) -> bool:
7272
"""Refresh authentication tokens if needed; default returns False."""
@@ -78,7 +78,7 @@ def auth_headers(self, path: str | None = None) -> Mapping[str, str]:
7878

7979
async def close(self) -> None:
8080
"""Close any resources held by the strategy; default is no-op."""
81-
return None
81+
return
8282

8383

8484
class SessionLoginStrategy(BaseAuthStrategy):
@@ -269,7 +269,7 @@ def _client() -> BaseClient:
269269
except ClientError as error:
270270
code = error.response.get("Error", {}).get("Code")
271271
if code in {"NotAuthorizedException", "UserNotFoundException"}:
272-
raise NexityBadCredentialsError() from error
272+
raise NexityBadCredentialsError from error
273273
raise
274274

275275
id_token = tokens["AuthenticationResult"]["IdToken"]

pyoverkiz/client.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,8 @@ def __init__(
180180
self.gateways: list[Gateway] = []
181181
self.event_listener_id: str | None = None
182182

183-
self.session = (
184-
session
185-
if session
186-
else ClientSession(headers={"User-Agent": "python-overkiz-api"})
183+
self.session = session or ClientSession(
184+
headers={"User-Agent": "python-overkiz-api"}
187185
)
188186
self._ssl = verify_ssl
189187

@@ -519,8 +517,7 @@ async def execute_action_group(
519517
if self._action_queue:
520518
queued = await self._action_queue.add(actions, mode, label)
521519
return await queued
522-
else:
523-
return await self._execute_action_group_direct(actions, mode, label)
520+
return await self._execute_action_group_direct(actions, mode, label)
524521

525522
async def flush_action_queue(self) -> None:
526523
"""Force flush all pending actions in the queue immediately.

pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ select = [
104104
"TRY",
105105
# flake8-quotes
106106
"Q",
107+
# refurb
108+
"FURB",
109+
# perflint
110+
"PERF",
111+
# flake8-raise
112+
"RSE",
113+
# flake8-return
114+
"RET",
115+
# flake8-pie
116+
"PIE",
107117
]
108118
ignore = [
109119
"E501", # Line too long

tests/test_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,6 @@ async def json(self, content_type=None):
745745

746746
async def __aexit__(self, exc_type, exc, tb):
747747
"""Context manager exit (noop)."""
748-
pass
749748

750749
async def __aenter__(self):
751750
"""Context manager enter returning self."""

tests/test_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def test_base_url_parsing(
218218
"""Ensure device URL parsing extracts protocol, gateway and address correctly."""
219219
test_device = {
220220
**RAW_DEVICES,
221-
**{"deviceURL": device_url},
221+
"deviceURL": device_url,
222222
}
223223
device_data = decamelize(test_device)
224224
device = Device(**device_data)
@@ -240,7 +240,7 @@ def test_invalid_device_url_raises(self, device_url: str):
240240
"""Invalid device URLs should raise during identifier parsing."""
241241
test_device = {
242242
**RAW_DEVICES,
243-
**{"deviceURL": device_url},
243+
"deviceURL": device_url,
244244
}
245245
device_data = decamelize(test_device)
246246

utils/generate_enums.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,11 @@ def clean_description(desc: str) -> str:
363363

364364
# Get parameter info
365365
if cmd.prototype and cmd.prototype.parameters:
366-
param_strs = []
367-
for param in cmd.prototype.parameters:
368-
if param.value_prototypes:
369-
param_strs.append(
370-
format_value_prototype(param.value_prototypes[0])
371-
)
366+
param_strs = [
367+
format_value_prototype(param.value_prototypes[0])
368+
for param in cmd.prototype.parameters
369+
if param.value_prototypes
370+
]
372371
param_info = (
373372
f"({', '.join(param_strs)})" if param_strs else "()"
374373
)

0 commit comments

Comments
 (0)