Skip to content

Commit 5d8d6f8

Browse files
authored
Merge pull request #34 from Myoldmopar/FixTypeHint
Fix a few type hints
2 parents a5c31cd + 132c666 commit 5d8d6f8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

adafruit_ds18x20.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@
2929
from typing_extensions import Literal
3030
from circuitpython_typing import WriteableBuffer
3131
from adafruit_onewire.bus import OneWireBus # pylint: disable=ungrouped-imports
32+
from adafruit_onewire.device import OneWireAddress
3233
except ImportError:
3334
pass
3435

3536
_CONVERT = b"\x44"
3637
_RD_SCRATCH = b"\xBE"
3738
_WR_SCRATCH = b"\x4E"
3839
_CONVERSION_TIMEOUT = const(1)
39-
RESOLUTION = (9, 10, 11, 12)
40+
RESOLUTION: tuple[Literal[9, 10, 11, 12], ...] = (9, 10, 11, 12)
4041
# Maximum conversion delay in seconds, from DS18B20 datasheet.
4142
_CONVERSION_DELAY = {9: 0.09375, 10: 0.1875, 11: 0.375, 12: 0.750}
4243

@@ -74,7 +75,7 @@ class DS18X20:
7475
7576
"""
7677

77-
def __init__(self, bus: OneWireBus, address: int) -> None:
78+
def __init__(self, bus: OneWireBus, address: OneWireAddress) -> None:
7879
if address.family_code in (0x10, 0x28):
7980
self._address = address
8081
self._device = OneWireDevice(bus, address)
@@ -84,7 +85,7 @@ def __init__(self, bus: OneWireBus, address: int) -> None:
8485
raise ValueError("Incorrect family code in device address.")
8586

8687
@property
87-
def temperature(self):
88+
def temperature(self) -> float:
8889
"""The temperature in degrees Celsius."""
8990
self._convert_temp()
9091
return self._read_temp()

0 commit comments

Comments
 (0)