Skip to content

Commit

Permalink
Fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbruno25 committed Jul 19, 2024
1 parent 9744920 commit e759b97
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/can_explorer/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import enum

import can
from can.bus import BusABC

from can_explorer.configs import Default
from can_explorer.models import PlotModel
Expand All @@ -19,7 +20,7 @@ def __init__(
self,
model: PlotModel,
view: MainView,
bus: can.bus.BusABC | None = None,
bus: BusABC | None = None,
refresh_rate: float | None = Default.REFRESH_RATE,
) -> None:
self.model = model
Expand All @@ -35,15 +36,15 @@ def state(self) -> State:
return self._state

@property
def bus(self) -> can.bus.BusABC | None:
def bus(self) -> BusABC:
if self._bus is None:
raise RuntimeError("Must apply settings before starting")
return self._bus

def is_active(self) -> bool:
return bool(self.state)

def set_bus(self, bus: can.BusABC) -> None:
def set_bus(self, bus: BusABC) -> None:
"""
Set CAN bus to use during controller loop.
"""
Expand Down
3 changes: 2 additions & 1 deletion src/can_explorer/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections import defaultdict, deque
from typing import DefaultDict

import can

Expand All @@ -22,7 +23,7 @@ def __getitem__(self, index) -> tuple: # type: ignore [override]

class PlotModel:
def __init__(self) -> None:
self._data = defaultdict(PayloadBuffer)
self._data: DefaultDict[int, PayloadBuffer] = defaultdict(PayloadBuffer)
self._len = Default.BUFFER_SIZE

def add_message(self, message: can.Message) -> None:
Expand Down

0 comments on commit e759b97

Please sign in to comment.