attempt to merge sofubi/static-type-checking, albeit incompletely

This commit is contained in:
Josh Klar
2021-09-27 15:22:23 -07:00
23 changed files with 1436 additions and 290 deletions

View File

@@ -1,11 +1,29 @@
import sys
from time import sleep
from kmk.consts import TYPING_PLATFORMS
if sys.platform in TYPING_PLATFORMS:
from typing import Any, Optional
from kmk.keys import Key, KeyAttrDict
from kmk.kmk_keyboard import KMKKeyboard # Avoid cyclical imports
def passthrough(key, keyboard, *args, **kwargs):
return keyboard
def default_pressed(key, keyboard, KC, coord_int=None, coord_raw=None, *args, **kwargs):
def default_pressed(
key, # type: Key
keyboard, # type: KMKKeyboard
KC, # type: KeyAttrDict
coord_int=None, # type: Optional[int]
coord_raw=None, # type: Optional[str]
*args, # type: Any
**kwargs, # type: Any
):
# type: (...) -> KMKKeyboard
keyboard.hid_pending = True
keyboard.keys_pressed.add(key)
@@ -14,8 +32,15 @@ def default_pressed(key, keyboard, KC, coord_int=None, coord_raw=None, *args, **
def default_released(
key, keyboard, KC, coord_int=None, coord_raw=None, *args, **kwargs # NOQA
key, # type: Key
keyboard, # type: KMKKeyboard
KC, # type: KeyAttrDict
coord_int=None, # type: Optional[int]
coord_raw=None, # type: Optional[str]
*args, # type: Any
**kwargs, # type: Any # NOQA
):
# type: (...) -> KMKKeyboard
keyboard.hid_pending = True
keyboard.keys_pressed.discard(key)