Skip to content

Commit 59d1830

Browse files
committed
fix(llvm/**.py): fix comparison to None
from PEP8 (https://peps.python.org/pep-0008/#programming-recommendations): > Comparisons to singletons like None should always be done with is or > is not, never the equality operators.
1 parent f372bb4 commit 59d1830

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

llvm/utils/indirect_calls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def look_for_indirect(file):
3434
if line.startswith(" ") == False:
3535
function = line
3636
result = re.search("(call|jmp).*\*", line)
37-
if result != None:
37+
if result is not None:
3838
# TODO: Perhaps use cxxfilt to demangle functions?
3939
print(function)
4040
print(line)

llvm/utils/lit/lit/TestRunner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def executeShCmd(cmd, shenv, results, timeout=0):
197197
timeout
198198
"""
199199
# Use the helper even when no timeout is required to make
200-
# other code simpler (i.e. avoid bunch of ``!= None`` checks)
200+
# other code simpler (i.e. avoid bunch of ``is not None`` checks)
201201
timeoutHelper = TimeoutHelper(timeout)
202202
if timeout > 0:
203203
timeoutHelper.startTimer()

llvm/utils/lit/lit/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def killProcess():
408408
out, err = p.communicate(input=input)
409409
exitCode = p.wait()
410410
finally:
411-
if timerObject != None:
411+
if timerObject is not None:
412412
timerObject.cancel()
413413

414414
# Ensure the resulting output is always of string type.

llvm/utils/schedcover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def add(instr, model, resource=None):
2525
def filter_model(m):
2626
global filt
2727
if m and filt:
28-
return filt.search(m) != None
28+
return filt.search(m) is not None
2929
else:
3030
return True
3131

llvm/utils/shuffle_select_fuzz_tester.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def dump(self):
157157
)
158158

159159
def calc_value(self):
160-
if self.value != None:
160+
if self.value is not None:
161161
print("Trying to calculate the value of a shuffle instruction twice")
162162
exit(1)
163163

@@ -199,7 +199,7 @@ def dump(self):
199199
)
200200

201201
def calc_value(self):
202-
if self.value != None:
202+
if self.value is not None:
203203
print("Trying to calculate the value of a select instruction twice")
204204
exit(1)
205205

@@ -237,7 +237,7 @@ def gen_inputs(ty, num):
237237
# In case one of the dimensions (scalar type/number of elements) is provided,
238238
# fill the blank dimension and return appropriate Type object.
239239
def get_random_type(ty, num_elts):
240-
if ty != None:
240+
if ty is not None:
241241
if ty == "i8":
242242
is_float = False
243243
width = 8
@@ -260,10 +260,10 @@ def get_random_type(ty, num_elts):
260260
int_elt_widths = [8, 16, 32, 64]
261261
float_elt_widths = [32, 64]
262262

263-
if num_elts == None:
263+
if num_elts is None:
264264
num_elts = random.choice(range(2, 65))
265265

266-
if ty == None:
266+
if ty is None:
267267
# 1 for integer type, 0 for floating-point
268268
if random.randint(0, 1):
269269
is_float = False
@@ -388,7 +388,7 @@ def main():
388388
), "Minimum value greater than maximum."
389389
assert args.type in [None, "i8", "i16", "i32", "i64", "f32", "f64"], "Illegal type."
390390
assert (
391-
args.num_elts == None or args.num_elts > 0
391+
args.num_elts is None or args.num_elts > 0
392392
), "num_elts must be a positive integer."
393393

394394
random.seed(args.seed)

0 commit comments

Comments
 (0)