Skip to content
This repository was archived by the owner on Apr 13, 2024. It is now read-only.

Commit d309cdc

Browse files
authored
Added linter to opendbc (commaai#203)
* Added linter to opendbc * this? * This should work * another try * added pylintrc
1 parent d452706 commit d309cdc

File tree

5 files changed

+612
-5
lines changed

5 files changed

+612
-5
lines changed

azure-pipelines.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ pr: none
22

33
pool:
44
vmImage: 'ubuntu-16.04'
5-
65
steps:
76
- script: |
87
set -e
98
docker build -t opendbc .
9+
displayName: 'Build'
10+
- script: |
1011
docker run opendbc bash -c "python -m unittest discover opendbc"
11-
12-
displayName: 'Run Tests'
12+
displayName: 'Unit tests'
13+
- script: |
14+
docker run opendbc bash -c "cd opendbc/can/tests/linter_python; PYTHONPATH=/ ./flake8_opendbc.sh"
15+
docker run opendbc bash -c "cd opendbc/can/tests/linter_python; PYTHONPATH=/ ./pylint_opendbc.sh"
16+
displayName: 'Python linter'

can/dbc.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ def get_signals(self, msg):
257257

258258
if __name__ == "__main__":
259259
from opendbc import DBC_PATH
260-
import numpy as np
261260

262261
dbc_test = dbc(os.path.join(DBC_PATH, 'toyota_prius_2017_pt_generated.dbc'))
263262
msg = ('STEER_ANGLE_SENSOR', {'STEER_ANGLE': -6.0, 'STEER_RATE': 4, 'STEER_FRACTION': -0.2})
@@ -267,7 +266,7 @@ def get_signals(self, msg):
267266

268267
dbc_test = dbc(os.path.join(DBC_PATH, 'hyundai_santa_fe_2019_ccan.dbc'))
269268
decoded = dbc_test.decode((0x2b0, 0, "\xfa\xfe\x00\x07\x12"))
270-
assert np.isclose(decoded[1]['SAS_Angle'], -26.2)
269+
assert abs(decoded[1]['SAS_Angle'] - (-26.2)) < 0.001
271270

272271
msg = ('SAS11', {'SAS_Stat': 7.0, 'MsgCount': 0.0, 'SAS_Angle': -26.200000000000003, 'SAS_Speed': 0.0, 'CheckSum': 0.0})
273272
encoded = dbc_test.encode(*msg)

0 commit comments

Comments
 (0)