Skip to content

Commit

Permalink
Make excepts more specific
Browse files Browse the repository at this point in the history
Switch from generic Exception to RuntimeError or OSError (the two I got while debugging this issue) to pass the pylint process checking
  • Loading branch information
DemiVis committed Dec 15, 2023
1 parent 928f574 commit ae80695
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions adafruit_ahtx0.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,18 @@ def calibrate(self) -> bool:
try:
# Newer AHT20's may not succeed with old command, so wrapping in try/except
i2c.write(self._buf, start=0, end=3)
except Exception: # pylint: disable=broad-except
except (RuntimeError, OSError):
calibration_failed = True

if calibration_failed:
# try another calibration command for newer AHT20's
# print("Calibration failed, trying AH20 command")
time.sleep(0.01)
self._buf[0] = AHT20_CMD_CALIBRATE
with self.i2c_device as i2c:
try:
i2c.write(self._buf, start=0, end=3)
except Exception:
except (RuntimeError, OSError):
pass

while self.status & AHTX0_STATUS_BUSY:
Expand Down

0 comments on commit ae80695

Please sign in to comment.