Skip to content

Commit 6c4e212

Browse files
author
caternuson
committed
code review updates
1 parent f1cdad8 commit 6c4e212

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ ignored-classes=optparse.Values,thread._local,_thread._local
156156
# (useful for modules/projects where namespaces are manipulated during runtime
157157
# and thus existing member attributes cannot be deduced by static analysis. It
158158
# supports qualified module names, as well as Unix pattern matching.
159-
ignored-modules=
159+
ignored-modules=board
160160

161161
# Show a hint with possible names when a member name was not found. The aspect
162162
# of finding the hint is based on edit distance.

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ deploy:
2323
tags: true
2424

2525
install:
26-
- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme
26+
- pip install circuitpython-build-tools Sphinx sphinx-rtd-theme
27+
- pip install --force-reinstall pylint==1.9.2
2728

2829
script:
2930
- pylint adafruit_tca9548a.py

adafruit_tca9548a.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,14 @@ class TCA9548A():
8989
def __init__(self, i2c, address=_DEFAULT_ADDRESS):
9090
self.i2c = i2c
9191
self.address = address
92-
self.used_channels = []
92+
self.channels = [None]*8
93+
94+
def __len__(self):
95+
return 8
9396

9497
def __getitem__(self, key):
9598
if not 0 <= key <= 7:
96-
raise ValueError("Channel must be an integer in the range: 0-7")
97-
if key in self.used_channels:
98-
raise ValueError("Channel already in use.")
99-
self.used_channels.append(key)
100-
return TCA9548A_Channel(self, key)
99+
raise IndexError("Channel must be an integer in the range: 0-7")
100+
if self.channels[key] is None:
101+
self.channels[key] = TCA9548A_Channel(self, key)
102+
return self.channels[key]

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
adafruit-circuitpython-busdevice

0 commit comments

Comments
 (0)