diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b853523e42..b50a586507 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,7 +33,7 @@ repos: - -L bu,ro,te,ue,alo,hda,ois,nam,nams,ned,som,parm,setts,inout,warmup,bumb,nd,sie,preints,whit,indexIn - --builtins clear,rare,informal,usage,code,names,en-GB_to_en-US - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.10 + rev: v0.5.0 hooks: - id: ruff exclude: '^(third_party/)|(msgq/)|(panda/)|(rednose/)|(rednose_repo/)|(tinygrad/)|(tinygrad_repo/)|(teleoprtc/)|(teleoprtc_repo/)' diff --git a/pyproject.toml b/pyproject.toml index df4fdd760d..a300021c38 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -209,7 +209,8 @@ lint.select = [ "UP", # pyupgrade "TRY302", "TRY400", "TRY401", # try/excepts "RUF008", "RUF100", - "TID251" + "TID251", + "PLR1704", ] lint.ignore = [ "E741", diff --git a/selfdrive/debug/can_printer.py b/selfdrive/debug/can_printer.py index 220008979d..b93e48ba73 100755 --- a/selfdrive/debug/can_printer.py +++ b/selfdrive/debug/can_printer.py @@ -23,12 +23,12 @@ def can_printer(bus, max_msg, addr, ascii_decode): if time.monotonic() - lp > 0.1: dd = chr(27) + "[2J" dd += f"{time.monotonic() - start:5.2f}\n" - for addr in sorted(msgs.keys()): - a = f"\"{msgs[addr][-1].decode('ascii', 'backslashreplace')}\"" if ascii_decode else "" - x = binascii.hexlify(msgs[addr][-1]).decode('ascii') - freq = len(msgs[addr]) / (time.monotonic() - start) - if max_msg is None or addr < max_msg: - dd += "%04X(%4d)(%6d)(%3dHz) %s %s\n" % (addr, addr, len(msgs[addr]), freq, x.ljust(20), a) + for _addr in sorted(msgs.keys()): + a = f"\"{msgs[_addr][-1].decode('ascii', 'backslashreplace')}\"" if ascii_decode else "" + x = binascii.hexlify(msgs[_addr][-1]).decode('ascii') + freq = len(msgs[_addr]) / (time.monotonic() - start) + if max_msg is None or _addr < max_msg: + dd += "%04X(%4d)(%6d)(%3dHz) %s %s\n" % (_addr, _addr, len(msgs[_addr]), freq, x.ljust(20), a) print(dd) lp = time.monotonic()