Skip to content

Commit 8a0d980

Browse files
committed
fix other linter stuff
1 parent cbea5ee commit 8a0d980

File tree

21 files changed

+37
-53
lines changed

21 files changed

+37
-53
lines changed

.pylintrc-wip

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,22 +93,16 @@ disable=blacklisted-name,
9393
too-many-statements,
9494
too-many-nested-blocks,
9595
no-else-raise,
96-
attribute-defined-outside-init,
97-
protected-access,
98-
abstract-method,
9996
bad-indentation,
10097
wildcard-import,
10198
fixme,
10299
broad-except,
103100
bad-format-string,
104-
missing-format-argument-key,
105101
unused-format-string-argument,
106-
invalid-format-index,
107102
no-absolute-import,
108103
dict-iter-method,
109104
oct-method,
110105
hex-method,
111-
exception-message-attribute,
112106
redefined-builtin,
113107
no-else-return,
114108
redefined-argument-from-local,
@@ -118,7 +112,14 @@ disable=blacklisted-name,
118112
useless-else-on-loop,
119113
duplicate-code,
120114
inconsistent-return-statements,
121-
arguments-differ
115+
arguments-differ,
116+
unused-wildcard-import,
117+
logging-fstring-interpolation,
118+
logging-format-interpolation,
119+
unused-argument,
120+
abstract-method,
121+
attribute-defined-outside-init,
122+
protected-access
122123

123124
# Enable the message, report, category or checker with the given id(s). You can
124125
# either give multiple identifier separated by comma (,) or put this option

can/broadcastmanager.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import logging
1212
import threading
1313
import time
14-
import warnings
1514

1615
log = logging.getLogger('can.bcm')
1716

can/bus.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import logging
99
import threading
1010
from time import time
11-
from collections import namedtuple
1211
from aenum import Enum, auto
1312

1413
from .broadcastmanager import ThreadBasedCyclicSendTask
@@ -239,8 +238,8 @@ def _send_periodic_internal(self, msg, period, duration=None):
239238
:rtype: can.broadcastmanager.CyclicSendTaskABC
240239
"""
241240
if not hasattr(self, "_lock_send_periodic"):
242-
# Create a send lock for this bus
243-
self._lock_send_periodic = threading.Lock()
241+
# Create a send lock for this bus, but not for buses which override this method
242+
self._lock_send_periodic = threading.Lock() # pylint: disable=attribute-defined-outside-init
244243
task = ThreadBasedCyclicSendTask(self, self._lock_send_periodic, msg, period, duration)
245244
return task
246245

can/ctypesutil.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
This module contains common `ctypes` utils.
55
"""
66

7-
import binascii
87
import ctypes
98
import logging
109
import sys
@@ -44,7 +43,7 @@ def map_symbol(self, func_name, restype=None, argtypes=(), errcheck=None):
4443
raise ImportError("Could not map function '{}' from library {}".format(func_name, self._name))
4544

4645
setattr(symbol, "_name", func_name)
47-
log.debug('Wrapped function "{}", result type: {}, error_check {}'.format(func_name, type(restype), errcheck))
46+
log.debug(f'Wrapped function "{func_name}", result type: {type(restype)}, error_check {errcheck}')
4847

4948
if errcheck:
5049
symbol.errcheck = errcheck

can/interface.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66
CyclicSendTasks.
77
"""
88

9-
import sys
109
import importlib
1110
import logging
1211

13-
import can
1412
from .bus import BusABC
15-
from .broadcastmanager import CyclicSendTaskABC, MultiRateCyclicSendTaskABC
1613
from .util import load_config
1714
from .interfaces import BACKENDS
1815

@@ -56,7 +53,7 @@ def _get_class_for_interface(interface):
5653
return bus_class
5754

5855

59-
class Bus(BusABC):
56+
class Bus(BusABC): # pylint disable=abstract-method
6057
"""Bus wrapper with configuration loading.
6158
6259
Instantiates a CAN Bus of the given ``interface``, falls back to reading a
@@ -154,7 +151,7 @@ def detect_available_configs(interfaces=None):
154151

155152
# get available channels
156153
try:
157-
available = list(bus_class._detect_available_configs())
154+
available = list(bus_class._detect_available_configs()) # pylint: disable=protected-access
158155
except NotImplementedError:
159156
log_autodetect.debug('interface "%s" does not support detection of available configurations', interface)
160157
else:

can/interfaces/ics_neovi/neovi_bus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def _process_msg_queue(self, timeout=0.1):
234234
continue
235235
self.rx_buffer.append(ics_msg)
236236
if errors:
237-
logger.warning("%d error(s) found" % errors)
237+
logger.warning("%d error(s) found", errors)
238238

