Skip to content

Commit

Permalink
Bump pre-commit hooks, more coverage (similar to openpilot) (commaai#…
Browse files Browse the repository at this point in the history
…1078)

* pytest defaults

* move some stuff to pyproject

* bump codespell

* more like openpilot
  • Loading branch information
sshane authored Aug 17, 2024
1 parent f4d077b commit 132b1a6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
9 changes: 3 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@ repos:
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
exclude: '\.dbc$'
args:
- --check-hidden
- --builtins clear,rare,informal,usage,code,names,en-GB_to_en-US
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
rev: v1.11.1
hooks:
- id: mypy
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.2
rev: v0.5.7
hooks:
- id: ruff
- repo: https://github.com/MarcoGorelli/cython-lint
Expand Down
2 changes: 1 addition & 1 deletion opendbc/can/tests/test_checksums.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_honda_checksum(self):
checksum_std = [11, 10, 9, 8]
checksum_ext = [4, 3, 2, 1]

for std, ext in zip(checksum_std, checksum_ext):
for std, ext in zip(checksum_std, checksum_ext, strict=True):
msgs = [
packer.make_can_msg("LKAS_HUD", 0, values),
packer.make_can_msg("LKAS_HUD_A", 0, values),
Expand Down
4 changes: 2 additions & 2 deletions opendbc/dbc/generator/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ def create_dbc(src_dir: str, filename: str, output_path: str):
dbc_file_out.write('CM_ "AUTOGENERATED FILE, DO NOT EDIT";\n')

for include_filename in includes:
include_file_header = '\n\nCM_ "Imported file %s starts here";\n' % include_filename
include_file_header = f'\n\nCM_ "Imported file {include_filename} starts here";\n'
dbc_file_out.write(include_file_header)

include_file = read_dbc(src_dir, include_filename)
dbc_file_out.write(include_file)

dbc_file_out.write('\nCM_ "%s starts here";\n' % filename)
dbc_file_out.write(f'\nCM_ "{filename} starts here";\n')

core_dbc = include_pattern.sub('', dbc_file_in)
dbc_file_out.write(core_dbc)
Expand Down
31 changes: 30 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,48 @@ requires-python = ">=3.9"

urls = { "homepage" = "https://github.com/commaai/opendbc" }

[tool.pytest.ini_options]
addopts = "-Werror --strict-config --strict-markers --durations=10 -n auto"
python_files = "test_*.py"
testpaths = [
"opendbc"
]

[tool.codespell]
quiet-level = 3
builtin = "clear,rare,informal,code,names,en-GB_to_en-US"
check-hidden = true

[tool.cython-lint]
max-line-length = 120
ignore = ["E111", "E114"]

[tool.mypy]
# helpful warnings
warn_redundant_casts=true
warn_unreachable=true
warn_unused_ignores=true

# restrict dynamic typing
warn_return_any=true

explicit_package_bases=true

# https://beta.ruff.rs/docs/configuration/#using-pyprojecttoml
[tool.ruff]
line-length = 160
indent-width = 2
target-version="py311"

[tool.ruff.lint]
select = ["E", "F", "W", "PIE", "C4", "ISC", "RUF100", "A"]
select = [
"E", "F", "W", "PIE", "C4", "ISC", "A", "B",
"NPY", # numpy
"UP", # pyupgrade
"TRY302", "TRY400", "TRY401", # try/excepts
"RUF008", "RUF100",
"TID251",
"PLR1704",
]
ignore = ["W292", "E741", "E402", "C408", "ISC003"]
flake8-implicit-str-concat.allow-multiline=false

0 comments on commit 132b1a6

Please sign in to comment.