From 77509c9bc1bb6da06447155c6f6e5333d0b77418 Mon Sep 17 00:00:00 2001 From: Thomas Franks Date: Tue, 20 Sep 2022 11:01:58 -0400 Subject: [PATCH 1/3] Add Missing Type Annotations --- adafruit_max31855.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/adafruit_max31855.py b/adafruit_max31855.py index 3734567..3ba7c72 100644 --- a/adafruit_max31855.py +++ b/adafruit_max31855.py @@ -32,6 +32,13 @@ from adafruit_bus_device.spi_device import SPIDevice +try: + import typing # pylint: disable=unused-import + from digitalio import DigitalInOut + from board import SPI +except ImportError: + pass + __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MAX31855.git" @@ -71,11 +78,11 @@ class MAX31855: temperature = sensor.temperature """ - def __init__(self, spi, cs): + def __init__(self, spi: SPI, cs: DigitalInOut) -> None: self.spi_device = SPIDevice(spi, cs) self.data = bytearray(4) - def _read(self, internal=False): + def _read(self, internal: bool = False) -> int: with self.spi_device as spi: spi.readinto(self.data) # pylint: disable=no-member if self.data[3] & 0x01: @@ -94,17 +101,17 @@ def _read(self, internal=False): return temp @property - def temperature(self): + def temperature(self) -> float: """Thermocouple temperature in degrees Celsius.""" return self._read() / 4 @property - def reference_temperature(self): + def reference_temperature(self) -> float: """Internal reference temperature in degrees Celsius.""" return self._read(True) * 0.0625 @property - def temperature_NIST(self): + def temperature_NIST(self) -> float: """ Thermocouple temperature in degrees Celsius, computed using raw voltages and NIST approximation for Type K, see: @@ -187,7 +194,7 @@ def temperature_NIST(self): ) else: raise RuntimeError( - "Total thermoelectric voltage out of range:{}".format(VTOTAL) + f"Total thermoelectric voltage out of range:{VTOTAL}" ) # compute temperature TEMPERATURE = 0 From f7519fde67c7e3b52c9036955edccd2fc1d8eb5e Mon Sep 17 00:00:00 2001 From: Thomas Franks Date: Tue, 20 Sep 2022 12:54:47 -0400 Subject: [PATCH 2/3] redo precommit to reformat file --- adafruit_max31855.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/adafruit_max31855.py b/adafruit_max31855.py index 3ba7c72..4e2719d 100644 --- a/adafruit_max31855.py +++ b/adafruit_max31855.py @@ -193,9 +193,7 @@ def temperature_NIST(self) -> float: -3.110810e-08, ) else: - raise RuntimeError( - f"Total thermoelectric voltage out of range:{VTOTAL}" - ) + raise RuntimeError(f"Total thermoelectric voltage out of range:{VTOTAL}") # compute temperature TEMPERATURE = 0 for n, c in enumerate(DCOEF): From 8d86a7e96b5c637b98f1d821655570aff55b6039 Mon Sep 17 00:00:00 2001 From: Thomas Franks Date: Tue, 20 Sep 2022 12:59:28 -0400 Subject: [PATCH 3/3] fix spi error --- adafruit_max31855.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_max31855.py b/adafruit_max31855.py index 4e2719d..8bbc162 100644 --- a/adafruit_max31855.py +++ b/adafruit_max31855.py @@ -35,7 +35,7 @@ try: import typing # pylint: disable=unused-import from digitalio import DigitalInOut - from board import SPI + from busio import SPI except ImportError: pass