Skip to content

Commit 9bea68c

Browse files
committed
doc(mypy): Additional type annotations
1 parent cd0f5a7 commit 9bea68c

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

adafruit_ssd1306.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
import adafruit_framebuf as framebuf
2323

2424
try:
25-
from typing import Any, Optional
25+
# Used only for typing
26+
from typing import Optional
27+
import busio
28+
import digitalio
2629
except ImportError:
2730
pass
2831

@@ -61,7 +64,7 @@ def __init__(
6164
height: int,
6265
*,
6366
external_vcc: bool,
64-
reset: Any,
67+
reset: Optional[digitalio.DigitalInOut],
6568
page_addressing: bool
6669
):
6770
super().__init__(buffer, width, height)
@@ -175,7 +178,7 @@ def write_framebuf(self) -> None:
175178
"""Derived class must implement this"""
176179
raise NotImplementedError
177180

178-
def write_cmd(self, cmd: Any) -> None:
181+
def write_cmd(self, cmd: int) -> None:
179182
"""Derived class must implement this"""
180183
raise NotImplementedError
181184

@@ -226,11 +229,11 @@ def __init__(
226229
self,
227230
width: int,
228231
height: int,
229-
i2c: Any,
232+
i2c: busio.I2C,
230233
*,
231234
addr: int = 0x3C,
232235
external_vcc: bool = False,
233-
reset: Any = None,
236+
reset: Optional[digitalio.DigitalInOut] = None,
234237
page_addressing: bool = False
235238
):
236239
self.i2c_device = i2c_device.I2CDevice(i2c, addr)
@@ -297,10 +300,10 @@ def __init__(
297300
self,
298301
width: int,
299302
height: int,
300-
spi: Any,
301-
dc: Any,
302-
reset: bool,
303-
cs: int,
303+
spi: busio.SPI,
304+
dc: digitalio.DigitalInOut,
305+
reset: Optional[digitalio.DigitalInOut],
306+
cs: digitalio.DigitalInOut,
304307
*,
305308
external_vcc: bool = False,
306309
baudrate: int = 8000000,

0 commit comments

Comments
 (0)