Skip to content

Commit 3816a4f

Browse files
authored
Merge pull request #20 from tcfranks/main
fixed annotations issues
2 parents 0c3a5ec + b1d1996 commit 3816a4f

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

adafruit_thermistor.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
import math
4141
import analogio
4242

43+
try:
44+
import typing # pylint: disable=unused-import
45+
import microcontroller
46+
except ImportError:
47+
pass
48+
4349
__version__ = "0.0.0-auto.0"
4450
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Thermistor.git"
4551

@@ -85,14 +91,14 @@ class Thermistor:
8591

8692
def __init__(
8793
self,
88-
pin,
89-
series_resistor,
90-
nominal_resistance,
91-
nominal_temperature,
92-
b_coefficient,
94+
pin: microcontroller.Pin,
95+
series_resistor: int,
96+
nominal_resistance: int,
97+
nominal_temperature: int,
98+
b_coefficient: int,
9399
*,
94-
high_side=True
95-
):
100+
high_side: bool = True
101+
) -> None:
96102
# pylint: disable=too-many-arguments
97103
self.pin = analogio.AnalogIn(pin)
98104
self.series_resistor = series_resistor
@@ -102,7 +108,7 @@ def __init__(
102108
self.high_side = high_side
103109

104110
@property
105-
def resistance(self):
111+
def resistance(self) -> float:
106112
"""The resistance of the thermistor in Ohms"""
107113
if self.high_side:
108114
# Thermistor connected from analog input to high logic level.
@@ -115,7 +121,7 @@ def resistance(self):
115121
return reading
116122

117123
@property
118-
def temperature(self):
124+
def temperature(self) -> float:
119125
"""The temperature of the thermistor in Celsius"""
120126
steinhart = self.resistance / self.nominal_resistance # (R/Ro)
121127
steinhart = math.log(steinhart) # ln(R/Ro)

0 commit comments

Comments
 (0)