Bump pre-commit hooks, more coverage (similar to openpilot) (#1078)

* pytest defaults

* move some stuff to pyproject

* bump codespell

* more like openpilot
This commit is contained in:
Shane Smiskol 2024-08-16 22:24:44 -07:00 committed by GitHub
parent f4d077b832
commit 132b1a66b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 36 additions and 10 deletions

View File

@ -9,19 +9,16 @@ repos:
- id: check-executables-have-shebangs - id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable - id: check-shebang-scripts-are-executable
- repo: https://github.com/codespell-project/codespell - repo: https://github.com/codespell-project/codespell
rev: v2.2.6 rev: v2.3.0
hooks: hooks:
- id: codespell - id: codespell
exclude: '\.dbc$' 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 - repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0 rev: v1.11.1
hooks: hooks:
- id: mypy - id: mypy
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.2 rev: v0.5.7
hooks: hooks:
- id: ruff - id: ruff
- repo: https://github.com/MarcoGorelli/cython-lint - repo: https://github.com/MarcoGorelli/cython-lint

View File

@ -22,7 +22,7 @@ class TestCanChecksums:
checksum_std = [11, 10, 9, 8] checksum_std = [11, 10, 9, 8]
checksum_ext = [4, 3, 2, 1] 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 = [ msgs = [
packer.make_can_msg("LKAS_HUD", 0, values), packer.make_can_msg("LKAS_HUD", 0, values),
packer.make_can_msg("LKAS_HUD_A", 0, values), packer.make_can_msg("LKAS_HUD_A", 0, values),

View File

@ -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') dbc_file_out.write('CM_ "AUTOGENERATED FILE, DO NOT EDIT";\n')
for include_filename in includes: 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) dbc_file_out.write(include_file_header)
include_file = read_dbc(src_dir, include_filename) include_file = read_dbc(src_dir, include_filename)
dbc_file_out.write(include_file) 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) core_dbc = include_pattern.sub('', dbc_file_in)
dbc_file_out.write(core_dbc) dbc_file_out.write(core_dbc)

View File

@ -9,19 +9,48 @@ requires-python = ">=3.9"
urls = { "homepage" = "https://github.com/commaai/opendbc" } 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] [tool.cython-lint]
max-line-length = 120 max-line-length = 120
ignore = ["E111", "E114"] ignore = ["E111", "E114"]
[tool.mypy] [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 explicit_package_bases=true
# https://beta.ruff.rs/docs/configuration/#using-pyprojecttoml # https://beta.ruff.rs/docs/configuration/#using-pyprojecttoml
[tool.ruff] [tool.ruff]
line-length = 160 line-length = 160
indent-width = 2
target-version="py311" target-version="py311"
[tool.ruff.lint] [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"] ignore = ["W292", "E741", "E402", "C408", "ISC003"]
flake8-implicit-str-concat.allow-multiline=false flake8-implicit-str-concat.allow-multiline=false