Skip to content

Commit b08454f

Browse files
authored
Merge pull request #19 from process1183/type_annotations
[#18] Add type annotations
2 parents 97fae39 + 434e796 commit b08454f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

adafruit_ntp.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
import time
2323
import rtc
2424

25+
try:
26+
# Used only for typing
27+
import typing # pylint: disable=unused-import
28+
from adafruit_esp32spi.adafruit_esp32spi import ESP_SPIcontrol
29+
except ImportError:
30+
pass
31+
2532
__version__ = "0.0.0-auto.0"
2633
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_NTP.git"
2734

@@ -34,7 +41,7 @@ class NTP:
3441
:param bool debug: Set to True to output set_time() failures to console
3542
"""
3643

37-
def __init__(self, esp, debug=False):
44+
def __init__(self, esp: ESP_SPIcontrol, debug: bool = False) -> None:
3845
# Verify ESP32SPI module
3946
if "ESP_SPIcontrol" in str(type(esp)):
4047
self._esp = esp
@@ -43,7 +50,7 @@ def __init__(self, esp, debug=False):
4350
self.valid_time = False
4451
self.debug = debug
4552

46-
def set_time(self, tz_offset=0):
53+
def set_time(self, tz_offset: int = 0) -> None:
4754
"""Fetches and sets the microcontroller's current time
4855
in seconds since since Jan 1, 1970.
4956

0 commit comments

Comments
 (0)