From 9f7aa004865c4cdf4cc0c5b13d086da3205a2eed Mon Sep 17 00:00:00 2001 From: Thomas Franks Date: Thu, 30 Jun 2022 17:22:32 -0400 Subject: [PATCH 1/3] fixed annotations issues --- adafruit_thermistor.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/adafruit_thermistor.py b/adafruit_thermistor.py index 3d4685e..d20a177 100644 --- a/adafruit_thermistor.py +++ b/adafruit_thermistor.py @@ -39,6 +39,7 @@ import math import analogio +import microcontroller __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Thermistor.git" @@ -85,13 +86,13 @@ class Thermistor: def __init__( self, - pin, - series_resistor, - nominal_resistance, - nominal_temperature, - b_coefficient, + pin: microcontroller.pin, + series_resistor: int, + nominal_resistance: int, + nominal_temperature: int, + b_coefficient: int, *, - high_side=True + high_side: bool = True ): # pylint: disable=too-many-arguments self.pin = analogio.AnalogIn(pin) From b0f63e243e2affdf2a770e5bb43aac5e8821b3de Mon Sep 17 00:00:00 2001 From: Thomas Franks Date: Sun, 3 Jul 2022 19:43:35 -0400 Subject: [PATCH 2/3] annotated __init__, resistance(self), temperature(self) --- adafruit_thermistor.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/adafruit_thermistor.py b/adafruit_thermistor.py index d20a177..9fef9b9 100644 --- a/adafruit_thermistor.py +++ b/adafruit_thermistor.py @@ -39,7 +39,11 @@ import math import analogio -import microcontroller +try: + import typing # pylint: disable=unused-import + import microcontroller +except ImportError: + pass __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Thermistor.git" @@ -86,14 +90,14 @@ class Thermistor: def __init__( self, - pin: microcontroller.pin, + pin: microcontroller.Pin, series_resistor: int, nominal_resistance: int, nominal_temperature: int, b_coefficient: int, *, high_side: bool = True - ): + ) -> None: # pylint: disable=too-many-arguments self.pin = analogio.AnalogIn(pin) self.series_resistor = series_resistor @@ -103,7 +107,7 @@ def __init__( self.high_side = high_side @property - def resistance(self): + def resistance(self) -> float: """The resistance of the thermistor in Ohms""" if self.high_side: # Thermistor connected from analog input to high logic level. @@ -116,7 +120,7 @@ def resistance(self): return reading @property - def temperature(self): + def temperature(self) -> float: """The temperature of the thermistor in Celsius""" steinhart = self.resistance / self.nominal_resistance # (R/Ro) steinhart = math.log(steinhart) # ln(R/Ro) From b1d199676df46279f926ec884755cb2bd45194b6 Mon Sep 17 00:00:00 2001 From: Thomas Franks Date: Sun, 3 Jul 2022 19:58:59 -0400 Subject: [PATCH 3/3] and black formatting --- adafruit_thermistor.py | 1 + 1 file changed, 1 insertion(+) diff --git a/adafruit_thermistor.py b/adafruit_thermistor.py index 9fef9b9..d39fb23 100644 --- a/adafruit_thermistor.py +++ b/adafruit_thermistor.py @@ -39,6 +39,7 @@ import math import analogio + try: import typing # pylint: disable=unused-import import microcontroller