Skip to content

[#18] Add type annotations #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions adafruit_ntp.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
import time
import rtc

try:
# Used only for typing
import typing # pylint: disable=unused-import
from adafruit_esp32spi.adafruit_esp32spi import ESP_SPIcontrol
except ImportError:
pass

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_NTP.git"

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

def __init__(self, esp, debug=False):
def __init__(self, esp: ESP_SPIcontrol, debug: bool = False) -> None:
# Verify ESP32SPI module
if "ESP_SPIcontrol" in str(type(esp)):
self._esp = esp
Expand All @@ -43,7 +50,7 @@ def __init__(self, esp, debug=False):
self.valid_time = False
self.debug = debug

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

Expand Down