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.
pull/25914/head
Cameron Clough 3 years ago committed by GitHub
parent 96ed5aa581
commit 4e310b807f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      .pre-commit-config.yaml
  2. 6
      Pipfile
  3. 1051
      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 # 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 - -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 - --builtins clear,rare,informal,usage,code,names,en-GB_to_en-US
- repo: https://github.com/pre-commit/mirrors-mypy - repo: local
rev: v0.931
hooks: hooks:
- id: mypy - id: mypy
exclude: '^(pyextra/)|(cereal/)|(rednose/)|(panda/)|(laika/)|(opendbc/)|(laika_repo/)|(rednose_repo/)/|(tinygrad/)|(tinygrad_repo/)' name: mypy
additional_dependencies: ['types-PyYAML', 'lxml', 'numpy', 'types-atomicwrites', 'types-pycurl', 'types-requests', 'types-certifi'] entry: mypy
args: language: system
- --warn-redundant-casts types: [python]
- --warn-return-any exclude: '^(pyextra/)|(cereal/)|(panda/)|(laika/)|(laika_repo/)|(rednose/)|(rednose_repo/)|(tinygrad/)|(tinygrad_repo/)'
- --warn-unreachable
- --warn-unused-ignores
#- --html-report=/home/batman/openpilot
- repo: https://github.com/PyCQA/flake8 - repo: https://github.com/PyCQA/flake8
rev: 4.0.1 rev: 4.0.1
hooks: hooks:

@ -43,6 +43,12 @@ carla = {version = "==0.9.13", markers="platform_system != 'Darwin'"}
ft4222 = "*" ft4222 = "*"
pandas = "*" pandas = "*"
tabulate = "*" tabulate = "*"
types-pyyaml = "*"
lxml = "*"
types-atomicwrites = "*"
types-pycurl = "*"
types-requests = "*"
types-certifi = "*"
[packages] [packages]
atomicwrites = "*" atomicwrites = "*"

1051
Pipfile.lock generated

File diff suppressed because it is too large Load Diff

@ -31,7 +31,7 @@ class Priority:
def set_realtime_priority(level: int) -> None: def set_realtime_priority(level: int) -> None:
if not PC: 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: def set_core_affinity(cores: List[int]) -> None:

@ -1,4 +1,16 @@
[mypy] [mypy]
python_version = 3.8 python_version = 3.8
ignore_missing_imports = True
plugins = numpy.typing.mypy_plugin 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 argparse
import numpy as np import numpy as np
from collections import defaultdict, deque from collections import defaultdict, deque
from typing import DefaultDict, Deque from typing import DefaultDict, Deque, MutableSequence
from common.realtime import sec_since_boot from common.realtime import sec_since_boot
import cereal.messaging as messaging import cereal.messaging as messaging
@ -19,7 +19,7 @@ if __name__ == "__main__":
socket_names = args.socket socket_names = args.socket
sockets = {} 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)) valids: DefaultDict[str, Deque[bool]] = defaultdict(lambda: deque(maxlen=100))
t = sec_since_boot() t = sec_since_boot()

@ -3,13 +3,13 @@
import sys import sys
import time import time
import numpy as np import numpy as np
from typing import DefaultDict, Deque from typing import DefaultDict, MutableSequence
from collections import defaultdict, deque from collections import defaultdict, deque
import cereal.messaging as messaging import cereal.messaging as messaging
socks = {s: messaging.sub_sock(s, conflate=False) for s in sys.argv[1:]} 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__": if __name__ == "__main__":
while True: while True:

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

Loading…
Cancel
Save