Cache SmartErrorCode creation (#1022)

Uses the python 3.9 cache feature to improve performance of error code creation
This commit is contained in:
J. Nick Koston
2024-06-30 04:49:59 -05:00
committed by GitHub
parent 2a62849987
commit 368590cd36
3 changed files with 11 additions and 5 deletions

View File

@@ -241,12 +241,12 @@ class SmartProtocol(BaseProtocol):
def _handle_response_error_code(self, resp_dict: dict, method, raise_on_error=True):
error_code_raw = resp_dict.get("error_code")
try:
error_code = SmartErrorCode(error_code_raw) # type: ignore[arg-type]
error_code = SmartErrorCode.from_int(error_code_raw)
except ValueError:
_LOGGER.warning("Received unknown error code: %s", error_code_raw)
error_code = SmartErrorCode.INTERNAL_UNKNOWN_ERROR
if error_code == SmartErrorCode.SUCCESS:
if error_code is SmartErrorCode.SUCCESS:
return
if not raise_on_error: