configure mypy outside of pre-commit environment (#25892)

* add mypy config matching precommit

* use local mypy, add files to config

* excludes too

* fix config

* pylint is sad now... did it get updated?

* fix typing hints

* ignore

* this should be a regexp

* mypy doesn't like Deque despite inheriting MutableSequence

* more excludes

* Revert "pylint is sad now... did it get updated?"

This reverts commit 250c632f18.
old-commit-hash: 4e310b807f
taco
Cameron Clough 3 years ago committed by GitHub
parent 8a828af454
commit 23a4e66b17
  1. 16
      .pre-commit-config.yaml
  2. 4
      Pipfile
  3. 4
      Pipfile.lock
  4. 2
      common/realtime.py
  5. 14
      mypy.ini
  6. 4
      selfdrive/debug/check_freq.py
  7. 4
      selfdrive/debug/check_timings.py
  8. 1
      system/hardware/tici/casync.py

@ -24,18 +24,14 @@ repos:
# if you've got a short variable name that's getting flagged, add it here
- -L bu,ro,te,ue,alo,hda,ois,nam,nams,ned,som,parm,setts,inout,warmup
- --builtins clear,rare,informal,usage,code,names,en-GB_to_en-US
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.931
- repo: local
hooks:
- id: mypy
exclude: '^(pyextra/)|(cereal/)|(rednose/)|(panda/)|(laika/)|(opendbc/)|(laika_repo/)|(rednose_repo/)/|(tinygrad/)|(tinygrad_repo/)'
additional_dependencies: ['types-PyYAML', 'lxml', 'numpy', 'types-atomicwrites', 'types-pycurl', 'types-requests', 'types-certifi']
args:
- --warn-redundant-casts
- --warn-return-any
- --warn-unreachable
- --warn-unused-ignores
#- --html-report=/home/batman/openpilot
name: mypy
entry: mypy
language: system
types: [python]
exclude: '^(pyextra/)|(cereal/)|(panda/)|(laika/)|(laika_repo/)|(rednose/)|(rednose_repo/)|(tinygrad/)|(tinygrad_repo/)'
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5fea746328dc90e4e1542a334508feda0616b2d19d7904f33a3ecfff2b1a6f79
size 1621
oid sha256:67078d38037d44571e909dee2288c4fe9f7a1cc3691fe3165c1628ff3d19cde6
size 1736

4
Pipfile.lock generated

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7d093d32dfcaf18972f9c62a0b87dc470ee0d74304ca8d659fc142ee0176b7c5
size 188750
oid sha256:848091d4b13abe8c0c97c997fc8641953e1685582560a45841bac625eb0991b4
size 205318

@ -31,7 +31,7 @@ class Priority:
def set_realtime_priority(level: int) -> None:
if not PC:
os.sched_setscheduler(0, os.SCHED_FIFO, os.sched_param(level)) # type: ignore[attr-defined] # pylint: disable=no-member
os.sched_setscheduler(0, os.SCHED_FIFO, os.sched_param(level)) # pylint: disable=no-member
def set_core_affinity(cores: List[int]) -> None:

@ -1,4 +1,16 @@
[mypy]
python_version = 3.8
ignore_missing_imports = True
plugins = numpy.typing.mypy_plugin
files = body, common, docs, scripts, selfdrive, site_scons, system, tools
exclude = ^(pyextra/)|(cereal/)|(opendbc/)|(panda/)|(laika/)|(laika_repo/)|(rednose/)|(rednose_repo/)|(tinygrad/)|(tinygrad_repo/)|(xx/)
; third-party packages
ignore_missing_imports = True
; helpful warnings
warn_redundant_casts = True
warn_unreachable = True
warn_unused_ignores = True
; restrict dynamic typing
warn_return_any = True

@ -2,7 +2,7 @@
import argparse
import numpy as np
from collections import defaultdict, deque
from typing import DefaultDict, Deque
from typing import DefaultDict, Deque, MutableSequence
from common.realtime import sec_since_boot
import cereal.messaging as messaging
@ -19,7 +19,7 @@ if __name__ == "__main__":
socket_names = args.socket
sockets = {}
rcv_times: DefaultDict[str, Deque[float]] = defaultdict(lambda: deque(maxlen=100))
rcv_times: DefaultDict[str, MutableSequence[float]] = defaultdict(lambda: deque(maxlen=100))
valids: DefaultDict[str, Deque[bool]] = defaultdict(lambda: deque(maxlen=100))
t = sec_since_boot()

@ -3,13 +3,13 @@
import sys
import time
import numpy as np
from typing import DefaultDict, Deque
from typing import DefaultDict, MutableSequence
from collections import defaultdict, deque
import cereal.messaging as messaging
socks = {s: messaging.sub_sock(s, conflate=False) for s in sys.argv[1:]}
ts: DefaultDict[str, Deque[float]] = defaultdict(lambda: deque(maxlen=100))
ts: DefaultDict[str, MutableSequence[float]] = defaultdict(lambda: deque(maxlen=100))
if __name__ == "__main__":
while True:

@ -86,6 +86,7 @@ class RemoteChunkReader(ChunkReader):
def parse_caibx(caibx_path: str) -> List[Chunk]:
"""Parses the chunks from a caibx file. Can handle both local and remote files.
Returns a list of chunks with hash, offset and length"""
caibx: io.BufferedIOBase
if os.path.isfile(caibx_path):
caibx = open(caibx_path, 'rb')
else:

Loading…
Cancel
Save