Skip to content

Commit 270224c

Browse files
authored
Fix formatter and bump ci tools (#1167)
* Bump CI tool versions * Fix many linter issues * Format code with black
1 parent 38889ec commit 270224c

30 files changed

+117
-126
lines changed

can/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
log = logging.getLogger("can")
1414

15-
rc: Dict[str, Any] = dict()
15+
rc: Dict[str, Any] = {}
1616

1717
from .listener import Listener, BufferedReader, RedirectReader, AsyncBufferedReader
1818

can/interfaces/canalystii.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def __init__(
5353
elif isinstance(channel, int):
5454
self.channels = [channel]
5555
else: # Sequence[int]
56-
self.channels = [c for c in channel]
56+
self.channels = list(channel)
5757

5858
self.rx_queue = collections.deque(
5959
maxlen=rx_queue_size

can/interfaces/cantact.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _detect_available_configs():
3939

4040
channels = []
4141
for i in range(0, interface.channel_count()):
42-
channels.append({"interface": "cantact", "channel": "ch:%d" % i})
42+
channels.append({"interface": "cantact", "channel": f"ch:{i}"})
4343
return channels
4444

4545
def __init__(

can/interfaces/ics_neovi/neovi_bus.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ def channel_to_netid(channel_name_or_id):
226226
channel = getattr(ics, netid)
227227
else:
228228
raise ValueError(
229-
"channel must be an integer or " "a valid ICS channel name"
230-
)
229+
"channel must be an integer or a valid ICS channel name"
230+
) from None
231231
return channel
232232

233233
@staticmethod

can/interfaces/ixxat/canlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,12 +604,12 @@ def _inWaiting(self):
604604
return 1
605605

606606
def flush_tx_buffer(self):
607-
""" Flushes the transmit buffer on the IXXAT """
607+
"""Flushes the transmit buffer on the IXXAT"""
608608
# TODO #64: no timeout?
609609
_canlib.canChannelWaitTxEvent(self._channel_handle, constants.INFINITE)
610610

611611
def _recv_internal(self, timeout):
612-
""" Read a message from IXXAT device. """
612+
"""Read a message from IXXAT device."""
613613

614614
# TODO: handling CAN error messages?
615615
data_received = False

can/interfaces/ixxat/exceptions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121

2222

2323
class VCITimeout(CanTimeoutError):
24-
""" Wraps the VCI_E_TIMEOUT error """
24+
"""Wraps the VCI_E_TIMEOUT error"""
2525

2626

2727
class VCIError(CanOperationError):
28-
""" Try to display errors that occur within the wrapped C library nicely. """
28+
"""Try to display errors that occur within the wrapped C library nicely."""
2929

3030

3131
class VCIRxQueueEmptyError(VCIError):
32-
""" Wraps the VCI_E_RXQUEUE_EMPTY error """
32+
"""Wraps the VCI_E_RXQUEUE_EMPTY error"""
3333

3434
def __init__(self):
3535
super().__init__("Receive queue is empty")

can/interfaces/kvaser/canlib.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -713,11 +713,7 @@ def get_channel_info(channel):
713713
ctypes.sizeof(number),
714714
)
715715

716-
return "%s, S/N %d (#%d)" % (
717-
name.value.decode("ascii"),
718-
serial.value,
719-
number.value + 1,
720-
)
716+
return f"{name.value.decode('ascii')}, S/N {serial.value} (#{number.value + 1})"
721717

722718

723719
init_kvaser_library()

can/interfaces/neousys/neousys.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848

4949
class NeousysCanSetup(Structure):
50-
""" C CAN Setup struct """
50+
"""C CAN Setup struct"""
5151

5252
_fields_ = [
5353
("bitRate", c_uint),
@@ -58,7 +58,7 @@ class NeousysCanSetup(Structure):
5858

5959

6060
class NeousysCanMsg(Structure):
61-
""" C CAN Message struct """
61+
"""C CAN Message struct"""
6262

6363
_fields_ = [
6464
("id", c_uint),
@@ -75,7 +75,7 @@ class NeousysCanMsg(Structure):
7575
# valid:1~4, Resynchronization Jump Width in time quanta
7676
# valid:1~1023, CAN_CLK divider used to determine time quanta
7777
class NeousysCanBitClk(Structure):
78-
""" C CAN BIT Clock struct """
78+
"""C CAN BIT Clock struct"""
7979

8080
_fields_ = [
8181
("syncPropPhase1Seg", c_ushort),

can/interfaces/nixnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
)
3131
except ImportError:
3232
logger.error("Error, NIXNET python module cannot be loaded.")
33-
raise ImportError()
33+
raise
3434
else:
3535
logger.error("NI-XNET interface is only available on Windows systems")
3636
raise NotImplementedError("NiXNET is not supported on not Win32 platforms")

can/interfaces/seeedstudio/seeedstudio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def __init__(
113113
"could not create the serial device"
114114
) from error
115115

116-
super(SeeedBus, self).__init__(channel=channel, *args, **kwargs)
116+
super().__init__(channel=channel, *args, **kwargs)
117117
self.init_frame()
118118

119119
def shutdown(self):

0 commit comments

Comments
 (0)