mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 20:03:53 +08:00
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 250c632f18ecb3d33ffb931e15425f9314a0964b.
This commit is contained in:
@@ -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:
|
||||
|
||||
6
Pipfile
6
Pipfile
@@ -43,6 +43,12 @@ carla = {version = "==0.9.13", markers="platform_system != 'Darwin'"}
|
||||
ft4222 = "*"
|
||||
pandas = "*"
|
||||
tabulate = "*"
|
||||
types-pyyaml = "*"
|
||||
lxml = "*"
|
||||
types-atomicwrites = "*"
|
||||
types-pycurl = "*"
|
||||
types-requests = "*"
|
||||
types-certifi = "*"
|
||||
|
||||
[packages]
|
||||
atomicwrites = "*"
|
||||
|
||||
1011
Pipfile.lock
generated
1011
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:
|
||||
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:
|
||||
|
||||
14
mypy.ini
14
mypy.ini
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user