Skip to content

Commit 4033a62

Browse files
committed
fix other linter stuff
1 parent fb6c7d6 commit 4033a62

12 files changed

Lines changed: 32 additions & 91 deletions

File tree

.pylintrc-wip

Lines changed: 5 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -64,41 +64,19 @@ disable=blacklisted-name,
6464
invalid-name,
6565
missing-docstring,
6666
empty-docstring,
67-
singleton-comparison,
68-
misplaced-comparison-constant,
69-
consider-using-enumerate,
70-
consider-iterating-dictionary,
71-
bad-classmethod-argument,
72-
bad-mcs-method-argument,
73-
bad-mcs-classmethod-argument,
7467
single-string-used-for-slots,
7568
line-too-long,
7669
too-many-lines,
77-
multiple-statements,
78-
superfluous-parens,
7970
bad-whitespace,
8071
mixed-line-endings,
8172
unexpected-line-ending-format,
8273
bad-continuation,
83-
wrong-spelling-in-comment,
84-
wrong-spelling-in-docstring,
85-
invalid-characters-in-docstring,
8674
multiple-imports,
8775
wrong-import-order,
8876
ungrouped-imports,
8977
wrong-import-position,
90-
useless-import-alias,
91-
len-as-condition,
92-
syntax-error,
93-
unrecognized-inline-option,
94-
bad-option-value,
95-
return-in-init,
96-
duplicate-argument-name,
97-
abstract-class-instantiated,
98-
bad-reversed-sequence,
9978
too-many-star-expressions,
10079
invalid-star-assignment-target,
101-
star-needs-assignment-target,
10280
method-hidden,
10381
access-member-before-definition,
10482
no-method-argument,
@@ -151,16 +129,7 @@ disable=blacklisted-name,
151129
yield-inside-async-function,
152130
locally-disabled,
153131
file-ignored,
154-
suppressed-message,
155-
useless-suppression,
156-
deprecated-pragma,
157-
use-symbolic-message-instead,
158-
c-extension-no-member,
159-
literal-comparison,
160-
comparison-with-itself,
161132
no-self-use,
162-
no-classmethod-decorator,
163-
no-staticmethod-decorator,
164133
useless-object-inheritance,
165134
cyclic-import,
166135
duplicate-code,
@@ -173,18 +142,8 @@ disable=blacklisted-name,
173142
too-many-arguments,
174143
too-many-locals,
175144
too-many-statements,
176-
too-many-boolean-expressions,
177-
consider-merging-isinstance,
178145
too-many-nested-blocks,
179-
simplifiable-if-statement,
180-
redefined-argument-from-local,
181-
no-else-return,
182-
consider-using-ternary,
183-
trailing-comma-tuple,
184-
stop-iteration-return,
185-
simplify-boolean-expression,
186146
inconsistent-return-statements,
187-
useless-return,
188147
no-else-raise,
189148
dangerous-default-value,
190149
pointless-statement,
@@ -216,10 +175,6 @@ disable=blacklisted-name,
216175
misplaced-future,
217176
fixme,
218177
invalid-encoded-data,
219-
global-variable-undefined,
220-
global-variable-not-assigned,
221-
global-statement,
222-
global-at-module-level,
223178
unused-import,
224179
unused-variable,
225180
unused-argument,
@@ -233,18 +188,8 @@ disable=blacklisted-name,
233188
missing-format-argument-key,
234189
unused-format-string-argument,
235190
invalid-format-index,
236-
duplicate-string-formatting-argument,
237-
implicit-str-concat-in-sequence,
238-
redundant-unittest-assert,
239-
bad-thread-instantiation,
240-
shallow-copy-environ,
241-
invalid-envvar-default,
242-
subprocess-popen-preexec-fn,
243191
no-absolute-import,
244192
dict-iter-method,
245-
dict-view-method,
246-
next-method-called,
247-
metaclass-assignment,
248193
indexing-exception,
249194
raising-string,
250195
oct-method,
@@ -253,16 +198,11 @@ disable=blacklisted-name,
253198
invalid-str-codec,
254199
sys-max-int,
255200
next-method-defined,
256-
dict-items-not-iterating,
257-
dict-keys-not-iterating,
258-
dict-values-not-iterating,
259-
deprecated-operator-function,
260-
deprecated-urllib-function,
261-
xreadlines-attribute,
262-
deprecated-sys-function,
263-
exception-escape,
264-
comprehension-escape,
265-
redefined-builtin
201+
redefined-builtin,
202+
no-else-return,
203+
redefined-argument-from-local,
204+
abstract-class-instantiated,
205+
multiple-statements
266206

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

