Skip to content

Commit 96a2707

Browse files
committed
address review
1 parent 41e4706 commit 96a2707

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

can/interfaces/socketcan/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ def find_available_interfaces() -> Iterable[str]:
6060
# log.debug("find_available_interfaces(): output=\n%s", output)
6161
# output contains some lines like "1: vcan42: <NOARP,UP,LOWER_UP> ..."
6262
# extract the "vcan42" of each line
63-
interface_names = [line.split(": ", 3)[1] for line in output.splitlines()]
64-
log.debug("find_available_interfaces(): detected: %s", interface_names)
65-
return filter(_PATTERN_CAN_INTERFACE.match, interface_names)
63+
interfaces = [line.split(": ", 3)[1] for line in output.splitlines()]
64+
log.debug("find_available_interfaces(): detected these interfaces (before filtering): %s", interfaces)
65+
return filter(_PATTERN_CAN_INTERFACE.match, interfaces)
6666

6767

6868
def error_code_to_str(code: Optional[int]) -> str:
@@ -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") if code is not None else "UNKNOWN"
76+
name = errno.errorcode.get(code, "UNKNOWN") # type: ignore
7777
description = os.strerror(code) if code is not None else "NO DESCRIPTION AVAILABLE"
7878

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

test/test_socketcan_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_error_code_to_str(self):
2121
"""
2222

2323
# all possible & also some invalid error codes
24-
test_data = list(range(0, 256)) + [-1, 256, 5235, 346264]
24+
test_data = list(range(0, 256)) + [-1, 256, 5235, 346264, None]
2525

2626
for error_code in test_data:
2727
string = error_code_to_str(error_code)

0 commit comments

Comments
 (0)