239239
for msg in ics.get_error_messages(self.dev):
240240
error = ICSApiError(*msg)

can/interfaces/ixxat/canlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import logging
1919
import sys
2020

21-
from can import CanError, BusABC, Message
21+
from can import BusABC, Message
2222
from can.broadcastmanager import (LimitedDurationCyclicSendTaskABC,
2323
RestartableCyclicTaskABC)
2424
from can.ctypesutil import CLibrary, HANDLE, PHANDLE, HRESULT as ctypes_HRESULT
@@ -383,7 +383,7 @@ def __init__(self, channel, can_filters=None, **kwargs):
383383

384384
# Usually you get back 3 messages like "CAN initialized" ecc...
385385
# Clear the FIFO by filter them out with low timeout
386-
for i in range(rxFifoSize):
386+
for _ in range(rxFifoSize):
387387
try:
388388
_canlib.canChannelReadMessage(self._channel_handle, 0, ctypes.byref(self._message))
389389
except (VCITimeout, VCIRxQueueEmptyError):

can/interfaces/kvaser/canlib.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,9 @@ def __init__(self, channel, can_filters=None, **kwargs):
375375
self.single_handle = single_handle
376376

377377
num_channels = ctypes.c_int(0)
378-
res = canGetNumberOfChannels(ctypes.byref(num_channels))
379-
#log.debug("Res: {}".format(res))
378+
#log.debug("Res: %d", canGetNumberOfChannels(ctypes.byref(num_channels)))
380379
num_channels = int(num_channels.value)
381-
log.info('Found %d available channels' % num_channels)
380+
log.info('Found %d available channels', num_channels)
382381
for idx in range(num_channels):
383382
channel_info = get_channel_info(idx)
384383
log.info('%d: %s', idx, channel_info)
@@ -391,7 +390,7 @@ def __init__(self, channel, can_filters=None, **kwargs):
391390
if fd:
392391
flags |= canstat.canOPEN_CAN_FD
393392

394-
log.debug('Creating read handle to bus channel: %s' % channel)
393+
log.debug('Creating read handle to bus channel: %s', channel)
395394
self._read_handle = canOpenChannel(channel, flags)
396395
canIoCtl(self._read_handle,
397396
canstat.canIOCTL_SET_TIMER_SCALE,
@@ -427,7 +426,7 @@ def __init__(self, channel, can_filters=None, **kwargs):
427426
log.debug("We don't require separate handles to the bus")
428427
self._write_handle = self._read_handle
429428
else:
430-
log.debug('Creating separate handle for TX on channel: %s' % channel)
429+
log.debug('Creating separate handle for TX on channel: %s', channel)
431430
self._write_handle = canOpenChannel(channel, flags)
432431
canBusOn(self._read_handle)
433432

can/interfaces/pcan/pcan.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
"""
66

77
import logging
8-
import sys
98
import time
109

11-
import can
1210
from can import CanError, Message, BusABC
1311
from can.bus import BusState
1412
from can.util import len2dlc, dlc2len
@@ -165,7 +163,7 @@ def __init__(self, *args, channel='PCAN_USBBUS1', state=BusState.ACTIVE, bitrate
165163
self.m_PcanHandle = globals()[channel]
166164

167165
if state is BusState.ACTIVE or state is BusState.PASSIVE:
168-
self.state = state
166+
self._state = state
169167
else:
170168
raise ArgumentError("BusState must be Active or Passive")
171169

can/interfaces/socketcan/socketcan.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import logging
44
import ctypes
55
import ctypes.util
6-
import os
76
import select
87
import socket
98
import struct
@@ -25,8 +24,7 @@
2524
from can.broadcastmanager import ModifiableCyclicTaskABC, \
2625
RestartableCyclicTaskABC, LimitedDurationCyclicSendTaskABC
2726
from can.interfaces.socketcan.constants import * # CAN_RAW, CAN_*_FLAG
28-
from can.interfaces.socketcan.utils import \
29-
pack_filters, find_available_interfaces, error_code_to_str
27+
from can.interfaces.socketcan.utils import pack_filters, find_available_interfaces
3028

3129

3230
# Setup BCM struct
@@ -478,6 +476,7 @@ def __init__(self, channel="", receive_own_messages=False, fd=False, **kwargs):
478476
self.channel = channel
479477
self.channel_info = "socketcan channel '%s'" % channel
480478
self._bcm_sockets = {}
479+
self._is_filtered = False
481480

482481
# set the receive_own_messages parameter
483482
try:

0 commit comments

Comments
 (0)