Abstract classes inherit from ABC (#23246)

pull/23251/head
Willem Melching 3 years ago committed by GitHub
parent 55390d273f
commit 14bf834fef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      selfdrive/car/interfaces.py
  2. 4
      selfdrive/hardware/base.py

@ -1,6 +1,6 @@
import os import os
import time import time
from abc import abstractmethod from abc import abstractmethod, ABC
from typing import Dict, Tuple, List from typing import Dict, Tuple, List
from cereal import car from cereal import car
@ -23,7 +23,7 @@ ACCEL_MIN = -3.5
# generic car and radar interfaces # generic car and radar interfaces
class CarInterfaceBase(): class CarInterfaceBase(ABC):
def __init__(self, CP, CarController, CarState): def __init__(self, CP, CarController, CarState):
self.CP = CP self.CP = CP
self.VM = VehicleModel(CP) self.VM = VehicleModel(CP)
@ -170,7 +170,7 @@ class CarInterfaceBase():
return events return events
class RadarInterfaceBase(): class RadarInterfaceBase(ABC):
def __init__(self, CP): def __init__(self, CP):
self.pts = {} self.pts = {}
self.delay = 0 self.delay = 0
@ -184,7 +184,7 @@ class RadarInterfaceBase():
return ret return ret
class CarStateBase: class CarStateBase(ABC):
def __init__(self, CP): def __init__(self, CP):
self.CP = CP self.CP = CP
self.car_fingerprint = CP.carFingerprint self.car_fingerprint = CP.carFingerprint

@ -1,9 +1,9 @@
from abc import abstractmethod from abc import abstractmethod, ABC
from collections import namedtuple from collections import namedtuple
ThermalConfig = namedtuple('ThermalConfig', ['cpu', 'gpu', 'mem', 'bat', 'ambient', 'pmic']) ThermalConfig = namedtuple('ThermalConfig', ['cpu', 'gpu', 'mem', 'bat', 'ambient', 'pmic'])
class HardwareBase: class HardwareBase(ABC):
@staticmethod @staticmethod
def get_cmdline(): def get_cmdline():
with open('/proc/cmdline') as f: with open('/proc/cmdline') as f:

Loading…
Cancel
Save