Finish type annotations for modules folder

Update pyproject.toml
This commit is contained in:
sofubi 2021-08-13 16:00:57 -04:00
parent 317d14fdac
commit 95dcc57e76
7 changed files with 168 additions and 146 deletions

View File

@ -1,3 +1,8 @@
from typing import NoReturn
from kmk.kmk_keyboard import KMKKeyboard
class InvalidExtensionEnvironment(Exception):
pass
@ -12,29 +17,29 @@ class Module:
# The below methods should be implemented by subclasses
def during_bootup(self, keyboard):
def during_bootup(self, keyboard: KMKKeyboard) -> NoReturn:
raise NotImplementedError
def before_matrix_scan(self, keyboard):
def before_matrix_scan(self, keyboard: KMKKeyboard) -> NoReturn:
'''
Return value will be injected as an extra matrix update
'''
raise NotImplementedError
def after_matrix_scan(self, keyboard):
def after_matrix_scan(self, keyboard: KMKKeyboard) -> NoReturn:
'''
Return value will be replace matrix update if supplied
'''
raise NotImplementedError
def before_hid_send(self, keyboard):
def before_hid_send(self, keyboard: KMKKeyboard) -> NoReturn:
raise NotImplementedError
def after_hid_send(self, keyboard):
def after_hid_send(self, keyboard: KMKKeyboard) -> NoReturn:
raise NotImplementedError
def on_powersave_enable(self, keyboard):
def on_powersave_enable(self, keyboard: KMKKeyboard) -> NoReturn:
raise NotImplementedError
def on_powersave_disable(self, keyboard):
def on_powersave_disable(self, keyboard: KMKKeyboard) -> NoReturn:
raise NotImplementedError

View File

