Skip to content

Commit a1c2c03

Browse files
committed
added Literal definitions as suggested and fixed pylint issues
1 parent 37fec22 commit a1c2c03

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

adafruit_max31856.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
try:
3636
from typing import Dict, Tuple
37+
from typing_extensions import Literal
3738
from busio import SPI
3839
from digitalio import DigitalInOut
3940
except ImportError:
@@ -206,7 +207,7 @@ def averaging(self, num_samples: int) -> None:
206207
self._write_u8(_MAX31856_CR1_REG, conf_reg_1)
207208

208209
@property
209-
def noise_rejection(self) -> int:
210+
def noise_rejection(self) -> Literal[50, 60]:
210211
"""
211212
The frequency (Hz) to be used by the noise rejection filter.
212213
Must be 50 or 60. Default is 60."""
@@ -217,7 +218,7 @@ def noise_rejection(self) -> int:
217218
return 60
218219

219220
@noise_rejection.setter
220-
def noise_rejection(self, frequency: int) -> None:
221+
def noise_rejection(self, frequency: Literal[50, 60]) -> None:
221222
conf_reg_0 = self._read_register(_MAX31856_CR0_REG, 1)[0]
222223
if frequency == 50:
223224
conf_reg_0 |= _MAX31856_CR0_50HZ # set the 50hz bit
@@ -290,7 +291,7 @@ def temperature_thresholds(self, val: Tuple[float, float]) -> None:
290291
@property
291292
def reference_temperature_thresholds( # pylint: disable=invalid-name,
292293
self,
293-
) -> Tuple[float, float]: # pylint: disable=invalid-name
294+
) -> Tuple[float, float]:
294295
"""The cold junction's low and high temperature thresholds
295296
as a ``(low_temp, high_temp)`` tuple
296297
"""
@@ -302,7 +303,7 @@ def reference_temperature_thresholds( # pylint: disable=invalid-name,
302303
@reference_temperature_thresholds.setter
303304
def reference_temperature_thresholds( # pylint: disable=invalid-name,
304305
self, val: Tuple[float, float]
305-
) -> None: # pylint: disable=invalid-name
306+
) -> None:
306307

307308
self._write_u8(_MAX31856_CJLF_REG, int(val[0]))
308309
self._write_u8(_MAX31856_CJHF_REG, int(val[1]))

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
Adafruit-Blinka
66
adafruit-circuitpython-busdevice
7+
typing-extensions~=4.0

0 commit comments

Comments
 (0)