Skip to content

Commit a966be1

Browse files
committed
Fix post-rebase lint and formatting issues
1 parent 19d71b1 commit a966be1

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

sagemcom_api/action_error_exception_handler.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
"""Logic to spot and create ActionErrorExceptions"""
1+
"""Logic to spot and create ActionErrorExceptions."""
22

33
from sagemcom_api.const import (
44
XMO_ACCESS_RESTRICTION_ERR,
55
XMO_AUTHENTICATION_ERR,
66
XMO_LOGIN_RETRY_ERR,
77
XMO_MAX_SESSION_COUNT_ERR,
8-
XMO_NON_WRITABLE_PARAMETER_ERR,
98
XMO_NO_ERR,
9+
XMO_NON_WRITABLE_PARAMETER_ERR,
1010
XMO_REQUEST_ACTION_ERR,
11-
XMO_UNKNOWN_PATH_ERR
11+
XMO_UNKNOWN_PATH_ERR,
1212
)
1313
from sagemcom_api.exceptions import (
1414
AccessRestrictionException,
@@ -17,32 +17,30 @@
1717
MaximumSessionCountException,
1818
NonWritableParameterException,
1919
UnknownException,
20-
UnknownPathException
20+
UnknownPathException,
2121
)
2222

2323

2424
class ActionErrorHandler:
25-
"""Raised when a requested action has an error"""
25+
"""Raised when a requested action has an error."""
2626

2727
KNOWN_EXCEPTIONS = (
2828
XMO_AUTHENTICATION_ERR,
2929
XMO_ACCESS_RESTRICTION_ERR,
3030
XMO_NON_WRITABLE_PARAMETER_ERR,
3131
XMO_UNKNOWN_PATH_ERR,
3232
XMO_MAX_SESSION_COUNT_ERR,
33-
XMO_LOGIN_RETRY_ERR
33+
XMO_LOGIN_RETRY_ERR,
3434
)
3535

3636
@staticmethod
3737
def throw_if(response):
38-
"""For anywhere that needs the old single-exception behaviour"""
39-
38+
"""For anywhere that needs the old single-exception behaviour."""
4039
if response["reply"]["error"]["description"] != XMO_REQUEST_ACTION_ERR:
4140
return
4241

4342
actions = response["reply"]["actions"]
4443
for action in actions:
45-
4644
action_error = action["error"]
4745
action_error_desc = action_error["description"]
4846

@@ -53,17 +51,12 @@ def throw_if(response):
5351

5452
@staticmethod
5553
def is_unknown_exception(desc):
56-
"""
57-
True/false if the ActionError is one of our known types
58-
"""
59-
54+
"""True/false if the ActionError is one of our known types."""
6055
return False if desc == XMO_NO_ERR else desc not in ActionErrorHandler.KNOWN_EXCEPTIONS
6156

6257
@staticmethod
6358
def from_error_description(action_error, action_error_desc):
64-
"""
65-
Create the correct exception from an error, for the caller to throw
66-
"""
59+
"""Create the correct exception from an error, for the caller to throw."""
6760
# pylint: disable=too-many-return-statements
6861

6962
if action_error_desc == XMO_AUTHENTICATION_ERR:

sagemcom_api/client.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from __future__ import annotations
44

5-
import asyncio
65
import hashlib
76
import json
87
import math
@@ -22,8 +21,8 @@
2221
ServerDisconnectedError,
2322
TCPConnector,
2423
)
25-
from .action_error_exception_handler import ActionErrorHandler
2624

25+
from .action_error_exception_handler import ActionErrorHandler
2726
from .const import (
2827
API_ENDPOINT,
2928
DEFAULT_TIMEOUT,
@@ -310,7 +309,7 @@ async def login(self):
310309
response = await self.__api_request_async([actions], True)
311310
ActionErrorHandler.throw_if(response)
312311

313-
except asyncio.TimeoutError as exception:
312+
except TimeoutError as exception:
314313
raise LoginTimeoutException(
315314
"Login request timed-out. This could be caused by using the wrong encryption method, or using a (non) SSL connection."
316315
) from exception
@@ -369,7 +368,6 @@ async def get_encryption_method(self):
369368
max_tries=1,
370369
on_backoff=retry_login,
371370
)
372-
async def get_value_by_xpath(self, xpath: str, options: dict | None = None) -> dict:
373371
async def get_value_by_xpath(
374372
self,
375373
xpath: str,
@@ -407,7 +405,6 @@ async def get_value_by_xpath(
407405
max_tries=1,
408406
on_backoff=retry_login,
409407
)
410-
async def get_values_by_xpaths(self, xpaths, options: dict | None = None) -> dict:
411408
async def get_values_by_xpaths(
412409
self,
413410
xpaths,
@@ -496,7 +493,7 @@ async def get_device_info(self) -> DeviceInfo:
496493
"software_version": "Device/DeviceInfo/SoftwareVersion",
497494
},
498495
# missing values converted to empty string
499-
suppress_action_errors=True
496+
suppress_action_errors=True,
500497
)
501498
data["manufacturer"] = "Sagemcom"
502499

0 commit comments

Comments
 (0)