enable numpy mypy typing (#24387)
* enable numpy mypy typing
* remove --warn-return-any
* merge conflict and syntax
* merge conflict
* merge conflict
* add type to img var
old-commit-hash: 603942ffe0
This commit is contained in:
parent
a5ed9358a5
commit
11b9cb9fb5
|
@ -20,12 +20,11 @@ repos:
|
|||
hooks:
|
||||
- id: mypy
|
||||
exclude: '^(pyextra/)|(cereal/)|(rednose/)|(panda/)|(laika/)|(opendbc/)|(laika_repo/)|(rednose_repo/)/'
|
||||
additional_dependencies: ['git+https://github.com/numpy/numpy-stubs', 'types-requests', 'types-atomicwrites',
|
||||
'types-pycurl', 'types-certifi', 'lxml']
|
||||
additional_dependencies: ['lxml', 'numpy', 'types-atomicwrites', 'types-pycurl', 'types-requests', 'types-certifi']
|
||||
args:
|
||||
- --warn-unused-ignores
|
||||
- --warn-redundant-casts
|
||||
- --warn-unreachable
|
||||
- --warn-unused-ignores
|
||||
#- --html-report=/home/batman/openpilot
|
||||
- repo: https://github.com/PyCQA/flake8
|
||||
rev: 4.0.1
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# pylint: skip-file
|
||||
import numpy as np
|
||||
from typing import Callable
|
||||
|
||||
from common.transformations.transformations import (ecef_euler_from_ned_single,
|
||||
euler2quat_single,
|
||||
|
@ -11,7 +12,7 @@ from common.transformations.transformations import (ecef_euler_from_ned_single,
|
|||
rot2quat_single)
|
||||
|
||||
|
||||
def numpy_wrap(function, input_shape, output_shape):
|
||||
def numpy_wrap(function, input_shape, output_shape) -> Callable[..., np.ndarray]:
|
||||
"""Wrap a function to take either an input or list of inputs and return the correct shape"""
|
||||
def f(*inps):
|
||||
*args, inp = inps
|
||||
|
|
|
@ -2,7 +2,7 @@ import sys
|
|||
import pygame # pylint: disable=import-error
|
||||
import cv2 # pylint: disable=import-error
|
||||
|
||||
class Window():
|
||||
class Window:
|
||||
def __init__(self, w, h, caption="window", double=False, halve=False):
|
||||
self.w = w
|
||||
self.h = h
|
||||
|
@ -54,7 +54,7 @@ class Window():
|
|||
if __name__ == "__main__":
|
||||
import numpy as np
|
||||
win = Window(200, 200, double=True)
|
||||
img = np.zeros((200, 200, 3), np.uint8)
|
||||
img: np.ndarray = np.zeros((200, 200, 3), np.uint8)
|
||||
while 1:
|
||||
print("draw")
|
||||
img += 1
|
||||
|
|
Loading…
Reference in New Issue