Skip to content

Commit 1ce550c

Browse files
authored
Update linters and gh actions (#1794)
* update black * update ruff * update mypy and pylint * make pylint happy * update actions
1 parent 96754c1 commit 1ce550c

File tree

20 files changed

+63
-55
lines changed

20 files changed

+63
-55
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
# See: https://foss.heptapod.net/pypy/pypy/-/issues/3809
6565
TEST_SOCKETCAN: "${{ matrix.os == 'ubuntu-latest' && ! startsWith(matrix.python-version, 'pypy' ) }}"
6666
- name: Coveralls Parallel
67-
uses: coverallsapp/github-action@master
67+
uses: coverallsapp/github-action@v2
6868
with:
6969
github-token: ${{ secrets.github_token }}
7070
flag-name: Unittests-${{ matrix.os }}-${{ matrix.python-version }}
@@ -76,17 +76,17 @@ jobs:
7676
runs-on: ubuntu-latest
7777
steps:
7878
- name: Coveralls Finished
79-
uses: coverallsapp/github-action@master
79+
uses: coverallsapp/github-action@v2
8080
with:
8181
github-token: ${{ secrets.github_token }}
8282
parallel-finished: true
8383

8484
static-code-analysis:
8585
runs-on: ubuntu-latest
8686
steps:
87-
- uses: actions/checkout@v3
87+
- uses: actions/checkout@v4
8888
- name: Set up Python
89-
uses: actions/setup-python@v4
89+
uses: actions/setup-python@v5
9090
with:
9191
python-version: "3.10"
9292
- name: Install dependencies
@@ -123,9 +123,9 @@ jobs:
123123
format:
124124
runs-on: ubuntu-latest
125125
steps:
126-
- uses: actions/checkout@v3
126+
- uses: actions/checkout@v4
127127
- name: Set up Python
128-
uses: actions/setup-python@v4
128+
uses: actions/setup-python@v5
129129
with:
130130
python-version: "3.10"
131131
- name: Install dependencies

can/ctypesutil.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
This module contains common `ctypes` utils.
33
"""
4+
45
import ctypes
56
import logging
67
import sys

can/interfaces/ixxat/structures.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@ class UniqueHardwareId(ctypes.Union):
5151
]
5252

5353
def __str__(self):
54-
return "Mfg: {}, Dev: {} HW: {}.{}.{}.{} Drv: {}.{}.{}.{}".format(
55-
self.Manufacturer,
56-
self.Description,
57-
self.HardwareBranchVersion,
58-
self.HardwareMajorVersion,
59-
self.HardwareMinorVersion,
60-
self.HardwareBuildVersion,
61-
self.DriverReleaseVersion,
62-
self.DriverMajorVersion,
63-
self.DriverMinorVersion,
64-
self.DriverBuildVersion,
54+
return (
55+
f"Mfg: {self.Manufacturer}, "
56+
f"Dev: {self.Description} "
57+
f"HW: {self.HardwareBranchVersion}"
58+
f".{self.HardwareMajorVersion}"
59+
f".{self.HardwareMinorVersion}"
60+
f".{self.HardwareBuildVersion} "
61+
f"Drv: {self.DriverReleaseVersion}"
62+
f".{self.DriverMajorVersion}"
63+
f".{self.DriverMinorVersion}"
64+
f".{self.DriverBuildVersion}"
6565
)
6666

6767

can/interfaces/kvaser/canlib.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def __get_canlib_function(func_name, argtypes=None, restype=None, errcheck=None)
6464

6565

6666
class CANLIBError(CanError):
67-
6867
"""
6968
Try to display errors that occur within the wrapped C library nicely.
7069
"""

can/interfaces/kvaser/structures.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,13 @@ class BusStatistics(ctypes.Structure):
2323

2424
def __str__(self):
2525
return (
26-
"std_data: {}, std_remote: {}, ext_data: {}, ext_remote: {}, "
27-
"err_frame: {}, bus_load: {:.1f}%, overruns: {}"
28-
).format(
29-
self.std_data,
30-
self.std_remote,
31-
self.ext_data,
32-
self.ext_remote,
33-
self.err_frame,
34-
self.bus_load / 100.0,
35-
self.overruns,
26+
f"std_data: {self.std_data}, "
27+
f"std_remote: {self.std_remote}, "
28+
f"ext_data: {self.ext_data}, "
29+
f"ext_remote: {self.ext_remote}, "
30+
f"err_frame: {self.err_frame}, "
31+
f"bus_load: {self.bus_load / 100.0:.1f}%, "
32+
f"overruns: {self.overruns}"
3633
)
3734

3835
@property

can/interfaces/pcan/pcan.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Enable basic CAN over a PCAN USB device.
33
"""
4+
45
import logging
56
import platform
67
import time

can/interfaces/socketcan/socketcan.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
4141
log.error("socket.CMSG_SPACE not available on this platform")
4242

4343

44+
# Constants needed for precise handling of timestamps
45+
RECEIVED_TIMESTAMP_STRUCT = struct.Struct("@ll")
46+
RECEIVED_ANCILLARY_BUFFER_SIZE = (
47+
CMSG_SPACE(RECEIVED_TIMESTAMP_STRUCT.size) if CMSG_SPACE_available else 0
48+
)
49+
50+
4451
# Setup BCM struct
4552
def bcm_header_factory(
4653
fields: List[Tuple[str, Union[Type[ctypes.c_uint32], Type[ctypes.c_long]]]],
@@ -597,12 +604,6 @@ def capture_message(
597604
return msg
598605

599606

600-
# Constants needed for precise handling of timestamps
601-
if CMSG_SPACE_available:
602-
RECEIVED_TIMESTAMP_STRUCT = struct.Struct("@ll")
603-
RECEIVED_ANCILLARY_BUFFER_SIZE = CMSG_SPACE(RECEIVED_TIMESTAMP_STRUCT.size)
604-
605-
606607
class SocketcanBus(BusABC): # pylint: disable=abstract-method
607608
"""A SocketCAN interface to CAN.
608609

can/interfaces/socketcand/socketcand.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Copyright (C) 2021 DOMOLOGIC GmbH
88
http://www.domologic.de
99
"""
10+
1011
import logging
1112
import os
1213
import select

can/interfaces/systec/exceptions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ def __init__(self, result, func, arguments):
2222

2323
@property
2424
@abstractmethod
25-
def _error_message_mapping(self) -> Dict[ReturnCode, str]:
26-
...
25+
def _error_message_mapping(self) -> Dict[ReturnCode, str]: ...
2726

2827

2928
class UcanError(UcanException):

can/interfaces/systec/ucanbus.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ def __init__(self, channel, can_filters=None, **kwargs):
143143
self._ucan.init_hardware(device_number=device_number)
144144
self._ucan.init_can(self.channel, **self._params)
145145
hw_info_ex, _, _ = self._ucan.get_hardware_info()
146-
self.channel_info = "{}, S/N {}, CH {}, BTR {}".format(
147-
self._ucan.get_product_code_message(hw_info_ex.product_code),
148-
hw_info_ex.serial,
149-
self.channel,
150-
self._ucan.get_baudrate_message(self.BITRATES[bitrate]),
146+
self.channel_info = (
147+
f"{self._ucan.get_product_code_message(hw_info_ex.product_code)}, "
148+
f"S/N {hw_info_ex.serial}, "
149+
f"CH {self.channel}, "
150+
f"BTR {self._ucan.get_baudrate_message(self.BITRATES[bitrate])}"
151151
)
152152
except UcanException as exception:
153153
raise CanInitializationError() from exception

0 commit comments

Comments
 (0)