From 7b4870dacf32ff5f32f8bbe5a059288cd3a79356 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Sun, 20 Mar 2022 13:14:44 -0400 Subject: [PATCH 1/2] Add type annotations, docstring params --- adafruit_pcf8563.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/adafruit_pcf8563.py b/adafruit_pcf8563.py index 52cf49a..d7175ee 100644 --- a/adafruit_pcf8563.py +++ b/adafruit_pcf8563.py @@ -49,9 +49,18 @@ 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 +except ImportError: + pass + class PCF8563: - """Interface to the PCF8563 RTC.""" + """Interface to the PCF8563 RTC. + + :param I2C i2c_bus: The I2C bus object + """ datetime_compromised = i2c_bit.RWBit(0x2, 7) """True if the clock integrity is compromised.""" @@ -74,7 +83,7 @@ class PCF8563: alarm_status = i2c_bit.RWBit(0x01, 3) """True if alarm is alarming. Set to False to reset.""" - def __init__(self, i2c_bus): + def __init__(self, i2c_bus: I2C) -> None: time.sleep(0.05) self.i2c_device = I2CDevice(i2c_bus, 0x51) @@ -87,13 +96,13 @@ def __init__(self, i2c_bus): i2c.write_then_readinto(buf, buf, out_end=1, in_start=1) @property - def datetime(self): + def datetime(self) -> time.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: time.struct_time) -> None: # Automatically sets lost_power to false. self.datetime_register = value self.datetime_compromised = False From 25db3d1bb5820317e6ae47bc9f710cb27a3d5063 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Sun, 20 Mar 2022 13:15:18 -0400 Subject: [PATCH 2/2] Reformatted per pre-commit --- adafruit_pcf8563.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_pcf8563.py b/adafruit_pcf8563.py index d7175ee..9f67de1 100644 --- a/adafruit_pcf8563.py +++ b/adafruit_pcf8563.py @@ -58,7 +58,7 @@ class is inherited by the chip-specific subclasses. class PCF8563: """Interface to the PCF8563 RTC. - + :param I2C i2c_bus: The I2C bus object """