Skip to content

Commit 64a134b

Browse files
committed
fix pylint messages
1 parent c3899a0 commit 64a134b

File tree

1 file changed

+29
-8
lines changed
  • CircuitPython_Zorque_Text_Game_openai

1 file changed

+29
-8
lines changed

CircuitPython_Zorque_Text_Game_openai/code.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ def on_last_line(self):
139139

140140
def refresh(self):
141141
text = '\n'.join(self.lines[self.line_offset : self.line_offset + max_lines])
142-
while '\n\n' in text:
142+
# Work around https://github.com/adafruit/Adafruit_CircuitPython_Display_Text/issues/183
143+
while '\n\n' in text:
143144
text = text.replace('\n\n', '\n \n')
144145
terminal.text = text
145146
board.DISPLAY.refresh()
@@ -162,10 +163,20 @@ def record_game_step(action, response):
162163

163164
def get_one_completion(full_prompt):
164165
if not use_openai:
165-
return f"""This is a canned response in offline mode. The player's last choice was as follows:
166+
return f"""\
167+
This is a canned response in offline mode. The player's last choice was as follows:
166168
{full_prompt[-1]['content']}
167169
168-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Nulla aliquet enim tortor at auctor urna. Arcu ac tortor dignissim convallis aenean et tortor at. Dapibus ultrices in iaculis nunc sed augue. Enim nec dui nunc mattis enim ut tellus elementum sagittis. Sit amet mattis vulputate enim nulla. Ultrices in iaculis nunc sed augue lacus. Pulvinar neque laoreet suspendisse interdum consectetur libero id faucibus nisl. Aenean pharetra magna ac placerat vestibulum lectus mauris ultrices eros. Imperdiet nulla malesuada pellentesque elit eget. Tellus at urna condimentum mattis pellentesque id nibh tortor. Velit dignissim sodales ut eu sem integer vitae. Id ornare arcu odio ut sem nulla pharetra diam sit.
170+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor \
171+
incididunt ut labore et dolore magna aliqua. Nulla aliquet enim tortor at \
172+
auctor urna. Arcu ac tortor dignissim convallis aenean et tortor at. Dapibus \
173+
ultrices in iaculis nunc sed augue. Enim nec dui nunc mattis enim ut tellus \
174+
elementum sagittis. Sit amet mattis vulputate enim nulla. Ultrices in iaculis \
175+
nunc sed augue lacus. Pulvinar neque laoreet suspendisse interdum consectetur \
176+
libero id faucibus nisl. Aenean pharetra magna ac placerat vestibulum lectus \
177+
mauris ultrices eros. Imperdiet nulla malesuada pellentesque elit eget. Tellus \
178+
at urna condimentum mattis pellentesque id nibh tortor. Velit dignissim sodales \
179+
ut eu sem integer vitae. Id ornare arcu odio ut sem nulla pharetra diam sit.
169180
170181
1: Stand in the place where you live
171182
2: Now face West
@@ -209,7 +220,8 @@ def get_touchscreen_choice():
209220
if wrapped_text_display.max_offset() > 0 and ticks_less(deadline, ticks_ms()):
210221
wrapped_text_display.scroll_next_line()
211222
wrapped_text_display.refresh()
212-
deadline = ticks_add(deadline, 5000 if wrapped_text_display.on_last_line() else 1000)
223+
deadline = ticks_add(deadline,
224+
5000 if wrapped_text_display.on_last_line() else 1000)
213225

214226
# Depending on the quadrant of the screen, make a choice
215227
x, y, _ = t
@@ -269,8 +281,17 @@ def run_game_step(forced_choice=None):
269281
use_width = board.DISPLAY.width - 4
270282

271283
# Game text is displayed on this wdget
272-
terminal = Label(font=nice_font, color=0xffffff, background_color=0, line_spacing=line_spacing, anchor_point=(0,0), anchored_position=(0,glyph_height+1))
273-
max_lines = (use_height - 2 * glyph_height) // int(nice_font.get_bounding_box()[1] * terminal.line_spacing)
284+
terminal = Label(
285+
font=nice_font,
286+
color=0xFFFFFF,
287+
background_color=0,
288+
line_spacing=line_spacing,
289+
anchor_point=(0, 0),
290+
anchored_position=(0, glyph_height + 1),
291+
)
292+
max_lines = (use_height - 2 * glyph_height) // int(
293+
nice_font.get_bounding_box()[1] * terminal.line_spacing
294+
)
274295
main_group.append(terminal)
275296

276297
# Indicate what each quadrant of the screen does when tapped
@@ -298,8 +319,8 @@ def run_game_step(forced_choice=None):
298319
while True:
299320
run_game_step()
300321
except Exception as e: # pylint: disable=broad-except
301-
traceback.print_exception(e)
302-
print_wrapped(f"An error occurred (more details on REPL).\nTouch the screen to re-load")
322+
traceback.print_exception(e) # pylint: disable=no-value-for-parameter
323+
print_wrapped("An error occurred (more details on REPL).\nTouch the screen to re-load")
303324
board.DISPLAY.refresh()
304325
get_touchscreen_choice()
305326
supervisor.reload()

0 commit comments

Comments
 (0)