diff --git a/adafruit_pcf8523.py b/adafruit_pcf8523.py index 8837ab8..90cb3b2 100644 --- a/adafruit_pcf8523.py +++ b/adafruit_pcf8523.py @@ -52,6 +52,13 @@ class is inherited by the chip-specific subclasses. from adafruit_register import i2c_bcd_alarm from adafruit_register import i2c_bcd_datetime +try: + import typing # pylint: disable=unused-import + from busio import I2C + from time import struct_time +except ImportError: + pass + STANDARD_BATTERY_SWITCHOVER_AND_DETECTION = 0b000 BATTERY_SWITCHOVER_OFF = 0b111 @@ -136,7 +143,7 @@ class PCF8523: """Calibration offset to apply, from -64 to +63. See the PCF8523 datasheet figure 18 for the offset calibration calculation workflow.""" - def __init__(self, i2c_bus): + def __init__(self, i2c_bus: I2C): self.i2c_device = I2CDevice(i2c_bus, 0x68) # Try and verify this is the RTC we expect by checking the timer B @@ -151,13 +158,13 @@ def __init__(self, i2c_bus): raise ValueError("Unable to find PCF8523 at i2c address 0x68.") @property - def datetime(self): + def datetime(self) -> struct_time: """Gets the current date and time or sets the current date and time then starts the clock.""" return self.datetime_register @datetime.setter - def datetime(self, value): + def datetime(self, value: struct_time): # Automatically sets lost_power to false. self.power_management = STANDARD_BATTERY_SWITCHOVER_AND_DETECTION self.datetime_register = value