From 1f1ff225bd03b273a4861a67d96d4e53d7ce542c Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Mon, 1 Jun 2020 02:03:03 -0700 Subject: [PATCH] enable almost all flake8 checks --- .pre-commit-config.yaml | 3 ++- can/dbc.py | 9 +++++---- can/packer_pyx_setup.py | 2 +- can/parser_pyx_setup.py | 2 +- can/process_dbc.py | 3 ++- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 602d9d8..3e5c1d4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,8 @@ repos: hooks: - id: flake8 args: - - --select=F + - --ignore=E111,E114,E121,E124,E302,E501,E741 + - --statistics - repo: local hooks: - id: pylint diff --git a/can/dbc.py b/can/dbc.py index cff65a1..32d8fff 100755 --- a/can/dbc.py +++ b/can/dbc.py @@ -12,6 +12,7 @@ def int_or_float(s): else: return float(s) + DBCSignal = namedtuple( "DBCSignal", ["name", "start_bit", "size", "is_little_endian", "is_signed", "factor", "offset", "tmin", "tmax", "units"]) @@ -41,7 +42,7 @@ class dbc(): self.def_vals = defaultdict(list) # lookup to bit reverse each byte - self.bits_index = [(i & ~0b111) + ((-i-1) & 0b111) for i in range(64)] + self.bits_index = [(i & ~0b111) + ((-i - 1) & 0b111) for i in range(64)] for l in self.txt: l = l.strip() @@ -103,7 +104,7 @@ class dbc(): # convert strings to UPPER_CASE_WITH_UNDERSCORES defvals[1::2] = [d.strip().upper().replace(" ", "_") for d in defvals[1::2]] - defvals = '"'+"".join(str(i) for i in defvals)+'"' + defvals = '"' + "".join(str(i) for i in defvals) + '"' self.def_vals[ids].append((sgname, defvals)) @@ -193,12 +194,12 @@ class dbc(): if arr is None: out = {} else: - out = [None]*len(arr) + out = [None] * len(arr) msg = self.msgs.get(x[0]) if msg is None: if x[0] not in self._warned_addresses: - #print("WARNING: Unknown message address {}".format(x[0])) + # print("WARNING: Unknown message address {}".format(x[0])) self._warned_addresses.add(x[0]) return None, None diff --git a/can/packer_pyx_setup.py b/can/packer_pyx_setup.py index d98a2a4..1e8c70c 100644 --- a/can/packer_pyx_setup.py +++ b/can/packer_pyx_setup.py @@ -65,4 +65,4 @@ setup(name='CAN packer', ) if platform.system() == "Darwin": - os.system("install_name_tool -change opendbc/can/libdbc.dylib "+BASEDIR+"/opendbc/can/libdbc.dylib packer_pyx.so") + os.system("install_name_tool -change opendbc/can/libdbc.dylib " + BASEDIR + "/opendbc/can/libdbc.dylib packer_pyx.so") diff --git a/can/parser_pyx_setup.py b/can/parser_pyx_setup.py index eefd3f5..6e4cbd5 100644 --- a/can/parser_pyx_setup.py +++ b/can/parser_pyx_setup.py @@ -65,4 +65,4 @@ setup(name='CAN parser', ) if platform.system() == "Darwin": - os.system("install_name_tool -change opendbc/can/libdbc.dylib "+BASEDIR+"/opendbc/can/libdbc.dylib parser_pyx.so") + os.system("install_name_tool -change opendbc/can/libdbc.dylib " + BASEDIR + "/opendbc/can/libdbc.dylib parser_pyx.so") diff --git a/can/process_dbc.py b/can/process_dbc.py index 4d88ed8..3e4390a 100755 --- a/can/process_dbc.py +++ b/can/process_dbc.py @@ -10,7 +10,7 @@ from opendbc.can.dbc import dbc def process(in_fn, out_fn): dbc_name = os.path.split(out_fn)[-1].replace('.cc', '') - #print("processing %s: %s -> %s" % (dbc_name, in_fn, out_fn)) + # print("processing %s: %s -> %s" % (dbc_name, in_fn, out_fn)) template_fn = os.path.join(os.path.dirname(__file__), "dbc_template.cc") @@ -122,5 +122,6 @@ def main(): process(in_fn, out_fn) + if __name__ == '__main__': main()