Skip to content

Commit 49c5fcf

Browse files
committed
Shrink keyboard.py mpy size
* Use list[usb_hid.Device] allows getting rid of typing import. * can then make `import usb_hid` unconditional This decreases the mpy-cross size of the file to 1186 bytes, smaller than the baseline of 1191 bytes before this PR. (down from 1234 bytes)
1 parent 7c417db commit 49c5fcf

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

adafruit_hid/keyboard.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@
1111

1212
import time
1313
from micropython import const
14+
import usb_hid
1415

1516
from .keycode import Keycode
1617

1718
from . import find_device
1819

19-
try:
20-
from typing import Sequence
21-
import usb_hid
22-
except ImportError:
23-
pass
2420

2521
_MAX_KEYPRESSES = const(6)
2622

@@ -39,7 +35,7 @@ class Keyboard:
3935

4036
# No more than _MAX_KEYPRESSES regular keys may be pressed at once.
4137

42-
def __init__(self, devices: Sequence[usb_hid.Device]) -> None:
38+
def __init__(self, devices: list[usb_hid.Device]) -> None:
4339
"""Create a Keyboard object that will send keyboard HID reports.
4440
4541
Devices can be a sequence of devices that includes a keyboard device or a keyboard device

0 commit comments

Comments
 (0)