Skip to content

Commit 684dec2

Browse files
committed
fix other linter stuff
1 parent 2ab6ff2 commit 684dec2

File tree

5 files changed

+22
-58
lines changed

5 files changed

+22
-58
lines changed

.pylintrc-wip

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,7 @@ disable=blacklisted-name,
205205
simplify-boolean-expression,
206206
inconsistent-return-statements,
207207
useless-return,
208-
consider-swap-variables,
209-
consider-using-join,
210-
consider-using-in,
211-
consider-using-get,
212-
chained-comparison,
213-
consider-using-dict-comprehension,
214-
consider-using-set-comprehension,
215-
simplifiable-if-expression,
216208
no-else-raise,
217-
unreachable,
218209
dangerous-default-value,
219210
pointless-statement,
220211
pointless-string-statement,
@@ -253,11 +244,6 @@ disable=blacklisted-name,
253244
unused-variable,
254245
unused-argument,
255246
unused-wildcard-import,
256-
redefined-outer-name,
257-
redefined-builtin,
258-
redefine-in-handler,
259-
undefined-loop-variable,
260-
unbalanced-tuple-unpacking,
261247
possibly-unused-variable,
262248
broad-except,
263249
logging-not-lazy,
@@ -275,39 +261,17 @@ disable=blacklisted-name,
275261
invalid-envvar-default,
276262
subprocess-popen-preexec-fn,
277263
no-absolute-import,
278-
old-division,
279264
dict-iter-method,
280265
dict-view-method,
281266
next-method-called,
282267
metaclass-assignment,
283268
indexing-exception,
284269
raising-string,
285-
reload-builtin,
286270
oct-method,
287271
hex-method,
288-
nonzero-method,
289-
cmp-method,
290-
input-builtin,
291-
round-builtin,
292-
intern-builtin,
293-
unichr-builtin,
294-
map-builtin-not-iterating,
295-
zip-builtin-not-iterating,
296-
range-builtin-not-iterating,
297-
filter-builtin-not-iterating,
298-
using-cmp-argument,
299-
eq-without-hash,
300-
div-method,
301-
idiv-method,
302-
rdiv-method,
303272
exception-message-attribute,
304273
invalid-str-codec,
305274
sys-max-int,
306-
bad-python3-import,
307-
deprecated-string-function,
308-
deprecated-str-translate-call,
309-
deprecated-itertools-function,
310-
deprecated-types-field,
311275
next-method-defined,
312276
dict-items-not-iterating,
313277
dict-keys-not-iterating,
@@ -317,7 +281,8 @@ disable=blacklisted-name,
317281
xreadlines-attribute,
318282
deprecated-sys-function,
319283
exception-escape,
320-
comprehension-escape
284+
comprehension-escape,
285+
redefined-builtin
321286

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

