Skip to content

Commit 253522f

Browse files
committed
added changes per reviewer comments
1 parent 09bbf56 commit 253522f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

adafruit_htu31d.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class HTU31D:
9898

9999
def __init__(self, i2c_bus: I2C, address: int = _HTU31D_DEFAULT_ADDR) -> None:
100100
if address not in _HTU31D_ADDRESSES:
101-
raise ValueError("Invalid address: {address:#x}")
101+
raise ValueError(f"Invalid address: {address:#x}")
102102
self.i2c_device = i2c_device.I2CDevice(i2c_bus, address)
103103
self._conversion_command = _HTU31D_CONVERSION
104104
self._buffer = bytearray(6)
@@ -111,7 +111,7 @@ def serial_number(self) -> int:
111111
with self.i2c_device as i2c:
112112
i2c.write_then_readinto(self._buffer, self._buffer, out_end=1, in_end=4)
113113
ser = struct.unpack(">I", self._buffer[0:4])
114-
return ser
114+
return ser[0]
115115

116116
def reset(self) -> None:
117117
"""Perform a soft reset of the sensor, resetting all settings to their power-on defaults"""
@@ -128,8 +128,8 @@ def heater(self) -> bool:
128128

129129
@heater.setter
130130
def heater(self, new_mode: bool) -> None:
131-
# check its a boolean
132-
if not new_mode in (True, False):
131+
# check it is a boolean
132+
if not isinstance(new_mode, bool):
133133
raise AttributeError("Heater mode must be boolean")
134134
# cache the mode
135135
self._heater = new_mode

0 commit comments

Comments
 (0)