Fix mypy issues

This commit is contained in:
Odd Stråbø 2023-12-09 16:35:45 +01:00
parent 8282ec3956
commit 457e7cf8a3
10 changed files with 56 additions and 50 deletions

View file

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
import os
import sys
from io import RawIOBase
from typing import List
sys.path.insert(1, os.path.dirname(os.path.dirname(sys.argv[0])))
@ -9,10 +8,11 @@ sys.path.insert(1, os.path.dirname(os.path.dirname(sys.argv[0])))
from draw_memory_map import memory_table # noqa: E402
from srnemqtt.config import get_config, get_interface # noqa: E402
from srnemqtt.interfaces import BaseInterface # noqa: E402
from srnemqtt.protocol import readMemory # noqa: E402
def get_device_name(iface: RawIOBase) -> str | None:
def get_device_name(iface: BaseInterface) -> str | None:
data = readMemory(iface, 0x0C, 8)
if data is None:
return None
@ -20,7 +20,7 @@ def get_device_name(iface: RawIOBase) -> str | None:
return data.decode("utf-8").strip()
def get_device_version(iface: RawIOBase) -> str | None:
def get_device_version(iface: BaseInterface) -> str | None:
data = readMemory(iface, 0x14, 4)
if data is None:
return None
@ -32,7 +32,7 @@ def get_device_version(iface: RawIOBase) -> str | None:
return f"{major}.{minor}.{patch}"
def get_device_serial(iface: RawIOBase) -> str | None:
def get_device_serial(iface: BaseInterface) -> str | None:
data = readMemory(iface, 0x18, 3)
if data is None:
return None

View file

@ -11,7 +11,8 @@ sys.path.insert(1, os.path.dirname(os.path.dirname(sys.argv[0])))
# from srnemqtt.lib.feasycom_ble import BTLEUart
from srnemqtt.protocol import construct_request, write # noqa: E402
for rate in [1200, 2400, 4800, 9600, 115200]:
# for rate in [1200, 2400, 4800, 9600, 115200]:
for rate in [9600]:
print(rate)
with Serial("/dev/ttyUSB0", baudrate=rate, timeout=2) as x:
sleep(2)