10000 all: Fix Python comparison to None and True, and use "not in". · peterwillcn/micropython@4376c96 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4376c96

Browse files
cclaussdpgeorge
authored andcommitted
all: Fix Python comparison to None and True, and use "not in".
These are basic PEP8 recommendations.
1 parent f3a596d commit 4376c96

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

ports/cc3200/tools/update-wipy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def transfer_file(args):
4545
if "250" in ftp.cwd("/flash"):
4646
if not ftp_directory_exists(ftp, "sys"):
4747
print("/flash/sys directory does not exist")
48-
if not "550" in ftp.mkd("sys"):
48+
if "550" not in ftp.mkd("sys"):
4949
print("/flash/sys directory created")
5050
else:
5151
print("Error: cannot create /flash/sys directory")

ports/nrf/examples/powerup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ def battery_level(self):
120120
return int(self.char_batt_lvl.read()[0])
121121

122122
def speed(self, new_speed=None):
123-
if new_speed == None:
123+
if new_speed is None:
124124
return int(self.char_control_speed.read()[0])
125125
else:
126126
self.char_control_speed.write(bytearray([new_speed]))
127127

128128
def angle(self, new_angle=None):
129-
if new_angle == None:
129+
if new_angle is None:
130130
return int(self.char_control_angle.read()[0])
131131
else:
132132
self.char_control_angle.write(bytearray([new_angle]))

ports/rp2/modules/rp2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def word(self, instr, label=None):
116116
if label is None:
117117
label = 0
118118
else:
119-
if not label in self.labels:
119+
if label not in self.labels:
120120
raise PIOASMError("unknown label {}".format(label))
121121
label = self.labels[label]
122122
self.prog[_PROG_DATA].append(instr | label)

ports/stm32/boards/pllvalues.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def compute_pll2(hse, sys, relax_pll48):
9494
fallback = None
9595
for P in mcu.range_p:
9696
# VCO_OUT must be between 192MHz and 432MHz
97-
if not sys * P in mcu.range_vco_out:
97+
if sys * P not in mcu.range_vco_out:
9898
continue
9999
NbyM = float(sys * P) / hse # float for Python 2
100100
# scan M

tools/mpremote/mpremote/commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ def _list_recursive(files, path):
122122
if command == "cat":
123123
# Don't be verbose by default when using cat, so output can be
124124
# redirected to something.
125-
verbose = args.verbose == True
125+
verbose = args.verbose is True
126126
else:
127-
verbose = args.verbose != False
127+
verbose = args.verbose is not False
128128

129129
if command == "cp" and args.recursive:
130130
if paths[-1] != ":":

tools/uf2conv.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ def convert_from_uf2(buf):
8585
if datalen > 476:
8686
assert False, "Invalid UF2 data size at " + ptr
8787
newaddr = hd[3]
88-
if (hd[2] & 0x2000) and (currfamilyid == None):
88+
if (hd[2] & 0x2000) and (currfamilyid is None):
8989
currfamilyid = hd[7]
90-
if curraddr == None or ((hd[2] & 0x2000) and hd[7] != currfamilyid):
90+
if curraddr is None or ((hd[2] & 0x2000) and hd[7] != currfamilyid):
9191
currfamilyid = hd[7]
9292
curraddr = newaddr
9393
if familyid == 0x0 or familyid == hd[7]:
@@ -111,7 +111,7 @@ def convert_from_uf2(buf):
111111
families_found[hd[7]] = newaddr
112112
else:
113113
families_found[hd[7]] = newaddr
114-
if prev_flag == None:
114+
if prev_flag is None:
115115
prev_flag = hd[2]
116116
if prev_flag != hd[2]:
117117
all_flags_same = False
@@ -234,7 +234,7 @@ def convert_from_hex_to_uf2(buf):
234234
break
235235
elif tp == 0:
236236
addr = upper + ((rec[1] << 8) | rec[2])
237-
if appstartaddr == None:
237+
if appstartaddr is None:
238238
appstartaddr = addr
239239
i = 4
240240
while i < len(rec) - 1:
@@ -419,7 +419,7 @@ def error(msg):
419419
)
420420
if args.convert or ext != "uf2":
421421
drives = []
422-
if args.output == None:
422+
if args.output is None:
423423
args.output = "flash." + ext
424424
else:
425425
drives = get_drives()

0 commit comments

Comments
 (0)
0