diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24bfef3..152dcca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: uses: actions/cache@v4 with: path: ~/.cache/pip - key: ${{ runner.os }}-3.8-${{ hashFiles('requirements.txt') }} + key: ${{ runner.os }}-3.8-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('requirements.txt') }} - name: Update pip run: pip install .[extra] - name: Check formatting with Black diff --git a/pybldc/pybldc.py b/pybldc/pybldc.py index 19fe70f..057a699 100644 --- a/pybldc/pybldc.py +++ b/pybldc/pybldc.py @@ -313,7 +313,7 @@ def reset(self) -> None: def _wait_for_packet_response( self, - packet_queue: queue.Queue[List[int]], + packet_queue: queue.Queue, comm_packet_id: CommPacketId, expected_response: List[int], timeout: float, @@ -329,7 +329,7 @@ def _wait_for_packet_response( return False try: - response = packet_queue.get(timeout=timeout - dt) + response: List[int] = packet_queue.get(timeout=timeout - dt) self._logger.debug(f"PyBldcBase: Received packet response: {response}, expected: {expected_response}") # Make sure it replies with the command as the first byte and "OK" as the second byte @@ -350,7 +350,7 @@ def __init__(self, can_id: int, controller_id: int, logger: logging.Logger) -> N self._controller_id = controller_id self._logger = logger self._is_stopped = False - self.packet_queue: queue.Queue[List[int]] = queue.Queue() + self.packet_queue: queue.Queue = queue.Queue() self.pong_event = threading.Event() self._hw_type: Optional[HwType] = None @@ -524,7 +524,7 @@ def __init__( # Open the serial port, but read from it in a thread, so we are not blocking the main loop self._serial = serial.Serial(port=port, baudrate=baudrate, timeout=0.5, exclusive=True) self._shutdown_thread = threading.Event() - self._packet_queue: queue.Queue[List[int]] = queue.Queue() + self._packet_queue: queue.Queue = queue.Queue() self._thread = threading.Thread( target=self._serial_read_thread, name="_serial_read_thread", @@ -596,7 +596,7 @@ def _serial_read_thread( ser: Any, shutdown_event: threading.Event, logger: logging.Logger, - packet_queue: queue.Queue[List[int]], + packet_queue: queue.Queue, ) -> None: try: data_buffer = bytearray() @@ -745,6 +745,7 @@ def cli() -> None: "-b", "--baudrate", "--bitrate", + type=int, help="The baudrate/bitrate to use for serial/can (defaults to 115200 for serial and 500000 for CAN)", ) optional.add_argument(