From 092e8bcd9924dbf17be889d23b804e60b532cf12 Mon Sep 17 00:00:00 2001 From: barton26 Date: Thu, 30 Sep 2021 17:07:53 -0400 Subject: [PATCH] Use `is None` instead of `== None` --- py/Boinc/boincxml.py | 2 +- py/Boinc/db_base.py | 8 ++++---- py/Boinc/setup_project.py | 4 ++-- sched/assimilator.py | 2 +- tests/old/testbase.py | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/py/Boinc/boincxml.py b/py/Boinc/boincxml.py index 652b653884..651f32e344 100644 --- a/py/Boinc/boincxml.py +++ b/py/Boinc/boincxml.py @@ -28,7 +28,7 @@ def get_element(node, name, optional=True): raise SystemExit("ERROR: Couldn't find xml node <%s>"% name) def _None2Str(object): - if object == None: + if object is None: return '' else: return object diff --git a/py/Boinc/db_base.py b/py/Boinc/db_base.py index 45b25fd54e..1f9d8901d8 100644 --- a/py/Boinc/db_base.py +++ b/py/Boinc/db_base.py @@ -69,13 +69,13 @@ def _commit_object(tablename, paramdict, id=None): equalcommands = [] for key in paramdict.keys(): value = paramdict[key] - if value == None: + if value is None: continue elif isinstance(value, int): equalcommands.append('%s=%d' %(key,value)) else: equalcommands.append("%s='%s'"%(key,dbconnection.escape_string(str(value)))) - if id == None: + if id is None: command = 'INSERT INTO %s SET %s' % \ (tablename, ', '.join(equalcommands)) if debug.mysql: @@ -97,7 +97,7 @@ def _remove_object(command, id=None): id is given, it assembles the SQL command and deletes the object from the database. Does nothing if no id is given.""" assert(dbconnection) - if id == None: + if id is None: pass else: cursor = dbconnection.cursor() @@ -122,7 +122,7 @@ def _select_object(table, searchdict, extra_args="", extra_params=[], select_wha if join: command += "," + join for (key,value) in searchdict.items(): - if value == None: + if value is None: value = '' escaped_value = dbconnection.escape_string(str(value)) if key == 'text': diff --git a/py/Boinc/setup_project.py b/py/Boinc/setup_project.py index b62d1e66a7..2d77d76460 100644 --- a/py/Boinc/setup_project.py +++ b/py/Boinc/setup_project.py @@ -57,7 +57,7 @@ def verbose_sleep(msg, wait): def get_env_var(name, default = None): value = os.environ.get(name, default) - if value == None: + if value is None: print("Environment variable %s not defined" % name) sys.exit(1) return value @@ -209,7 +209,7 @@ def _check_vars(dict, **names): for key in names: value = names[key] if not key in dict: - if value == None: + if value is None: raise SystemExit('error in test script: required parameter "%s" not specified'%key) dict[key] = value for key in dict: diff --git a/sched/assimilator.py b/sched/assimilator.py index 865cdb9372..4367d1947a 100644 --- a/sched/assimilator.py +++ b/sched/assimilator.py @@ -180,7 +180,7 @@ class Assimilator(): if result == wu.canonical_result: canonical_result=result - if canonical_result == None and wu.error_mask == 0: + if canonical_result is None and wu.error_mask == 0: # If no canonical result found and WU had no other errors, # something is wrong, e.g. result records got deleted prematurely. # This is probably unrecoverable, so mark the WU as having diff --git a/tests/old/testbase.py b/tests/old/testbase.py index af5d802f19..8958b21e68 100644 --- a/tests/old/testbase.py +++ b/tests/old/testbase.py @@ -125,7 +125,7 @@ def _check_vars(dict, **names): for key in names: value = names[key] if not key in dict: - if value == None: + if value is None: raise SystemExit('error in test script: required parameter "%s" not specified'%key) dict[key] = value for key in dict: