Skip to content

Commit

Permalink
drivers/sensor/mcp9808: Fixed regression made by ruff suggestions.
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
MarcoMiano committed Jan 1, 2025
1 parent ae8ee51 commit ce1e03f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions micropython/drivers/sensor/mcp9808/mcp9808.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
Microchip MCP9808 driver for MicroPython v.1.0.0
Microchip MCP9808 driver for MicroPython
THE MCP9808 IS A COMPLEX SENSOR WITH MANY FEATURES. IS IT ADVISABLE TO READ THE DATASHEET.
Expand Down Expand Up @@ -243,35 +243,35 @@ def _set_config(
# Type/value check the parameters
if hyst_mode not in [HYST_00, HYST_15, HYST_30, HYST_60]:
raise ValueError(f"hyst_mode: {hyst_mode}. Value should be between 0 and 3 inclusive.")
if shdn is not bool:
if shdn.__class__ is not bool:
raise TypeError(
f"shdn: {shdn} {shdn.__class__}. Expecting a bool.",
)
if crit_lock is not bool:
if crit_lock.__class__ is not bool:
raise TypeError(
f"crit_lock: {crit_lock} {crit_lock.__class__}. Expecting a bool.",
)
if alerts_lock is not bool:
if alerts_lock.__class__ is not bool:
raise TypeError(
f"alerts_lock: {alerts_lock} {alerts_lock.__class__}. Expecting a bool.",
)
if irq_clear_bit is not bool:
if irq_clear_bit.__class__ is not bool:
raise TypeError(
f"irq_clear_bit: {irq_clear_bit} {irq_clear_bit.__class__}. Expecting a bool.",
)
if alert_ctrl is not bool:
if alert_ctrl.__class__ is not bool:
raise TypeError(
f"alert_ctrl: {alert_ctrl} {alert_ctrl.__class__}. Expecting a bool.",
)
if alert_sel is not bool:
if alert_sel.__class__ is not bool:
raise TypeError(
f"alert_sel: {alert_sel} {alert_sel.__class__}. Expecting a bool.",
)
if alert_pol is not bool:
if alert_pol.__class__ is not bool:
raise TypeError(
f"alert_pol: {alert_pol} {alert_pol.__class__}. Expecting a bool.",
)
if alert_mode is not bool:
if alert_mode.__class__ is not bool:
raise TypeError(
f"alert_mode: {alert_mode} {alert_mode.__class__}. Expecting a bool.",
)
Expand Down Expand Up @@ -346,7 +346,7 @@ def _set_alert_limit(self, limit: float, register: int) -> None:
``None``
"""

if limit.__class__ not in [float]:
if limit.__class__ not in [float, int]:
raise TypeError(
f"limit: {limit} {limit.__class__}. Expecting float|int.",
)
Expand Down

0 comments on commit ce1e03f

Please sign in to comment.