Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ce1e03f

Browse files
committedJan 1, 2025··
drivers/sensor/mcp9808: Fixed regression made by ruff suggestions.
ruff suggest to use .isinstance() to check class type but bool doen't have .isinstance() method. ruff suggest to use only float in some places but i don't like it the code should be more flexible. Signed-off-by: MarcoMiano <[email protected]>
1 parent ae8ee51 commit ce1e03f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed
 

‎micropython/drivers/sensor/mcp9808/mcp9808.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
2424
2525
26-
Microchip MCP9808 driver for MicroPython v.1.0.0
26+
Microchip MCP9808 driver for MicroPython
2727
2828
THE MCP9808 IS A COMPLEX SENSOR WITH MANY FEATURES. IS IT ADVISABLE TO READ THE DATASHEET.
2929
@@ -243,35 +243,35 @@ def _set_config(
243243
# Type/value check the parameters
244244
if hyst_mode not in [HYST_00, HYST_15, HYST_30, HYST_60]:
245245
raise ValueError(f"hyst_mode: {hyst_mode}. Value should be between 0 and 3 inclusive.")
246-
if shdn is not bool:
246+
if shdn.__class__ is not bool:
247247
raise TypeError(
248248
f"shdn: {shdn} {shdn.__class__}. Expecting a bool.",
249249
)
250-
if crit_lock is not bool:
250+
if crit_lock.__class__ is not bool:
251251
raise TypeError(
252252
f"crit_lock: {crit_lock} {crit_lock.__class__}. Expecting a bool.",
253253
)
254-
if alerts_lock is not bool:
254+
if alerts_lock.__class__ is not bool:
255255
raise TypeError(
256256
f"alerts_lock: {alerts_lock} {alerts_lock.__class__}. Expecting a bool.",
257257
)
258-
if irq_clear_bit is not bool:
258+
if irq_clear_bit.__class__ is not bool:
259259
raise TypeError(
260260
f"irq_clear_bit: {irq_clear_bit} {irq_clear_bit.__class__}. Expecting a bool.",
261261
)
262-
if alert_ctrl is not bool:
262+
if alert_ctrl.__class__ is not bool:
263263
raise TypeError(
264264
f"alert_ctrl: {alert_ctrl} {alert_ctrl.__class__}. Expecting a bool.",
265265
)
266-
if alert_sel is not bool:
266+
if alert_sel.__class__ is not bool:
267267
raise TypeError(
268268
f"alert_sel: {alert_sel} {alert_sel.__class__}. Expecting a bool.",
269269
)
270-
if alert_pol is not bool:
270+
if alert_pol.__class__ is not bool:
271271
raise TypeError(
272272
f"alert_pol: {alert_pol} {alert_pol.__class__}. Expecting a bool.",
273273
)
274-
if alert_mode is not bool:
274+
if alert_mode.__class__ is not bool:
275275
raise TypeError(
276276
f"alert_mode: {alert_mode} {alert_mode.__class__}. Expecting a bool.",
277277
)
@@ -346,7 +346,7 @@ def _set_alert_limit(self, limit: float, register: int) -> None:
346346
``None``
347347
"""
348348

349-
if limit.__class__ not in [float]:
349+
if limit.__class__ not in [float, int]:
350350
raise TypeError(
351351
f"limit: {limit} {limit.__class__}. Expecting float|int.",
352352
)

0 commit comments

Comments
 (0)
Please sign in to comment.