Skip to content

Commit d9c712c

Browse files
committed
Ran black, updated to pylint 2.x
1 parent b1a7b2e commit d9c712c

File tree

11 files changed

+268
-190
lines changed

11 files changed

+268
-190
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
source actions-ci/install.sh
4141
- name: Pip install pylint, black, & Sphinx
4242
run: |
43-
pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme
43+
pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
4444
- name: Library version
4545
run: git describe --dirty --always --tags
4646
- name: PyLint

adafruit_boardtest/boardtest_gpio.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BoardTest.git"
5151

5252
# Constants
53-
LED_ON_DELAY_TIME = 0.2 # Seconds
54-
LED_OFF_DELAY_TIME = 0.2 # Seconds
55-
LED_PIN_NAMES = ['L', 'LED', 'RED_LED', 'GREEN_LED', 'BLUE_LED']
53+
LED_ON_DELAY_TIME = 0.2 # Seconds
54+
LED_OFF_DELAY_TIME = 0.2 # Seconds
55+
LED_PIN_NAMES = ["L", "LED", "RED_LED", "GREEN_LED", "BLUE_LED"]
5656

5757
# Test result strings
5858
PASS = "PASS"
@@ -67,11 +67,13 @@ def _is_number(val):
6767
except ValueError:
6868
return False
6969

70+
7071
# Release pins
7172
def _deinit_pins(gpios):
7273
for g in gpios:
7374
g.deinit()
7475

76+
7577
# Toggle IO pins while waiting for answer
7678
def _toggle_wait(gpios):
7779

@@ -91,7 +93,8 @@ def _toggle_wait(gpios):
9193
gpio.value = led_state
9294
if supervisor.runtime.serial_bytes_available:
9395
answer = input()
94-
return bool(answer == 'y')
96+
return bool(answer == "y")
97+
9598

9699
def run_test(pins):
97100

@@ -103,10 +106,10 @@ def run_test(pins):
103106
"""
104107

105108
# Create a list of analog GPIO pins
106-
analog_pins = [p for p in pins if p[0] == 'A' and _is_number(p[1])]
109+
analog_pins = [p for p in pins if p[0] == "A" and _is_number(p[1])]
107110

108111
# Create a list of digital GPIO
109-
digital_pins = [p for p in pins if p[0] == 'D' and _is_number(p[1])]
112+
digital_pins = [p for p in pins if p[0] == "D" and _is_number(p[1])]
110113

111114
# Toggle LEDs if we find any
112115
gpio_pins = analog_pins + digital_pins
@@ -116,10 +119,10 @@ def run_test(pins):
116119
gpios = [digitalio.DigitalInOut(getattr(board, p)) for p in gpio_pins]
117120

118121
# Print out the LEDs found
119-
print("GPIO pins found:", end=' ')
122+
print("GPIO pins found:", end=" ")
120123
for pin in gpio_pins:
121-
print(pin, end=' ')
122-
print('\n')
124+
print(pin, end=" ")
125+
print("\n")
123126

124127
# Set all IO to output
125128
for gpio in gpios:
@@ -140,24 +143,26 @@ def run_test(pins):
140143
print("No GPIO pins found")
141144
return NA, []
142145

146+
143147
def _main():
144148

145149
# List out all the pins available to us
146-
pins = [p for p in dir(board)]
150+
pins = list(dir(board))
147151
print()
148-
print("All pins found:", end=' ')
152+
print("All pins found:", end=" ")
149153

150154
# Print pins
151155
for pin in pins:
152-
print(pin, end=' ')
153-
print('\n')
156+
print(pin, end=" ")
157+
print("\n")
154158

155159
# Run test
156160
result = run_test(pins)
157161
print()
158162
print(result[0])
159163
print("Pins tested: " + str(result[1]))
160164

165+
161166
# Execute only if run as main.py or code.py
162167
if __name__ == "__main__":
163168
_main()

adafruit_boardtest/boardtest_i2c.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BoardTest.git"
5555

5656
# Constants
57-
SDA_PIN_NAME = 'SDA'
58-
SCL_PIN_NAME = 'SCL'
59-
NUM_I2C_TESTS = 10 # Number of times to write and read EEPROM values
60-
EEPROM_I2C_MAX_ADDR = 255 # Self-imposed max memory address
57+
SDA_PIN_NAME = "SDA"
58+
SCL_PIN_NAME = "SCL"
59+
NUM_I2C_TESTS = 10 # Number of times to write and read EEPROM values
60+
EEPROM_I2C_MAX_ADDR = 255 # Self-imposed max memory address
6161

6262
# Microchip AT24HC04B EEPROM I2C address
6363
EEPROM_I2C_ADDR = 0x50
@@ -81,6 +81,7 @@ def _eeprom_i2c_wait(i2c, i2c_addr, mem_addr, timeout=1.0):
8181

8282
return False
8383

84+
8485
# Write to address. Returns status (True for successful write, False otherwise)
8586
def _eeprom_i2c_write_byte(i2c, i2c_addr, mem_addr, mem_data):
8687

@@ -100,6 +101,7 @@ def _eeprom_i2c_write_byte(i2c, i2c_addr, mem_addr, mem_data):
100101

101102
return True
102103

104+
103105
# Read from address. Returns tuple [status, result]
104106
def _eeprom_i2c_read_byte(i2c, i2c_addr, mem_addr, timeout=1.0):
105107

@@ -117,6 +119,7 @@ def _eeprom_i2c_read_byte(i2c, i2c_addr, mem_addr, timeout=1.0):
117119

118120
return True, buf
119121

122+
120123
def run_test(pins, sda_pin=SDA_PIN_NAME, scl_pin=SCL_PIN_NAME):
121124

122125
"""
@@ -132,8 +135,10 @@ def run_test(pins, sda_pin=SDA_PIN_NAME, scl_pin=SCL_PIN_NAME):
132135
if list(set(pins).intersection(set([sda_pin, scl_pin]))):
133136

