Skip to content

Commit ae80695

Browse files
committed
Make excepts more specific
Switch from generic Exception to RuntimeError or OSError (the two I got while debugging this issue) to pass the pylint process checking
1 parent 928f574 commit ae80695

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

adafruit_ahtx0.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,18 @@ def calibrate(self) -> bool:
116116
try:
117117
# Newer AHT20's may not succeed with old command, so wrapping in try/except
118118
i2c.write(self._buf, start=0, end=3)
119-
except Exception: # pylint: disable=broad-except
119+
except (RuntimeError, OSError):
120120
calibration_failed = True
121121

122122
if calibration_failed:
123123
# try another calibration command for newer AHT20's
124+
# print("Calibration failed, trying AH20 command")
124125
time.sleep(0.01)
125126
self._buf[0] = AHT20_CMD_CALIBRATE
126127
with self.i2c_device as i2c:
127128
try:
128129
i2c.write(self._buf, start=0, end=3)
129-
except Exception:
130+
except (RuntimeError, OSError):
130131
pass
131132

132133
while self.status & AHTX0_STATUS_BUSY:

0 commit comments

Comments
 (0)