From 2c94f155840b49639b8bf1ec996d99e268fa9a52 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 13 Jan 2022 14:19:38 -0800 Subject: [PATCH] linter: don't allow implicitly concatenated strings (#23513) * linter: don't allow implicitly concatenated strings * fix hyundai --- .pre-commit-config.yaml | 10 +++++++++- .pylintrc | 5 +++++ selfdrive/car/chrysler/values.py | 2 -- selfdrive/car/ford/values.py | 2 -- selfdrive/car/gm/values.py | 2 -- selfdrive/car/hyundai/values.py | 4 +--- selfdrive/car/mazda/values.py | 2 -- selfdrive/car/nissan/values.py | 4 +--- selfdrive/car/subaru/values.py | 2 -- selfdrive/car/tesla/values.py | 2 -- selfdrive/car/toyota/values.py | 2 -- selfdrive/car/volkswagen/values.py | 2 -- tools/joystick/joystickd.py | 12 ++++++------ 13 files changed, 22 insertions(+), 29 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3e4e1e3e1..3fc559656 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,8 @@ repos: +- repo: meta + hooks: + - id: check-hooks-apply + - id: check-useless-excludes - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.1.0 hooks: @@ -23,9 +27,13 @@ repos: hooks: - id: flake8 exclude: '^(pyextra/)|(cereal/)|(rednose/)|(panda/)|(laika/)|(opendbc/)|(laika_repo/)|(rednose_repo/)|(selfdrive/debug/)/' + additional_dependencies: ['flake8-no-implicit-concat'] args: + - --indent-size=2 + - --enable-extensions=NIC - --select=F,E112,E113,E304,E502,E701,E702,E703,E71,E72,E731,W191,W6 - --statistics + - -j4 - repo: local hooks: - id: pylint @@ -33,7 +41,7 @@ repos: entry: pylint language: system types: [python] - exclude: '^(pyextra/)|(cereal/)|(rednose/)|(panda/)|(laika/)|(laika_repo/)|(rednose_repo/)/' + exclude: '^(pyextra/)|(cereal/)|(rednose/)|(panda/)|(laika/)|(laika_repo/)|(rednose_repo/)' - repo: local hooks: - id: cppcheck diff --git a/.pylintrc b/.pylintrc index a3a2fc36f..d7edeb117 100644 --- a/.pylintrc +++ b/.pylintrc @@ -463,6 +463,11 @@ known-standard-library= # Force import order to recognize a module as part of a third party library. known-third-party=enchant +[STRING] + +# This flag controls whether the implicit-str-concat should generate a warning +# on implicit string concatenation in sequences defined over several lines. +check-str-concat-over-line-jumps=yes [EXCEPTIONS] diff --git a/selfdrive/car/chrysler/values.py b/selfdrive/car/chrysler/values.py index e32de1950..3fd32e9bc 100644 --- a/selfdrive/car/chrysler/values.py +++ b/selfdrive/car/chrysler/values.py @@ -1,5 +1,3 @@ -# flake8: noqa - from selfdrive.car import dbc_dict from cereal import car Ecu = car.CarParams.Ecu diff --git a/selfdrive/car/ford/values.py b/selfdrive/car/ford/values.py index 7c6cc6d2d..e1e220647 100644 --- a/selfdrive/car/ford/values.py +++ b/selfdrive/car/ford/values.py @@ -1,5 +1,3 @@ -# flake8: noqa - from selfdrive.car import dbc_dict from cereal import car Ecu = car.CarParams.Ecu diff --git a/selfdrive/car/gm/values.py b/selfdrive/car/gm/values.py index d475b4bd6..dd00193a1 100644 --- a/selfdrive/car/gm/values.py +++ b/selfdrive/car/gm/values.py @@ -1,5 +1,3 @@ -# flake8: noqa - from cereal import car from selfdrive.car import dbc_dict Ecu = car.CarParams.Ecu diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index 39a38aff4..d940144f8 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -1,5 +1,3 @@ -# flake8: noqa - from cereal import car from selfdrive.car import dbc_dict Ecu = car.CarParams.Ecu @@ -672,7 +670,7 @@ FW_VERSIONS = { b'\xf1\x00IK MDPS R 1.00 1.07 57700-G9220 4I2VL107', ], (Ecu.transmission, 0x7e1, None): [ - b'\xf1\x87VCJLP18407832DN3\x88vXfvUVT\x97eFU\x87d7v\x88eVeveFU\x89\x98\x7f\xff\xb2\xb0\xf1\x81E25\x00\x00\x00' + b'\xf1\x87VCJLP18407832DN3\x88vXfvUVT\x97eFU\x87d7v\x88eVeveFU\x89\x98\x7f\xff\xb2\xb0\xf1\x81E25\x00\x00\x00', b'\x00\x00\x00\x00\xf1\x00bcsh8p54 E25\x00\x00\x00\x00\x00\x00\x00SIK0T33NB4\xecE\xefL', ], (Ecu.fwdRadar, 0x7d0, None): [ diff --git a/selfdrive/car/mazda/values.py b/selfdrive/car/mazda/values.py index f18c30176..c3a5de0c1 100644 --- a/selfdrive/car/mazda/values.py +++ b/selfdrive/car/mazda/values.py @@ -1,5 +1,3 @@ -# flake8: noqa - from selfdrive.car import dbc_dict from cereal import car Ecu = car.CarParams.Ecu diff --git a/selfdrive/car/nissan/values.py b/selfdrive/car/nissan/values.py index 22bd4a129..f7001d141 100644 --- a/selfdrive/car/nissan/values.py +++ b/selfdrive/car/nissan/values.py @@ -1,5 +1,3 @@ -# flake8: noqa - from selfdrive.car import dbc_dict from cereal import car Ecu = car.CarParams.Ecu @@ -71,7 +69,7 @@ FW_VERSIONS = { (Ecu.gateway, 0x18dad0f1, None): [ b'284U29HE0A', ], - }, + }, CAR.LEAF_IC: { (Ecu.fwdCamera, 0x707, None): [ b'5SH1BDB\x04\x18\x00\x00\x00\x00\x00_-?\x04\x91\xf2\x00\x00\x00\x80', diff --git a/selfdrive/car/subaru/values.py b/selfdrive/car/subaru/values.py index f5a616188..4e1745366 100644 --- a/selfdrive/car/subaru/values.py +++ b/selfdrive/car/subaru/values.py @@ -1,5 +1,3 @@ -# flake8: noqa - from selfdrive.car import dbc_dict from cereal import car Ecu = car.CarParams.Ecu diff --git a/selfdrive/car/tesla/values.py b/selfdrive/car/tesla/values.py index 90bc45c7a..616933789 100644 --- a/selfdrive/car/tesla/values.py +++ b/selfdrive/car/tesla/values.py @@ -1,5 +1,3 @@ -# flake8: noqa - from collections import namedtuple from selfdrive.car import dbc_dict from cereal import car diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index 2536c02b5..81f530ef5 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -1,5 +1,3 @@ -# flake8: noqa - from cereal import car from selfdrive.car import dbc_dict from selfdrive.config import Conversions as CV diff --git a/selfdrive/car/volkswagen/values.py b/selfdrive/car/volkswagen/values.py index 262b193f5..4806754fe 100755 --- a/selfdrive/car/volkswagen/values.py +++ b/selfdrive/car/volkswagen/values.py @@ -1,5 +1,3 @@ -# flake8: noqa - from collections import defaultdict from typing import Dict diff --git a/tools/joystick/joystickd.py b/tools/joystick/joystickd.py index 2b138b9c1..5a8629344 100755 --- a/tools/joystick/joystickd.py +++ b/tools/joystick/joystickd.py @@ -73,7 +73,7 @@ def joystick_thread(use_keyboard): if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Publishes events from your joystick to control your car.\n' + parser = argparse.ArgumentParser(description='Publishes events from your joystick to control your car.\n' + 'openpilot must be offroad before starting joysticked.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--keyboard', action='store_true', help='Use your keyboard instead of a joystick') @@ -85,11 +85,11 @@ if __name__ == '__main__': print() if args.keyboard: - print('Gas/brake control: `W` and `S` keys\n' - 'Steering control: `A` and `D` keys') - print('Buttons:\n' - '- `R`: Resets axes\n' - '- `C`: Cancel cruise control') + print('Gas/brake control: `W` and `S` keys') + print('Steering control: `A` and `D` keys') + print('Buttons') + print('- `R`: Resets axes') + print('- `C`: Cancel cruise control') else: print('Using joystick, make sure to run cereal/messaging/bridge on your device if running over the network!')