Skip to content

Commit 7ff2617

Browse files
committed
Add typing and required imports
1 parent 82e49db commit 7ff2617

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

adafruit_pcf8523.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class is inherited by the chip-specific subclasses.
5151
from adafruit_register import i2c_bits
5252
from adafruit_register import i2c_bcd_alarm
5353
from adafruit_register import i2c_bcd_datetime
54+
from busio import I2C
55+
from time import struct_time
5456

5557
STANDARD_BATTERY_SWITCHOVER_AND_DETECTION = 0b000
5658
BATTERY_SWITCHOVER_OFF = 0b111
@@ -136,7 +138,7 @@ class PCF8523:
136138
"""Calibration offset to apply, from -64 to +63. See the PCF8523 datasheet
137139
figure 18 for the offset calibration calculation workflow."""
138140

139-
def __init__(self, i2c_bus):
141+
def __init__(self, i2c_bus: I2C):
140142
self.i2c_device = I2CDevice(i2c_bus, 0x68)
141143

142144
# Try and verify this is the RTC we expect by checking the timer B
@@ -151,13 +153,13 @@ def __init__(self, i2c_bus):
151153
raise ValueError("Unable to find PCF8523 at i2c address 0x68.")
152154

153155
@property
154-
def datetime(self):
156+
def datetime(self) -> struct_time:
155157
"""Gets the current date and time or sets the current date and time then starts the
156158
clock."""
157159
return self.datetime_register
158160

159161
@datetime.setter
160-
def datetime(self, value):
162+
def datetime(self, value: struct_time):
161163
# Automatically sets lost_power to false.
162164
self.power_management = STANDARD_BATTERY_SWITCHOVER_AND_DETECTION
163165
self.datetime_register = value

0 commit comments

Comments
 (0)