Skip to content

Commit 62228b8

Browse files
committed
QA: Add more checks, fix the fallout.
1 parent f522016 commit 62228b8

File tree

6 files changed

+32
-16
lines changed

6 files changed

+32
-16
lines changed

ci/python.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
QA_INCLUDE="F,Q,W,E,B"
2-
QA_IGNORE="E501,E402"
1+
# F = Pyflakes
2+
# Q = Quotes
3+
# E/W = pycodestyle (Whitespace, Line lengths etc)
4+
# B - flake8-bugbear = Unused loop variables, sloppy code
5+
# COM - flake8-commas
6+
# BLE - flake8-blind-except
7+
# C4 - flake8-comprehensions
8+
# ISC - flake8-implicit-str-concat = Implicit string concat, eg: `"hello" "world"` on one line
9+
# ICN - flake8-import-conventions = Import conventions
10+
# PIE - flake8-pie = Misc silliness, catches range with a 0 start argument
11+
# RET - flake8-return = Enforces straight-forward code around return statements
12+
# SLF - flake8-self
13+
# ARG - flake8-unused-arguments
14+
15+
QA_INCLUDE="F,Q,W,E,B,COM,BLE,C4,ISC,ICN,PIE,RSE,RET,SLF,ARG"
16+
QA_IGNORE="E501,E402,COM812"
317

418
function qa_prepare_all {
519
pip install ruff

examples/balls_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self, x, y, r, dx, dy, pen):
2323

2424
# initialise shapes
2525
balls = []
26-
for _ in range(0, 170):
26+
for _ in range(170):
2727
r = random.randint(0, 10) + 3
2828
balls.append(
2929
Ball(

examples/cheerlights_bulb.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ def get_cheerlight():
206206
req.close()
207207
print("Success!")
208208

209-
colour = tuple(int(json["field2"][i:i + 2], 16) for i in (1, 3, 5))
210-
211-
return colour
209+
return tuple(int(json["field2"][i:i + 2], 16) for i in (1, 3, 5))
212210

213211
except OSError:
214212
print("Error: Failed to get new colour")

examples/image_gallery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def numberedfiles(k):
9595

9696

9797
try:
98-
files = list(file for file in sorted(os.listdir(directory), key=numberedfiles) if file.endswith(".jpg"))
98+
files = [file for file in sorted(os.listdir(directory), key=numberedfiles) if file.endswith(".jpg")]
9999
except OSError:
100100
display_error("Problem loading images.\n\nEnsure that your Presto or SD card contains a 'gallery' folder in the root")
101101

examples/random_maze.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,20 @@ def build(self, width, height):
151151
self.maze = []
152152

153153
row = [1]
154-
for _ in range(0, self.width):
154+
for _ in range(self.width):
155155
row.append(1)
156156
row.append(1)
157157
self.maze.append(row)
158158

159-
for y in range(0, self.height):
159+
for y in range(self.height):
160160
row = [1]
161-
for x in range(0, self.width):
161+
for x in range(self.width):
162162
row.append(0)
163163
row.append(1 if self.cell_grid[x][y].right else 0)
164164
self.maze.append(row)
165165

166166
row = [1]
167-
for x in range(0, self.width):
167+
for x in range(self.width):
168168
row.append(1 if self.cell_grid[x][y].bottom else 0)
169169
row.append(1)
170170
self.maze.append(row)

examples/word_clock.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,20 @@ def approx_time(hours, minutes):
6666

6767
if hours == 12:
6868
hours = 0
69+
6970
if minutes > 0 and minutes < 8:
7071
return "it is about " + nums[hours] + " O'Clock"
71-
elif minutes >= 8 and minutes < 23:
72+
73+
if minutes >= 8 and minutes < 23:
7274
return "it is about quarter past " + nums[hours]
73-
elif minutes >= 23 and minutes < 38:
75+
76+
if minutes >= 23 and minutes < 38:
7477
return "it is about half past " + nums[hours]
75-
elif minutes >= 38 and minutes < 53:
78+
79+
if minutes >= 38 and minutes < 53:
7680
return "it is about quarter to " + nums[hours + 1]
77-
else:
78-
return "it is about " + nums[hours + 1] + " O'Clock"
81+
82+
return "it is about " + nums[hours + 1] + " O'Clock"
7983

8084

8185
def update():

0 commit comments

Comments
 (0)