Skip to content

Commit 58895b9

Browse files
committed
Addressing PR comments
1 parent 65bfe66 commit 58895b9

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ _build
3737

3838
# Virtual environment-specific files
3939
.env
40+
.venv
4041

4142
# MacOS-specific files
4243
*.DS_Store
@@ -45,4 +46,3 @@ _build
4546
.idea
4647
.vscode
4748
*~
48-
.env

adafruit_ads1x15/ads1015.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
* Author(s): Carter Nelson
1212
"""
1313
import struct
14-
from typing import Dict, List
14+
15+
try:
16+
from typing import Dict, List
17+
18+
from typing_extensions import Literal
19+
except ImportError:
20+
pass
1521

1622
# pylint: disable=unused-import
1723
from .ads1x15 import ADS1x15, Mode
@@ -42,7 +48,7 @@ class ADS1015(ADS1x15):
4248
"""Class for the ADS1015 12 bit ADC."""
4349

4450
@property
45-
def bits(self) -> int:
51+
def bits(self) -> Literal[12]:
4652
"""The ADC bit resolution."""
4753
return 12
4854

adafruit_ads1x15/ads1115.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
* Author(s): Carter Nelson
1212
"""
1313
import struct
14-
from typing import Dict, List
14+
15+
try:
16+
from typing import Dict, List
17+
18+
from typing_extensions import Literal
19+
except ImportError:
20+
pass
1521

1622
# pylint: disable=unused-import
1723
from .ads1x15 import ADS1x15, Mode
@@ -43,7 +49,7 @@ class ADS1115(ADS1x15):
4349
"""Class for the ADS1115 16 bit ADC."""
4450

4551
@property
46-
def bits(self) -> int:
52+
def bits(self) -> Literal[16]:
4753
"""The ADC bit resolution."""
4854
return 16
4955

adafruit_ads1x15/ads1x15.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from micropython import const
2121

2222
try:
23-
from typing import Optional, List, Dict
23+
from typing import Dict, List, Literal, Optional, Union
2424

2525
from busio import I2C
2626
from microcontroller import Pin
@@ -77,16 +77,16 @@ def __init__(
7777
# pylint: disable=too-many-arguments
7878
self._last_pin_read = None
7979
self.buf = bytearray(3)
80-
self._gain: float
80+
self._gain = gain
8181
self.gain = gain
82-
self._data_rate: int
82+
self._data_rate = self._data_rate_default() if data_rate is None else data_rate
8383
self.data_rate = self._data_rate_default() if data_rate is None else data_rate
84-
self._mode: int
84+
self._mode = mode
8585
self.mode = mode
8686
self.i2c_device = I2CDevice(i2c, address)
8787

8888
@property
89-
def bits(self) -> int:
89+
def bits(self) -> Union[Literal[12], Literal[16]]:
9090
"""The ADC bit resolution."""
9191
raise NotImplementedError("Subclass must implement bits property.")
9292

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)