can/ctypesutil.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def map_symbol(self, func_name, restype=None, argtypes=(), errcheck=None):
3434
:param callable errcheck:
3535
optional error checking function, see ctypes docs for _FuncPtr
3636
"""
37-
if (argtypes):
37+
if argtypes:
3838
prototype = self.function_type(restype, *argtypes)
3939
else:
4040
prototype = self.function_type(restype)
@@ -46,7 +46,7 @@ def map_symbol(self, func_name, restype=None, argtypes=(), errcheck=None):
4646
setattr(symbol, "_name", func_name)
4747
log.debug('Wrapped function "{}", result type: {}, error_check {}'.format(func_name, type(restype), errcheck))
4848

49-
if (errcheck):
49+
if errcheck:
5050
symbol.errcheck = errcheck
5151

5252
setattr(self, func_name, symbol)
@@ -57,7 +57,7 @@ class CLibrary_Win32(_LibBase, LibraryMixin):
5757
" Basic ctypes.WinDLL derived class + LibraryMixin "
5858

5959
def __init__(self, library_or_path):
60-
if (isinstance(library_or_path, str)):
60+
if isinstance(library_or_path, str):
6161
super().__init__(library_or_path)
6262
else:
6363
super().__init__(library_or_path._name, library_or_path._handle)
@@ -71,7 +71,7 @@ class CLibrary_Unix(ctypes.CDLL, LibraryMixin):
7171
" Basic ctypes.CDLL derived class + LibraryMixin "
7272

7373
def __init__(self, library_or_path):
74-
if (isinstance(library_or_path, str)):
74+
if isinstance(library_or_path, str):
7575
super().__init__(library_or_path)
7676
else:
7777
super().__init__(library_or_path._name, library_or_path._handle)

can/interfaces/ixxat/canlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def __init__(self, channel, can_filters=None, **kwargs):
296296
# Usually comes as a string from the config file
297297
channel = int(channel)
298298

299-
if (bitrate not in self.CHANNEL_BITRATES[0]):
299+
if bitrate not in self.CHANNEL_BITRATES[0]:
300300
raise ValueError("Invalid bitrate {}".format(bitrate))
301301

302302
self._device_handle = HANDLE()
@@ -317,7 +317,7 @@ def __init__(self, channel, can_filters=None, **kwargs):
317317
try:
318318
_canlib.vciEnumDeviceNext(self._device_handle, ctypes.byref(self._device_info))
319319
except StopIteration:
320-
if (UniqueHardwareId is None):
320+
if UniqueHardwareId is None:
321321
raise VCIDeviceNotFoundError("No IXXAT device(s) connected or device(s) in use by other process(es).")
322322
else:
323323
raise VCIDeviceNotFoundError("Unique HW ID {} not connected or not available.".format(UniqueHardwareId))

can/interfaces/kvaser/canlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class c_canHandle(ctypes.c_int):
113113

114114

115115
def __handle_is_valid(handle):
116-
return (handle.value > canINVALID_HANDLE)
116+
return handle.value > canINVALID_HANDLE
117117

118118

119119
def __check_bus_handle_validity(handle, function, arguments):

can/interfaces/pcan/basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def __init__(self):
361361
self.__m_dllBasic = cdll.LoadLibrary('libPCBUSB.dylib')
362362
else:
363363
self.__m_dllBasic = cdll.LoadLibrary("libpcanbasic.so")
364-
if self.__m_dllBasic == None:
364+
if self.__m_dllBasic is None:
365365
logger.error("Exception: The PCAN-Basic DLL couldn't be loaded!")
366366

367367
def Initialize(

can/interfaces/usb2can/serial_selector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313

1414

1515
def WMIDateStringToDate(dtmDate):
16-
if (dtmDate[4] == 0):
16+
if dtmDate[4] == 0:
1717
strDateTime = dtmDate[5] + '/'
1818
else:
1919
strDateTime = dtmDate[4] + dtmDate[5] + '/'
2020

21-
if (dtmDate[6] == 0):
21+
if dtmDate[6] == 0:
2222
strDateTime = strDateTime + dtmDate[7] + '/'
2323
else:
2424
strDateTime = strDateTime + dtmDate[6] + dtmDate[7] + '/'

can/interfaces/vector/canlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def __init__(self, channel, can_filters=None, poll_interval=0.01,
9999
if channel_config.serialNumber == serial:
100100
if channel_config.hwChannel in self.channels:
101101
channel_index.append(channel_config.channelIndex)
102-
if len(channel_index) > 0:
102+
if channel_index:
103103
if len(channel_index) != len(self.channels):
104104
LOG.info("At least one defined channel wasn't found on the specified hardware.")
105105
self.channels = channel_index

can/io/canutils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ def __iter__(self):
5555
if channel.isdigit():
5656
channel = int(channel)
5757

58-
if len(canId) > 3:
59-
isExtended = True
60-
else:
61-
isExtended = False
58+
isExtended = len(canId) > 3
6259
canId = int(canId, 16)
6360

6461
if data and data[0].lower() == 'r':

can/io/csv.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ def __init__(self, file):
8989

9090
def __iter__(self):
9191
# skip the header line
92-
next(self.file)
92+
try:
93+
next(self.file)
94+
except StopIteration:
95+
# don't crash on a file with only a header
96+
return
9397

9498
for line in self.file:
9599

can/logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def main():
7575
can.set_logging_level(logging_level_name)
7676

7777
can_filters = []
78-
if len(results.filter) > 0:
78+
if results.filter:
7979
print(f"Adding filter(s): {results.filter}")
8080
for filt in results.filter:
8181
if ':' in filt:

0 commit comments

Comments
 (0)