Skip to content

Commit 50869ac

Browse files
committed
fix linter complaints
1 parent fd772a1 commit 50869ac

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

can/interfaces/socketcan/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
Defines common socketcan functions.
33
"""
44

5+
import errno
56
import logging
67
import os
7-
import errno
8+
import re
89
import struct
910
import subprocess
10-
import re
1111
from typing import cast, Iterable, Optional
1212

1313
from can.interfaces.socketcan.constants import CAN_EFF_FLAG
@@ -73,7 +73,7 @@ def error_code_to_str(code: Optional[int]) -> str:
7373
:returns: a string explaining and containing the given error code, or a string
7474
explaining that the errorcode is unknown if that is the case
7575
"""
76-
name = errno.errorcode.get(code, "UNKNOWN")
77-
description = os.strerror(code)
76+
name = errno.errorcode.get(code, "UNKNOWN") if code is not None else "UNKNOWN"
77+
description = os.strerror(code) if code is not None else "NO DESCRIPTION AVAILABLE"
7878

7979
return f"{name} (errno {code}): {description}"

0 commit comments

Comments
 (0)