134137
# Tell user to connect EEPROM chip
135-
print("Connect a Microchip AT24HC04B EEPROM I2C chip. " +
136-
"Press enter to continue.")
138+
print(
139+
"Connect a Microchip AT24HC04B EEPROM I2C chip. "
140+
+ "Press enter to continue."
141+
)
137142
input()
138143

139144
# Set up I2C
@@ -188,24 +193,26 @@ def run_test(pins, sda_pin=SDA_PIN_NAME, scl_pin=SCL_PIN_NAME):
188193
print("No I2C pins found")
189194
return NA, []
190195

196+
191197
def _main():
192198

193199
# List out all the pins available to us
194-
pins = [p for p in dir(board)]
200+
pins = list(dir(board))
195201
print()
196-
print("All pins found:", end=' ')
202+
print("All pins found:", end=" ")
197203

198204
# Print pins
199205
for pin in pins:
200-
print(pin, end=' ')
201-
print('\n')
206+
print(pin, end=" ")
207+
print("\n")
202208

203209
# Run test
204210
result = run_test(pins)
205211
print()
206212
print(result[0])
207213
print("Pins tested: " + str(result[1]))
208214

215+
209216
# Execute only if run as main.py or code.py
210217
if __name__ == "__main__":
211218
_main()

adafruit_boardtest/boardtest_led.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BoardTest.git"
5050

5151
# Constants
52-
LED_ON_DELAY_TIME = 0.2 # Seconds
53-
LED_OFF_DELAY_TIME = 0.2 # Seconds
54-
LED_PIN_NAMES = ['L', 'LED', 'RED_LED', 'YELLOW_LED', 'GREEN_LED', 'BLUE_LED']
52+
LED_ON_DELAY_TIME = 0.2 # Seconds
53+
LED_OFF_DELAY_TIME = 0.2 # Seconds
54+
LED_PIN_NAMES = ["L", "LED", "RED_LED", "YELLOW_LED", "GREEN_LED", "BLUE_LED"]
5555

5656
# Test result strings
5757
PASS = "PASS"
@@ -89,10 +89,11 @@ def _toggle_wait(led_pins):
8989
# Look for user input
9090
if supervisor.runtime.serial_bytes_available:
9191
answer = input()
92-
if answer == 'y':
92+
if answer == "y":
9393
return True
9494
return False
9595

96+
9697
def run_test(pins):
9798

9899
"""
@@ -109,10 +110,10 @@ def run_test(pins):
109110
if led_pins:
110111

111112
# Print out the LEDs found
112-
print("LEDs found:", end=' ')
113+
print("LEDs found:", end=" ")
113114
for pin in led_pins:
114-
print(pin, end=' ')
115-
print('\n')
115+
print(pin, end=" ")
116+
print("\n")
116117

117118
# Blink LEDs and wait for user to verify test
118119
result = _toggle_wait(led_pins)
@@ -126,24 +127,26 @@ def run_test(pins):
126127
print("No LED pins found")
127128
return NA, []
128129

130+
129131
def _main():
130132

131133
# List out all the pins available to us
132-
pins = [p for p in dir(board)]
134+
pins = list(dir(board))
133135
print()
134-
print("All pins found:", end=' ')
136+
print("All pins found:", end=" ")
135137

136138
# Print pins
137139
for pin in pins:
138-
print(pin, end=' ')
139-
print('\n')
140+
print(pin, end=" ")
141+
print("\n")
140142

141143
# Run test
142144
result = run_test(pins)
143145
print()
144146
print(result[0])
145147
print("Pins tested: " + str(result[1]))
146148

149+
147150
# Execute only if run as main.py or code.py
148151
if __name__ == "__main__":
149152
_main()

adafruit_boardtest/boardtest_sd.py

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,36 +48,39 @@
4848
"""
4949
import random
5050