can/interfaces/ixxat/canlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,8 @@ def _recv_internal(self, timeout):
465465
# so expect to see the value restarting from 0
466466
rx_msg = Message(
467467
timestamp=self._message.dwTime / self._tick_resolution, # Relative time in s
468-
is_remote_frame=True if self._message.uMsgInfo.Bits.rtr else False,
469-
is_extended_id=True if self._message.uMsgInfo.Bits.ext else False,
468+
is_remote_frame=bool(self._message.uMsgInfo.Bits.rtr),
469+
is_extended_id=bool(self._message.uMsgInfo.Bits.ext),
470470
arbitration_id=self._message.dwMsgId,
471471
dlc=self._message.uMsgInfo.Bits.dlc,
472472
data=self._message.abData[:self._message.uMsgInfo.Bits.dlc],

can/interfaces/pcan/basic.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -658,13 +658,15 @@ def GetValue(
658658
A touple with 2 values
659659
"""
660660
try:
661-
if Parameter == PCAN_API_VERSION or Parameter == PCAN_HARDWARE_NAME or Parameter == PCAN_CHANNEL_VERSION or Parameter == PCAN_LOG_LOCATION or Parameter == PCAN_TRACE_LOCATION or Parameter == PCAN_BITRATE_INFO_FD or Parameter == PCAN_IP_ADDRESS:
661+
if Parameter in (PCAN_API_VERSION, PCAN_HARDWARE_NAME, PCAN_CHANNEL_VERSION,
662+
PCAN_LOG_LOCATION, PCAN_TRACE_LOCATION, PCAN_BITRATE_INFO_FD,
663+
PCAN_IP_ADDRESS):
662664
mybuffer = create_string_buffer(256)
663665
else:
664666
mybuffer = c_int(0)
665667

666-
res = self.__m_dllBasic.CAN_GetValue(Channel,Parameter,byref(mybuffer),sizeof(mybuffer))
667-
return TPCANStatus(res),mybuffer.value
668+
res = self.__m_dllBasic.CAN_GetValue(Channel, Parameter, byref(mybuffer), sizeof(mybuffer))
669+
return TPCANStatus(res), mybuffer.value
668670
except:
669671
logger.error("Exception on PCANBasic.GetValue")
670672
raise
@@ -694,13 +696,13 @@ def SetValue(
694696
A TPCANStatus error code
695697
"""
696698
try:
697-
if Parameter == PCAN_LOG_LOCATION or Parameter == PCAN_LOG_TEXT or Parameter == PCAN_TRACE_LOCATION:
699+
if Parameter in (PCAN_LOG_LOCATION, PCAN_LOG_TEXT, PCAN_TRACE_LOCATION):
698700
mybuffer = create_string_buffer(256)
699701
else:
700702
mybuffer = c_int(0)
701703

702704
mybuffer.value = Buffer
703-
res = self.__m_dllBasic.CAN_SetValue(Channel,Parameter,byref(mybuffer),sizeof(mybuffer))
705+
res = self.__m_dllBasic.CAN_SetValue(Channel, Parameter, byref(mybuffer), sizeof(mybuffer))
704706
return TPCANStatus(res)
705707
except:
706708
logger.error("Exception on PCANBasic.SetValue")

can/interfaces/usb2can/usb2canInterface.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@ def __init__(self, *args, channel=None, dll="usb2can.dll", flags=0x00000008,
8989
self.can = Usb2CanAbstractionLayer(dll)
9090

9191
# get the serial number of the device
92-
if "serial" in kwargs:
93-
device_id = kwargs["serial"]
94-
else:
95-
device_id = channel
92+
device_id = kwargs.get("serial", d=channel)
9693

9794
# search for a serial number if the device_id is None or empty
9895
if not device_id:
@@ -107,9 +104,9 @@ def __init__(self, *args, channel=None, dll="usb2can.dll", flags=0x00000008,
107104
self.channel_info = "USB2CAN device {}".format(device_id)
108105

109106
connector = "{}; {}".format(device_id, baudrate)
110-
self.handle = self.can.open(connector, flags)
107+
self.handle = self.can.open(connector, flags_t)
111108

112-
super().__init__(channel=channel, dll=dll, flags=flags, bitrate=bitrate,
109+
super().__init__(channel=channel, dll=dll, flags_t=flags_t, bitrate=bitrate,
113110
*args, **kwargs)
114111

115112
def send(self, msg, timeout=None):
@@ -137,7 +134,7 @@ def _recv_internal(self, timeout):
137134

138135
if status == CANAL_ERROR_SUCCESS:
139136
rx = message_convert_rx(messagerx)
140-
elif status == CANAL_ERROR_RCV_EMPTY or status == CANAL_ERROR_TIMEOUT:
137+
elif status in (CANAL_ERROR_RCV_EMPTY, CANAL_ERROR_TIMEOUT):
141138
rx = None
142139
else:
143140
log.error('Canal Error %s', status)

can/interfaces/usb2can/usb2canabstractionlayer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
log = logging.getLogger('can.usb2can')
1515

1616
# type definitions
17-
flags = c_ulong
17+
flags_t = c_ulong
1818
pConfigureStr = c_char_p
19-
handle = c_long
20-
timeout = c_ulong
19+
handle_t = c_long
20+
timeout_t = c_ulong
2121
filter_t = c_ulong
2222

2323
# flags mappings
@@ -146,17 +146,17 @@ def blocking_receive(self, handle, msg, timeout):
146146
log.warning('Blocking Receive Failed')
147147
raise
148148

149-
def get_status(self, handle, CanalStatus):
149+
def get_status(self, handle, status):
150150
try:
151-
res = self.__m_dllBasic.CanalGetStatus(handle, CanalStatus)
151+
res = self.__m_dllBasic.CanalGetStatus(handle, status)
152152
return res
153153
except:
154154
log.warning('Get status failed')
155155
raise
156156

157-
def get_statistics(self, handle, CanalStatistics):
157+
def get_statistics(self, handle, statistics):
158158
try:
159-
res = self.__m_dllBasic.CanalGetStatistics(handle, CanalStatistics)
159+
res = self.__m_dllBasic.CanalGetStatistics(handle, statistics)
160160
return res
161161
except:
162162
log.warning('Get Statistics failed')

0 commit comments

Comments
 (0)