mirror of
https://github.com/infiniteCable2/panda.git
synced 2026-02-18 17:23:52 +08:00
fixes for mypy check for return-any
This commit is contained in:
@@ -8,6 +8,7 @@ import time
|
||||
import traceback
|
||||
import sys
|
||||
from functools import wraps
|
||||
from typing import Optional
|
||||
from .dfu import PandaDFU, MCU_TYPE_F2, MCU_TYPE_F4, MCU_TYPE_H7 # pylint: disable=import-error
|
||||
from .flash_release import flash_release # noqa pylint: disable=import-error
|
||||
from .update import ensure_st_up_to_date # noqa pylint: disable=import-error
|
||||
@@ -120,7 +121,7 @@ class ALTERNATIVE_EXPERIENCE:
|
||||
DISABLE_STOCK_AEB = 2
|
||||
RAISE_LONGITUDINAL_LIMITS_TO_ISO_MAX = 8
|
||||
|
||||
class Panda(object):
|
||||
class Panda:
|
||||
|
||||
# matches cereal.car.CarParams.SafetyModel
|
||||
SAFETY_SILENT = 0
|
||||
@@ -195,7 +196,7 @@ class Panda(object):
|
||||
FLAG_TESLA_POWERTRAIN = 1
|
||||
FLAG_TESLA_LONG_CONTROL = 2
|
||||
|
||||
def __init__(self, serial=None, claim=True):
|
||||
def __init__(self, serial: Optional[str] = None, claim: bool = True):
|
||||
self._serial = serial
|
||||
self._handle = None
|
||||
self.connect(claim)
|
||||
@@ -215,7 +216,7 @@ class Panda(object):
|
||||
while 1:
|
||||
try:
|
||||
for device in context.getDeviceList(skip_on_error=True):
|
||||
if device.getVendorID() == 0xbbaa and device.getProductID() in [0xddcc, 0xddee]:
|
||||
if device.getVendorID() == 0xbbaa and device.getProductID() in (0xddcc, 0xddee):
|
||||
try:
|
||||
this_serial = device.getSerialNumber()
|
||||
except Exception:
|
||||
@@ -225,7 +226,7 @@ class Panda(object):
|
||||
print("opening device", self._serial, hex(device.getProductID()))
|
||||
self.bootstub = device.getProductID() == 0xddee
|
||||
self._handle = device.open()
|
||||
if sys.platform not in ["win32", "cygwin", "msys", "darwin"]:
|
||||
if sys.platform not in ("win32", "cygwin", "msys", "darwin"):
|
||||
self._handle.setAutoDetachKernelDriver(True)
|
||||
if claim:
|
||||
self._handle.claimInterface(0)
|
||||
@@ -328,7 +329,7 @@ class Panda(object):
|
||||
if reconnect:
|
||||
self.reconnect()
|
||||
|
||||
def recover(self, timeout=None, reset=True):
|
||||
def recover(self, timeout: Optional[int] = None, reset: bool = True) -> bool:
|
||||
if reset:
|
||||
self.reset(enter_bootstub=True)
|
||||
self.reset(enter_bootloader=True)
|
||||
@@ -354,7 +355,7 @@ class Panda(object):
|
||||
ret = []
|
||||
try:
|
||||
for device in context.getDeviceList(skip_on_error=True):
|
||||
if device.getVendorID() == 0xbbaa and device.getProductID() in [0xddcc, 0xddee]:
|
||||
if device.getVendorID() == 0xbbaa and device.getProductID() in (0xddcc, 0xddee):
|
||||
try:
|
||||
ret.append(device.getSerialNumber())
|
||||
except Exception:
|
||||
@@ -409,7 +410,7 @@ class Panda(object):
|
||||
return self._handle.controlRead(Panda.REQUEST_IN, 0xd6, 0, 0, 0x40).decode('utf8')
|
||||
|
||||
@staticmethod
|
||||
def get_signature_from_firmware(fn):
|
||||
def get_signature_from_firmware(fn) -> bytes:
|
||||
f = open(fn, 'rb')
|
||||
f.seek(-128, 2) # Seek from end of file
|
||||
return f.read(128)
|
||||
@@ -465,11 +466,11 @@ class Panda(object):
|
||||
def has_obd(self):
|
||||
return (self.is_uno() or self.is_dos() or self.is_black() or self.is_red())
|
||||
|
||||
def has_canfd(self):
|
||||
def has_canfd(self) -> bool:
|
||||
return self.get_type() in Panda.H7_DEVICES
|
||||
|
||||
def is_internal(self):
|
||||
return self.get_type() in [Panda.HW_TYPE_UNO, Panda.HW_TYPE_DOS]
|
||||
def is_internal(self) -> bool:
|
||||
return self.get_type() in (Panda.HW_TYPE_UNO, Panda.HW_TYPE_DOS)
|
||||
|
||||
def get_serial(self):
|
||||
dat = self._handle.controlRead(Panda.REQUEST_IN, 0xd0, 0, 0, 0x20)
|
||||
@@ -511,7 +512,7 @@ class Panda(object):
|
||||
# TODO: check panda type
|
||||
if bus is None:
|
||||
self._handle.controlWrite(Panda.REQUEST_OUT, 0xdb, 0, 0, b'')
|
||||
elif bus in [Panda.GMLAN_CAN2, Panda.GMLAN_CAN3]:
|
||||
elif bus in (Panda.GMLAN_CAN2, Panda.GMLAN_CAN3):
|
||||
self._handle.controlWrite(Panda.REQUEST_OUT, 0xdb, 1, bus, b'')
|
||||
|
||||
def set_obd(self, obd):
|
||||
|
||||
Reference in New Issue
Block a user