51-
import adafruit_sdcard
5251
import board
5352
import busio
5453
import digitalio
54+
import adafruit_sdcard
5555
import storage
5656

5757
__version__ = "0.0.0-auto.0"
5858
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BoardTest.git"
5959

6060
# Constants
61-
MOSI_PIN_NAME = 'SD_MOSI'
62-
MISO_PIN_NAME = 'SD_MISO'
63-
SCK_PIN_NAME = 'SD_SCK'
64-
CS_PIN_NAME = 'SD_CS'
65-
FILENAME = "test.txt" # File that will be written to
66-
BAUD_RATE = 100000 # Bits per second
67-
NUM_UART_BYTES = 40 # Number of bytes to transmit over UART
68-
ASCII_MIN = 0x21 # '!' Lowest ASCII char in random range (inclusive)
69-
ASCII_MAX = 0x7E # '~' Highest ASCII char in random range (inclusive)
61+
MOSI_PIN_NAME = "SD_MOSI"
62+
MISO_PIN_NAME = "SD_MISO"
63+
SCK_PIN_NAME = "SD_SCK"
64+
CS_PIN_NAME = "SD_CS"
65+
FILENAME = "test.txt" # File that will be written to
66+
BAUD_RATE = 100000 # Bits per second
67+
NUM_UART_BYTES = 40 # Number of bytes to transmit over UART
68+
ASCII_MIN = 0x21 # '!' Lowest ASCII char in random range (inclusive)
69+
ASCII_MAX = 0x7E # '~' Highest ASCII char in random range (inclusive)
7070

7171
# Test result strings
7272
PASS = "PASS"
7373
FAIL = "FAIL"
7474
NA = "N/A"
7575

76-
def run_test(pins,
77-
mosi_pin=MOSI_PIN_NAME,
78-
miso_pin=MISO_PIN_NAME,
79-
sck_pin=SCK_PIN_NAME,
80-
cs_pin=CS_PIN_NAME):
76+
77+
def run_test(
78+
pins,
79+
mosi_pin=MOSI_PIN_NAME,
80+
miso_pin=MISO_PIN_NAME,
81+
sck_pin=SCK_PIN_NAME,
82+
cs_pin=CS_PIN_NAME,
83+
):
8184

8285
"""
8386
Performs random writes and reads to file on attached SD card.
@@ -96,8 +99,7 @@ def run_test(pins,
9699

97100
# Tell user to connect SD card
98101
print("Insert SD card into holder and connect SPI lines to holder.")
99-
print("Connect " + cs_pin + " to the CS (DAT3) pin on the SD " +
100-
"card holder.")
102+
print("Connect " + cs_pin + " to the CS (DAT3) pin on the SD " + "card holder.")
101103
print("WARNING: " + FILENAME + " will be created or overwritten.")
102104
print("Press enter to continue.")
103105
input()
@@ -108,9 +110,11 @@ def run_test(pins,
108110
csel.value = True
109111

110112
# Set up SPI
111-
spi = busio.SPI(getattr(board, sck_pin),
112-
MOSI=getattr(board, mosi_pin),
113-
MISO=getattr(board, miso_pin))
113+
spi = busio.SPI(
114+
getattr(board, sck_pin),
115+
MOSI=getattr(board, mosi_pin),
116+
MISO=getattr(board, miso_pin),
117+
)
114118

115119
# Try to connect to the card and mount the filesystem
116120
try:
@@ -160,24 +164,26 @@ def run_test(pins,
160164
print("No SD card pins found")
161165
return NA, []
162166

167+
163168
def _main():
164169

165170
# List out all the pins available to us
166-
pins = [p for p in dir(board)]
171+
pins = list(dir(board))
167172
print()
168-
print("All pins found:", end=' ')
173+
print("All pins found:", end=" ")
169174

170175
# Print pins
171176
for pin in pins:
172-
print(pin, end=' ')
173-
print('\n')
177+
print(pin, end=" ")
178+
print("\n")
174179

175180
# Run test
176181
result = run_test(pins)
177182
print()
178183
print(result[0])
179184
print("Pins tested: " + str(result[1]))
180185

186+
181187
# Execute only if run as main.py or code.py
182188
if __name__ == "__main__":
183189
_main()

0 commit comments

Comments
 (0)