@ -1,11 +1,10 @@
import digitalio
from microcontroller import Pin
from typing import Any, Dict, List, Optional, Tuple, Union
from typing import Any, ClassVar, Dict, List, Optional, Tuple, Union
from kmk.keys import KeyAttrDict
from kmk.kmktime import ticks_ms
from kmk.kmk_keyboard import KMKKeyboard
from kmk.kmktime import ticks_ms
from kmk.modules import Module
EncoderMap = Tuple[
@ -28,9 +27,9 @@ class EndcoderDirection:
class Encoder:
def __init__(
self,
pad_a: Pin,
pad_b: Pin,
button_pin: Optional[Pin] = None,
pad_a: Any,
pad_b: Any,
button_pin: Optional[Any] = None,
) -> None:
self.pad_a: Union[digitalio.DigitalInOut, None] = self.PreparePin(
pad_a
@ -94,7 +93,7 @@ class Encoder:
}
# adapted for CircuitPython from raspi
def PreparePin(self, num: Union[Pin, None]) -> Union[digitalio.DigitalInOut, None]:
def PreparePin(self, num: Union[Any, None]) -> Union[digitalio.DigitalInOut, None]:
if num is not None:
pad = digitalio.DigitalInOut(num)
pad.direction = digitalio.Direction.INPUT
@ -181,14 +180,14 @@ class Encoder:
class EncoderHandler(Module):
encoders: List[Encoder] = []
debug_enabled: bool = False # not working as inttended, do not use for now
encoders: ClassVar[List[Encoder]] = []
debug_enabled: ClassVar[bool] = False # not working as inttended, do not use for now
def __init__(
self, pad_a: List[Pin], pad_b: List[Pin], encoder_map: EncoderMap
self, pad_a: List[Any], pad_b: List[Any], encoder_map: EncoderMap
) -> None:
self.pad_a: List[Pin] = pad_a
self.pad_b: List[Pin] = pad_b
self.pad_a: List[Any] = pad_a
self.pad_b: List[Any] = pad_b
self.encoder_count: int = len(self.pad_a)
self.encoder_map: EncoderMap = encoder_map
self.make_encoders()
@ -235,7 +234,9 @@ class EncoderHandler(Module):
)
)
def send_encoder_keys(self, keyboard: KMKKeyboard, encoder_key: int, encoder_idx: int) -> KMKKeyboard:
def send_encoder_keys(
self, keyboard: KMKKeyboard, encoder_key: int, encoder_idx: int
) -> KMKKeyboard:
# position in the encoder map tuple
encoder_resolution = 2
for _ in range(

View File

@ -1,8 +1,11 @@
'''One layer isn't enough. Adds keys to get to more of them'''
from micropython import const
from typing import Any, Dict, Optional
from kmk.key_validators import layer_key_validator
from kmk.keys import make_argumented_key
from kmk.keys import Key, make_argumented_key
from kmk.kmk_keyboard import KMKKeyboard
from kmk.kmktime import accurate_ticks, accurate_ticks_diff
from kmk.modules import Module
@ -10,20 +13,20 @@ from kmk.modules import Module
class LayerType:
'''Defines layer type values for readability'''
MO = const(0)
DF = const(1)
LM = const(2)
LT = const(3)
TG = const(4)
TT = const(5)
MO: int = const(0)
DF: int = const(1)
LM: int = const(2)
LT: int = const(3)
TG: int = const(4)
TT: int = const(5)
class Layers(Module):
'''Gives access to the keys used to enable the layer system'''
def __init__(self):
def __init__(self) -> None:
# Layers
self.start_time = {
self.start_time: Dict[int, Optional[int]] = {
LayerType.LT: None,
LayerType.TG: None,
LayerType.TT: None,
@ -63,41 +66,41 @@ class Layers(Module):
on_release=self._tt_released,
)
def during_bootup(self, keyboard):
def during_bootup(self, keyboard: KMKKeyboard) -> None:
return
def before_matrix_scan(self, keyboard):
def before_matrix_scan(self, keyboard: KMKKeyboard) -> None:
return
def after_matrix_scan(self, keyboard):
def after_matrix_scan(self, keyboard: KMKKeyboard) -> None:
return
def before_hid_send(self, keyboard):
def before_hid_send(self, keyboard: KMKKeyboard) -> None:
return
def after_hid_send(self, keyboard):
def after_hid_send(self, keyboard: KMKKeyboard) -> None:
return
def on_powersave_enable(self, keyboard):
def on_powersave_enable(self, keyboard: KMKKeyboard) -> None:
return
def on_powersave_disable(self, keyboard):
def on_powersave_disable(self, keyboard: KMKKeyboard) -> None:
return
def _df_pressed(self, key, keyboard, *args, **kwargs):
def _df_pressed(self, key: Key, keyboard: KMKKeyboard, *args: Any, **kwargs: Any) -> None:
'''
Switches the default layer
'''
keyboard.active_layers[-1] = key.meta.layer
def _mo_pressed(self, key, keyboard, *args, **kwargs):
def _mo_pressed(self, key: Key, keyboard: KMKKeyboard, *args: Any, **kwargs: Any) -> None:
'''
Momentarily activates layer, switches off when you let go
'''
keyboard.active_layers.insert(0, key.meta.layer)
@staticmethod
def _mo_released(key, keyboard, *args, **kwargs):
def _mo_released(key: Key, keyboard: KMKKeyboard, *args: Any, **kwargs: Any) -> None:
# remove the first instance of the target layer
# from the active list
# under almost all normal use cases, this will
@ -112,7 +115,7 @@ class Layers(Module):
except ValueError:
pass
def _lm_pressed(self, key, keyboard, *args, **kwargs):
def _lm_pressed(self, key: Key, keyboard: KMKKeyboard, *args: Any, **kwargs: Any) -> None:
'''
As MO(layer) but with mod active
'''
@ -121,7 +124,7 @@ class Layers(Module):
keyboard.keys_pressed.add(key.meta.kc)
self._mo_pressed(key, keyboard, *args, **kwargs)
def _lm_released(self, key, keyboard, *args, **kwargs):
def _lm_released(self, key: Key, keyboard: KMKKeyboard, *args: Any, **kwargs: Any) -> None:
'''
As MO(layer) but with mod active
'''
@ -129,12 +132,12 @@ class Layers(Module):
keyboard.keys_pressed.discard(key.meta.kc)
self._mo_released(key, keyboard, *args, **kwargs)
def _lt_pressed(self, key, keyboard, *args, **kwargs):
def _lt_pressed(self, key: Key, keyboard: KMKKeyboard, *args: Any, **kwargs: Any) -> None:
# Sets the timer start and acts like MO otherwise
self.start_time[LayerType.LT] = accurate_ticks()
self._mo_pressed(key, keyboard, *args, **kwargs)
def _lt_released(self, key, keyboard, *args, **kwargs):
def _lt_released(self, key: Key, keyboard: KMKKeyboard, *args: Any, **kwargs: Any) -> None:
# On keyup, check timer, and press key if needed.
if self.start_time[LayerType.LT] and (
accurate_ticks_diff(
@ -147,7 +150,7 @@ class Layers(Module):
self._mo_released(key, keyboard, *args, **kwargs)
self.start_time[LayerType.LT] = None
def _tg_pressed(self, key, keyboard, *args, **kwargs):
def _tg_pressed(self, key: Key, keyboard: KMKKeyboard, *args: Any, **kwargs: Any) -> None:
'''
Toggles the layer (enables it if not active, and vise versa)
'''
@ -158,14 +161,14 @@ class Layers(Module):
except ValueError:
keyboard.active_layers.insert(0, key.meta.layer)
def _to_pressed(self, key, keyboard, *args, **kwargs):
def _to_pressed(self, key: Key, keyboard: KMKKeyboard, *args: Any, **kwargs: Any) -> None:
'''
Activates layer and deactivates all other layers
'''
keyboard.active_layers.clear()
keyboard.active_layers.insert(0, key.meta.layer)
def _tt_pressed(self, key, keyboard, *args, **kwargs):
def _tt_pressed(self, key: Key, keyboard: KMKKeyboard, *args: Any, **kwargs: Any) -> None:
'''
Momentarily activates layer if held, toggles it if tapped repeatedly
'''
@ -181,7 +184,7 @@ class Layers(Module):
return
return
def _tt_released(self, key, keyboard, *args, **kwargs):
def _tt_released(self, key: Key, keyboard: KMKKeyboard, *args: Any, **kwargs: Any) -> None:
if self.start_time[LayerType.TT] is None or not accurate_ticks_diff(
accurate_ticks(), self.start_time[LayerType.TT], keyboard.tap_time
):

View File

@ -1,12 +1,15 @@
from typing import Any, Optional
from kmk.key_validators import mod_tap_validator
from kmk.keys import make_argumented_key
from kmk.keys import Key, make_argumented_key
from kmk.kmk_keyboard import KMKKeyboard
from kmk.kmktime import accurate_ticks, accurate_ticks_diff
from kmk.modules import Module
class ModTap(Module):
def __init__(self):
self._mod_tap_timer = None
def __init__(self) -> None:
self._mod_tap_timer: Optional[int] = None
make_argumented_key(
validator=mod_tap_validator,
names=('MT',),
@ -14,35 +17,35 @@ class ModTap(Module):
on_release=self.mt_released,
)
def during_bootup(self, keyboard):
def during_bootup(self, keyboard: KMKKeyboard) -> None:
return
def before_matrix_scan(self, keyboard):
def before_matrix_scan(self, keyboard: KMKKeyboard) -> None:
return
def after_matrix_scan(self, keyboard):
def after_matrix_scan(self, keyboard: KMKKeyboard) -> None:
return
def before_hid_send(self, keyboard):
def before_hid_send(self, keyboard: KMKKeyboard) -> None:
return
def after_hid_send(self, keyboard):
def after_hid_send(self, keyboard: KMKKeyboard) -> None:
return
def on_powersave_enable(self, keyboard):
def on_powersave_enable(self, keyboard: KMKKeyboard) -> None:
return
def on_powersave_disable(self, keyboard):
def on_powersave_disable(self, keyboard: KMKKeyboard) -> None:
return
def mt_pressed(self, key, keyboard, *args, **kwargs):
def mt_pressed(self, key: Key, keyboard: KMKKeyboard, *args: Any, **kwargs: Any) -> KMKKeyboard:
'''Sets the timer start and acts like a modifier otherwise'''
keyboard.keys_pressed.add(key.meta.mods)
self._mod_tap_timer = accurate_ticks()
return keyboard
def mt_released(self, key, keyboard, *args, **kwargs):
def mt_released(self, key: Key, keyboard: KMKKeyboard, *args: Any, **kwargs: Any) -> KMKKeyboard:
'''On keyup, check timer, and press key if needed.'''
keyboard.keys_pressed.discard(key.meta.mods)
if self._mod_tap_timer and (

View File

@ -1,21 +1,24 @@
from kmk.kmk_keyboard import KMKKeyboard
import board
import digitalio
from typing import Any, Dict, Optional
from kmk.handlers.stock import passthrough as handler_passthrough
from kmk.keys import make_key
from kmk.keys import Key, make_key
from kmk.kmktime import sleep_ms, ticks_diff, ticks_ms
from kmk.modules import Module
class Power(Module):
def __init__(self, powersave_pin=None):
self.enable = False
def __init__(self, powersave_pin: Optional[Any] = None) -> None:
self.enable: bool = False
self.powersave_pin = powersave_pin # Powersave pin board object
self._powersave_start = ticks_ms()
self._usb_last_scan = ticks_ms() - 5000
self._psp = None # Powersave pin object
self._i2c = 0
self._loopcounter = 0
self._powersave_start: float = ticks_ms()
self._usb_last_scan: float = ticks_ms() - 5000
self._psp: Optional[digitalio.DigitalInOut] = None # Powersave pin object
self._i2c: int = 0
self._loopcounter: int = 0
make_key(
names=('PS_TOG',), on_press=self._ps_tog, on_release=handler_passthrough
@ -27,10 +30,10 @@ class Power(Module):
names=('PS_OFF',), on_press=self._ps_disable, on_release=handler_passthrough
)
def __repr__(self):
def __repr__(self) -> str:
return f'Power({self._to_dict()})'
def _to_dict(self):
def _to_dict(self) -> Dict[str, Any]:
return {
'enable': self.enable,
'powersave_pin': self.powersave_pin,
@ -39,24 +42,24 @@ class Power(Module):
'_psp': self._psp,
}
def during_bootup(self, keyboard):
def during_bootup(self, keyboard: KMKKeyboard) -> None:
self._i2c_scan()
def before_matrix_scan(self, keyboard):
def before_matrix_scan(self, keyboard: KMKKeyboard) -> None:
return
def after_matrix_scan(self, keyboard):
def after_matrix_scan(self, keyboard: KMKKeyboard) -> None:
if keyboard.matrix_update or keyboard.secondary_matrix_update:
self.psave_time_reset()
def before_hid_send(self, keyboard):
def before_hid_send(self, keyboard: KMKKeyboard) -> None:
return
def after_hid_send(self, keyboard):
def after_hid_send(self, keyboard: KMKKeyboard) -> None:
if self.enable:
self.psleep()
def on_powersave_enable(self, keyboard):
def on_powersave_enable(self, keyboard: KMKKeyboard) -> None:
'''Gives 10 cycles to allow other extensions to clean up before powersave'''
if self._loopcounter > 10:
self.enable_powersave(keyboard)
@ -65,11 +68,11 @@ class Power(Module):
self._loopcounter += 1
return
def on_powersave_disable(self, keyboard):
def on_powersave_disable(self, keyboard: KMKKeyboard) -> None:
self.disable_powersave(keyboard)
return
def enable_powersave(self, keyboard):
def enable_powersave(self, keyboard: KMKKeyboard) -> None:
'''Enables power saving features'''
if keyboard.i2c_deinit_count >= self._i2c and self.powersave_pin:
# Allows power save to prevent RGB drain.
@ -85,7 +88,7 @@ class Power(Module):
keyboard._trigger_powersave_enable = False
return
def disable_powersave(self, keyboard):
def disable_powersave(self, keyboard: KMKKeyboard) -> None:
'''Disables power saving features'''
if self._psp:
self._psp.value = False
@ -96,7 +99,7 @@ class Power(Module):
self.enable = False
return
def psleep(self):
def psleep(self) -> None:
'''
Sleeps longer and longer to save power the more time in between updates.
'''
@ -106,10 +109,10 @@ class Power(Module):
sleep_ms(180)
return
def psave_time_reset(self):
def psave_time_reset(self) -> None:
self._powersave_start = ticks_ms()
def _i2c_scan(self):
def _i2c_scan(self) -> None:
i2c = board.I2C()
while not i2c.try_lock():
pass
@ -119,28 +122,28 @@ class Power(Module):
i2c.unlock()
return
def usb_rescan_timer(self):
def usb_rescan_timer(self) -> bool:
return bool(ticks_diff(ticks_ms(), self._usb_last_scan) > 5000)
def usb_time_reset(self):
def usb_time_reset(self) -> None:
self._usb_last_scan = ticks_ms()
return
def usb_scan(self):
def usb_scan(self) -> bool:
# TODO Add USB detection here. Currently lies that it's connected
# https://github.com/adafruit/circuitpython/pull/3513
return True
def _ps_tog(self, key, keyboard, *args, **kwargs):
def _ps_tog(self, key: Key, keyboard: KMKKeyboard, *args: Any, **kwargs: Any) -> None:
if self.enable:
keyboard._trigger_powersave_disable = True
else:
keyboard._trigger_powersave_enable = True
def _ps_enable(self, key, keyboard, *args, **kwargs):
def _ps_enable(self, key: Key, keyboard: KMKKeyboard, *args: Any, **kwargs: Any) -> None:
if not self.enable:
keyboard._trigger_powersave_enable = True
def _ps_disable(self, key, keyboard, *args, **kwargs):
def _ps_disable(self, key: Key, keyboard: KMKKeyboard, *args: Any, **kwargs: Any) -> None:
if self.enable:
keyboard._trigger_powersave_disable = True

View File

@ -3,22 +3,26 @@ import busio
from micropython import const
from storage import getmount
from typing import Any, List, Optional, Tuple, Type, Union
from kmk.kmk_keyboard import KMKKeyboard
from kmk.kmktime import ticks_diff, ticks_ms
from kmk.matrix import intify_coordinate
from kmk.modules import Module
UartBuffer = List[Optional[Union[bytes, None]]]
class SplitSide:
LEFT = const(1)
RIGHT = const(2)
LEFT: int = const(1)
RIGHT: int = const(2)
class SplitType:
UART = const(1)
I2C = const(2) # unused
ONEWIRE = const(3) # unused
BLE = const(4)
UART: int = const(1)
I2C: int = const(2) # unused
ONEWIRE: int = const(3) # unused
BLE: int = const(4)
class Split(Module):
@ -26,56 +30,58 @@ class Split(Module):
def __init__(
self,
split_flip=True,
split_side=None,
split_type=SplitType.UART,
split_target_left=True,
uart_interval=20,
data_pin=None,
data_pin2=None,
target_left=True,
uart_flip=True,
debug_enabled=False,
):
self._is_target = True
self._uart_buffer = []
self.split_flip = split_flip
self.split_side = split_side
self.split_type = split_type
self.split_target_left = split_target_left
self.split_offset = None
self.data_pin = data_pin
self.data_pin2 = data_pin2
self.target_left = target_left
self.uart_flip = uart_flip
self._is_target = True
self._uart = None
self._uart_interval = uart_interval
self._debug_enabled = debug_enabled
split_flip: bool = True,
split_side: Optional[int] = None,
split_type: int = SplitType.UART,
split_target_left: bool = True,
uart_interval: int = 20,
data_pin: Optional[Any] = None,
data_pin2: Optional[Any] = None,
target_left: bool = True,
uart_flip: bool = True,
debug_enabled: bool = False,
) -> None:
self._is_target: bool = True
self._uart_buffer: UartBuffer = []
self.split_flip: bool = split_flip
self.split_side: Optional[int] = split_side
self.split_type: int = split_type
self.split_target_left: bool = split_target_left
self.split_offset: Optional[int] = None
self.data_pin: Optional[Any] = data_pin
self.data_pin2: Optional[Any] = data_pin2
self.target_left: bool = target_left
self.uart_flip: bool = uart_flip
self._is_target: bool = True
self._uart: Optional[busio.UART] = None
self._uart_interval: int = uart_interval
self._debug_enabled: bool = debug_enabled
if self.split_type == SplitType.BLE:
try:
from adafruit_ble import BLERadio
from adafruit_ble import BLEConnection, BLERadio
from adafruit_ble.advertising.standard import (
ProvideServicesAdvertisement,
)
from adafruit_ble.services.nordic import UARTService
self.ProvideServicesAdvertisement = ProvideServicesAdvertisement
self.UARTService = UARTService
self.ProvideServicesAdvertisement: Type[
ProvideServicesAdvertisement
] = ProvideServicesAdvertisement
self.UARTService: Type[UARTService] = UARTService
except ImportError:
print('BLE Import error')
return # BLE isn't supported on this platform
self._ble = BLERadio()
self._ble_last_scan = ticks_ms() - 5000
self._connection_count = 0
self._uart_connection = None
self._advertisment = None
self._advertising = False
self._psave_enable = False
self._ble: BLERadio = BLERadio()
self._ble_last_scan: float = ticks_ms() - 5000
self._connection_count: int = 0
self._uart_connection: Optional[BLEConnection] = None
self._advertisment: Optional[ProvideServicesAdvertisement] = None
self._advertising: bool = False
self._psave_enable: bool = False
def during_bootup(self, keyboard):
def during_bootup(self, keyboard: KMKKeyboard) -> None:
# Set up name for target side detection and BLE advertisment
name = str(getmount('/').label)
name: str = str(getmount('/').label)
if self.split_type == SplitType.BLE:
self._ble.name = name
else:
@ -127,7 +133,7 @@ class Split(Module):
for cidx in range(cols_to_calc):
keyboard.coord_mapping.append(intify_coordinate(ridx, cidx))
def before_matrix_scan(self, keyboard):
def before_matrix_scan(self, keyboard: KMKKeyboard) -> None:
if self.split_type == SplitType.BLE:
self._check_all_connections()
self._receive_ble(keyboard)
@ -138,7 +144,7 @@ class Split(Module):
pass # Protocol needs written
return
def after_matrix_scan(self, keyboard):
def after_matrix_scan(self, keyboard: KMKKeyboard) -> None:
if keyboard.matrix_update:
if self.split_type == SplitType.UART and self._is_target:
pass # explicit pass just for dev sanity...
@ -155,28 +161,28 @@ class Split(Module):
return
def before_hid_send(self, keyboard):
def before_hid_send(self, keyboard: KMKKeyboard) -> None:
if not self._is_target:
keyboard.hid_pending = False
return
def after_hid_send(self, keyboard):
def after_hid_send(self, keyboard: KMKKeyboard) -> None:
return
def on_powersave_enable(self, keyboard):
def on_powersave_enable(self, keyboard: KMKKeyboard) -> None:
if self.split_type == SplitType.BLE:
if self._uart_connection and not self._psave_enable:
self._uart_connection.connection_interval = self._uart_interval
self._psave_enable = True
def on_powersave_disable(self, keyboard):
def on_powersave_disable(self, keyboard: KMKKeyboard) -> None:
if self.split_type == SplitType.BLE:
if self._uart_connection and self._psave_enable:
self._uart_connection.connection_interval = 11.25
self._psave_enable = False
def _check_all_connections(self):
def _check_all_connections(self) -> None:
'''Validates the correct number of BLE connections'''
self._connection_count = len(self._ble.connections)
if self._is_target and self._connection_count < 2:
@ -184,7 +190,7 @@ class Split(Module):
elif not self._is_target and self._connection_count < 1:
self._initiator_scan()
def _initiator_scan(self):
def _initiator_scan(self) -> None:
'''Scans for target device'''
self._uart = None
self._uart_connection = None
@ -217,7 +223,7 @@ class Split(Module):
break
self._ble.stop_scan()
def _target_advertise(self):
def _target_advertise(self) -> None:
'''Advertises the target for the initiator to find'''
self._ble.stop_advertising()
if self._debug_enabled:
@ -239,15 +245,15 @@ class Split(Module):
break
self._ble.stop_advertising()
def ble_rescan_timer(self):
def ble_rescan_timer(self) -> bool:
'''If true, the rescan timer is up'''
return bool(ticks_diff(ticks_ms(), self._ble_last_scan) > 5000)
def ble_time_reset(self):
def ble_time_reset(self) -> None:
'''Resets the rescan timer'''
self._ble_last_scan = ticks_ms()
def _send_ble(self, update):
def _send_ble(self, update: List) -> None:
if self._uart:
try:
if not self._is_target:
@ -265,7 +271,7 @@ class Split(Module):
self._uart_connection = None
self._uart = None
def _receive_ble(self, keyboard):
def _receive_ble(self, keyboard: KMKKeyboard) -> None:
if self._uart is not None and self._uart.in_waiting > 0 or self._uart_buffer:
while self._uart.in_waiting >= 3:
self._uart_buffer.append(self._uart.read(3))
@ -273,7 +279,7 @@ class Split(Module):
keyboard.secondary_matrix_update = bytearray(self._uart_buffer.pop(0))
return
def _send_uart(self, update):
def _send_uart(self, update: List) -> None:
# Change offsets depending on where the data is going to match the correct
# matrix location of the receiever
if self._is_target:
@ -290,7 +296,7 @@ class Split(Module):
if self._uart is not None:
self._uart.write(update)
def _receive_uart(self, keyboard):
def _receive_uart(self, keyboard: KMKKeyboard) -> None:
if self._uart is not None and self._uart.in_waiting > 0 or self._uart_buffer:
if self._uart.in_waiting >= 60:
# This is a dirty hack to prevent crashes in unrealistic cases

View File

@ -31,3 +31,4 @@ exclude = [
"user_keymaps"
]
reportMissingModuleSource = false
reportMissingTypeStubs = true