Skip to content

Commit 773730c

Browse files
authored
Merge pull request #4 from tekktrik/doc/add-typing
Add type annotations
2 parents a5953e9 + 25db3d1 commit 773730c

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

adafruit_pcf8563.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,18 @@ class is inherited by the chip-specific subclasses.
4949
from adafruit_register import i2c_bcd_alarm
5050
from adafruit_register import i2c_bcd_datetime
5151

52+
try:
53+
import typing # pylint: disable=unused-import
54+
from busio import I2C
55+
except ImportError:
56+
pass
57+
5258

5359
class PCF8563:
54-
"""Interface to the PCF8563 RTC."""
60+
"""Interface to the PCF8563 RTC.
61+
62+
:param I2C i2c_bus: The I2C bus object
63+
"""
5564

5665
datetime_compromised = i2c_bit.RWBit(0x2, 7)
5766
"""True if the clock integrity is compromised."""
@@ -74,7 +83,7 @@ class PCF8563:
7483
alarm_status = i2c_bit.RWBit(0x01, 3)
7584
"""True if alarm is alarming. Set to False to reset."""
7685

77-
def __init__(self, i2c_bus):
86+
def __init__(self, i2c_bus: I2C) -> None:
7887
time.sleep(0.05)
7988
self.i2c_device = I2CDevice(i2c_bus, 0x51)
8089

@@ -87,13 +96,13 @@ def __init__(self, i2c_bus):
8796
i2c.write_then_readinto(buf, buf, out_end=1, in_start=1)
8897

8998
@property
90-
def datetime(self):
99+
def datetime(self) -> time.struct_time:
91100
"""Gets the current date and time or sets the current date and time then starts the
92101
clock."""
93102
return self.datetime_register
94103

95104
@datetime.setter
96-
def datetime(self, value):
105+
def datetime(self, value: time.struct_time) -> None:
97106
# Automatically sets lost_power to false.
98107
self.datetime_register = value
99108
self.datetime_compromised = False

0 commit comments

Comments
 (0)