Add types to validators, time, types
Update pyproject.toml to ignore boards, user_keymaps for mypy Update pyproject.toml to reduce loud mypy reporting
This commit is contained in:
parent
2c69d0e197
commit
75f9d10cc7
@ -7,7 +7,7 @@ from kmk.types import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def key_seq_sleep_validator(ms):
|
def key_seq_sleep_validator(ms: float) -> KeySeqSleepMeta:
|
||||||
return KeySeqSleepMeta(ms)
|
return KeySeqSleepMeta(ms)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
def sleep_ms(ms):
|
def sleep_ms(ms: float) -> None:
|
||||||
return time.sleep(ms / 1000)
|
return time.sleep(ms / 1000)
|
||||||
|
|
||||||
|
|
||||||
def ticks_ms():
|
def ticks_ms() -> float:
|
||||||
'''Has .25s granularity, but is cheap'''
|
'''Has .25s granularity, but is cheap'''
|
||||||
return time.monotonic() * 1000
|
return time.monotonic() * 1000
|
||||||
|
|
||||||
|
|
||||||
def ticks_diff(new, old):
|
def ticks_diff(new: float, old: float) -> float:
|
||||||
return new - old
|
return new - old
|
||||||
|
|
||||||
|
|
||||||
def accurate_ticks():
|
def accurate_ticks() -> int:
|
||||||
'''Is more expensive, but good for time critical things'''
|
'''Is more expensive, but good for time critical things'''
|
||||||
return time.monotonic_ns()
|
return time.monotonic_ns()
|
||||||
|
|
||||||
|
|
||||||
def accurate_ticks_diff(new, old, ms):
|
def accurate_ticks_diff(new: float, old: float, ms: float) -> bool:
|
||||||
return bool(new - old < ms * 1000000)
|
return bool(new - old < ms * 1000000)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
from typing import List, Optional, Tuple
|
||||||
|
|
||||||
from kmk.consts import UnicodeMode
|
from kmk.consts import UnicodeMode
|
||||||
from kmk.keys import KeyAttrDict
|
from kmk.keys import KeyAttrDict
|
||||||
from typing import List, Optional
|
|
||||||
|
|
||||||
|
|
||||||
class AttrDict(dict):
|
class AttrDict(dict):
|
||||||
@ -23,8 +24,8 @@ class LayerKeyMeta:
|
|||||||
|
|
||||||
|
|
||||||
class ModTapKeyMeta:
|
class ModTapKeyMeta:
|
||||||
def __init__(self, kc: Optional[KeyAttrDict] = None, mods: Optional[List[KeyAttrDict]] = None):
|
def __init__(self, kc: Optional[KeyAttrDict] = None, mods: Optional[List[KeyAttrDict]] = None) -> None:
|
||||||
self.mods: Optional[List[KeyAttrDict]] = mods
|
self.mods: Optional[List[KeyAttrDict]] = mods
|
||||||
self.kc: Optional[KeyAttrDict] = kc
|
self.kc: Optional[KeyAttrDict] = kc
|
||||||
|
|
||||||
|
|
||||||
@ -44,5 +45,5 @@ class UnicodeModeKeyMeta:
|
|||||||
|
|
||||||
|
|
||||||
class TapDanceKeyMeta:
|
class TapDanceKeyMeta:
|
||||||
def __init__(self, codes):
|
def __init__(self, codes: Tuple[KeyAttrDict, ...]):
|
||||||
self.codes = codes
|
self.codes = codes
|
||||||
|
@ -28,7 +28,14 @@ include = ["kmk"]
|
|||||||
exclude = [
|
exclude = [
|
||||||
"hardware",
|
"hardware",
|
||||||
".venv",
|
".venv",
|
||||||
"user_keymaps"
|
"user_keymaps",
|
||||||
|
"boards"
|
||||||
]
|
]
|
||||||
reportMissingModuleSource = false
|
reportMissingModuleSource = false
|
||||||
|
# reports missing typestubs allowing for a code action to
|
||||||
|
# create new library typestubs
|
||||||
reportMissingTypeStubs = true
|
reportMissingTypeStubs = true
|
||||||
|
|
||||||
|
[tool.mypy]
|
||||||
|
exclude = "boards/|user_keymaps/"
|
||||||
|
ignore_missing_imports = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user