Skip to content

Commit 94434bc

Browse files
committed
Ran black, updated to pylint 2.x
1 parent 89fec08 commit 94434bc

File tree

8 files changed

+221
-132
lines changed

8 files changed

+221
-132
lines changed

.github/workflows/build.yml

+1-1
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_clue.py

+69-18
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,39 @@
7676
__version__ = "0.0.0-auto.0"
7777
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CLUE.git"
7878

79+
7980
class _ClueSimpleTextDisplay:
8081
"""Easily display lines of text on CLUE display."""
81-
def __init__(self, title=None, title_color=0xFFFFFF, title_scale=1, # pylint: disable=too-many-arguments
82-
text_scale=1, font=None, colors=None):
82+
83+
def __init__( # pylint: disable=too-many-arguments
84+
self,
85+
title=None,
86+
title_color=0xFFFFFF,
87+
title_scale=1,
88+
text_scale=1,
89+
font=None,
90+
colors=None,
91+
):
92+
# pylint: disable=import-outside-toplevel
8393
import displayio
8494
import terminalio
8595
from adafruit_display_text import label
8696

97+
# pylint: enable=import-outside-toplevel
98+
8799
if not colors:
88-
colors = (Clue.VIOLET, Clue.GREEN, Clue.RED, Clue.CYAN, Clue.ORANGE,
89-
Clue.BLUE, Clue.MAGENTA, Clue.SKY, Clue.YELLOW, Clue.PURPLE)
100+
colors = (
101+
Clue.VIOLET,
102+
Clue.GREEN,
103+
Clue.RED,
104+
Clue.CYAN,
105+
Clue.ORANGE,
106+
Clue.BLUE,
107+
Clue.MAGENTA,
108+
Clue.SKY,
109+
Clue.YELLOW,
110+
Clue.PURPLE,
111+
)
90112

91113
self._colors = colors
92114
self._label = label
@@ -102,8 +124,13 @@ def __init__(self, title=None, title_color=0xFFFFFF, title_scale=1, # pylint:
102124
if len(title) > 60:
103125
raise ValueError("Title must be 60 characters or less.")
104126

105-
title = label.Label(self._font, text=title, max_glyphs=60, color=title_color,
106-
scale=title_scale)
127+
title = label.Label(
128+
self._font,
129+
text=title,
130+
max_glyphs=60,
131+
color=title_color,
132+
scale=title_scale,
133+
)
107134
title.x = 0
108135
title.y = 8
109136
self._y = title.y + 18
@@ -120,7 +147,9 @@ def __getitem__(self, item):
120147
"""Fetch the Nth text line Group"""
121148
if len(self._lines) - 1 < item:
122149
for _ in range(item - (len(self._lines) - 1)):
123-
self._lines.append(self.add_text_line(color=self._colors[item % len(self._colors)]))
150+
self._lines.append(
151+
self.add_text_line(color=self._colors[item % len(self._colors)])
152+
)
124153
return self._lines[item]
125154

126155
def add_text_line(self, color=0xFFFFFF):
@@ -141,6 +170,7 @@ def show_terminal(self):
141170
"""Revert to terminalio screen."""
142171
self._display.show(None)
143172

173+
144174
class Clue: # pylint: disable=too-many-instance-attributes, too-many-public-methods
145175
"""Represents a single CLUE."""
146176

@@ -195,8 +225,12 @@ def __init__(self):
195225
self._red_led.switch_to_output()
196226

197227
# Define audio:
198-
self._mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA,
199-
sample_rate=16000, bit_depth=16)
228+
self._mic = audiobusio.PDMIn(
229+
board.MICROPHONE_CLOCK,
230+
board.MICROPHONE_DATA,
231+
sample_rate=16000,
232+
bit_depth=16,
233+
)
200234
self._sample = None
201235
self._samples = None
202236
self._sine_wave = None
@@ -352,7 +386,7 @@ def were_pressed(self):
352386
"""
353387
ret = set()
354388
pressed = self._gamepad.get_pressed()
355-
for button, mask in (('A', 0x01), ('B', 0x02)):
389+
for button, mask in (("A", 0x01), ("B", 0x02)):
356390
if mask & pressed:
357391
ret.add(button)
358392
return ret
@@ -690,7 +724,7 @@ def _sine_sample(length):
690724
tone_volume = (2 ** 15) - 1
691725
shift = 2 ** 15
692726
for i in range(length):
693-
yield int(tone_volume * math.sin(2*math.pi*(i / length)) + shift)
727+
yield int(tone_volume * math.sin(2 * math.pi * (i / length)) + shift)
694728

695729
def _generate_sample(self, length=100):
696730
if self._sample is not None:
@@ -791,8 +825,13 @@ def stop_tone(self):
791825
@staticmethod
792826
def _normalized_rms(values):
793827
mean_values = int(sum(values) / len(values))
794-
return math.sqrt(sum(float(sample - mean_values) * (sample - mean_values)
795-
for sample in values) / len(values))
828+
return math.sqrt(
829+
sum(
830+
float(sample - mean_values) * (sample - mean_values)
831+
for sample in values
832+
)
833+
/ len(values)
834+
)
796835

797836
@property
798837
def sound_level(self):
@@ -812,7 +851,7 @@ def sound_level(self):
812851
print(clue.sound_level)
813852
"""
814853
if self._sample is None:
815-
self._samples = array.array('H', [0] * 160)
854+
self._samples = array.array("H", [0] * 160)
816855
self._mic.record(self._samples, len(self._samples))
817856
return self._normalized_rms(self._samples)
818857

@@ -859,8 +898,14 @@ def loud_sound(self, sound_threshold=200):
859898
return self.sound_level > sound_threshold
860899

861900
@staticmethod
862-
def simple_text_display(title=None, title_color=(255, 255, 255), title_scale=1, # pylint: disable=too-many-arguments
863-
text_scale=1, font=None, colors=None):
901+
def simple_text_display( # pylint: disable=too-many-arguments
902+
title=None,
903+
title_color=(255, 255, 255),
904+
title_scale=1,
905+
text_scale=1,
906+
font=None,
907+
colors=None,
908+
):
864909
"""Display lines of text on the CLUE display. Lines of text are created in order as shown
865910
in the example below. If you skip a number, the line will be shown blank on the display,
866911
e.g. if you include ``[0]`` and ``[2]``, the second line on the display will be empty, and
@@ -910,8 +955,14 @@ def simple_text_display(title=None, title_color=(255, 255, 255), title_scale=1,
910955
clue_data[2].text = "Magnetic: {:.3f} {:.3f} {:.3f}".format(*clue.magnetic)
911956
clue_data.show()
912957
"""
913-
return _ClueSimpleTextDisplay(title=title, title_color=title_color, title_scale=title_scale,
914-
text_scale=text_scale, font=font, colors=colors)
958+
return _ClueSimpleTextDisplay(
959+
title=title,
960+
title_color=title_color,
961+
title_scale=title_scale,
962+
text_scale=text_scale,
963+
font=font,
964+
colors=colors,
965+
)
915966

916967

917968
clue = Clue() # pylint: disable=invalid-name

0 commit comments

Comments
 (0)