Skip to content

Commit 9cfe7d1

Browse files
committed
Fix singleton comparisons (None, True)
Checks should be done with "is None"/"is not None"
1 parent 47d49d8 commit 9cfe7d1

11 files changed

Lines changed: 26 additions & 26 deletions

File tree

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def get_requirements(lookup=None):
3333
'''get_requirements reads in requirements and versions from
3434
the lookup obtained with get_lookup'''
3535

36-
if lookup == None:
36+
if lookup is None:
3737
lookup = get_lookup()
3838

3939
install_requires = []
@@ -43,7 +43,7 @@ def get_requirements(lookup=None):
4343
if "exact_version" in module_meta:
4444
dependency = "%s==%s" %(module_name,module_meta['exact_version'])
4545
elif "min_version" in module_meta:
46-
if module_meta['min_version'] == None:
46+
if module_meta['min_version'] is None:
4747
dependency = module_name
4848
else:
4949
dependency = "%s>=%s" %(module_name,module_meta['min_version'])

spython/instance/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def generate_name(self, name=None):
4242
supply one.
4343
'''
4444
# If no name provided, use robot name
45-
if name == None:
45+
if name is None:
4646
name = self.RobotNamer.generate()
4747
self.name = name.replace('-','_')
4848

@@ -74,7 +74,7 @@ def _update_metadata(self, kwargs=None):
7474
'''
7575

7676
# If not given metadata, use instance.list to get it for container
77-
if kwargs == None and hasattr(self, 'name'):
77+
if kwargs is None and hasattr(self, 'name'):
7878
kwargs = self._list(self.name, quiet=True, return_json=True)
7979

8080
# Add acceptable arguments

spython/instance/cmd/start.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def start(self, image=None, name=None, args=None, sudo=False, options=[], captur
3030
check_install()
3131

3232
# If name provided, over write robot (default)
33-
if name != None:
33+
if name is not None:
3434
self.name = name
3535

3636
# If an image isn't provided, we have an initialized instance
@@ -57,7 +57,7 @@ def start(self, image=None, name=None, args=None, sudo=False, options=[], captur
5757
cmd = cmd + options + [image, self.name]
5858

5959
# If arguments are provided
60-
if args != None:
60+
if args is not None:
6161
if not isinstance(args, list):
6262
args = [args]
6363
cmd = cmd + args

spython/logger/spinner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def changing_arrows():
3131
for cursor in '<^>v': yield cursor
3232

3333
def select_generator(self, generator):
34-
if generator == None:
34+
if generator is None:
3535
generator = choice(['cursor',
3636
'arrow',
3737
'balloons'])

spython/main/base/command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def run_command(self, cmd,
125125
126126
'''
127127
# First preference to function, then to client setting
128-
if quiet == None:
128+
if quiet is None:
129129
quiet = self.quiet
130130

131131
result = run_cmd(cmd, sudo=sudo, capture=capture, quiet=quiet)

spython/main/export.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def export(self,
3434
# If not version 3, run deprecated command
3535
if 'version 3' in self.version() or '2.6' in self.version():
3636

37-
if output_file == None:
37+
if output_file is None:
3838
output_file = self._get_filename(image_path, 'sandbox')
3939

4040
return self.build(recipe=image_path,
@@ -79,7 +79,7 @@ def _export(self,
7979
cmd = self._init_command('export')
8080

8181
# If the user has specified export to pipe, we don't need a file
82-
if pipe == True:
82+
if pipe:
8383
cmd.append(image_path)
8484

8585
else:
@@ -94,7 +94,7 @@ def _export(self,
9494
return None
9595

9696
# if user has specified output file, move it there, return path
97-
if output_file != None:
97+
if output_file is not None:
9898
shutil.copyfile(tmptar, output_file)
9999
return output_file
100100
else:

spython/main/help.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def help(self, command=None):
1818
check_install()
1919

2020
cmd = ['singularity','--help']
21-
if command != None:
21+
if command is not None:
2222
cmd.append(command)
2323
help = self._run_command(cmd)
2424
return help

spython/main/instances.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def instances(self, name=None, return_json=False, quiet=False):
6666
for i in instances:
6767

6868
# If the user has provided a name, only add instance matches
69-
if name != None:
69+
if name is not None:
7070
if name != i['daemon_name']:
7171
continue
7272

@@ -89,7 +89,7 @@ def instances(self, name=None, return_json=False, quiet=False):
8989
bot.info('No instances found.')
9090

9191
# If we are given a name, return just one
92-
if name != None and instances not in [None,[]]:
92+
if name is not None and instances not in [None,[]]:
9393
if len(instances) == 1:
9494
instances = instances[0]
9595

spython/oci/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self,
3838
self.sudo = sudo
3939

4040
# If bundle is provided, create it
41-
if bundle != None and container_id != None and create:
41+
if bundle is not None and container_id is not None and create:
4242
self.bundle = bundle
4343
self.create(bundle, container_id, **kwargs)
4444

@@ -56,7 +56,7 @@ def get_container_id(self, container_id=None):
5656
'''
5757

5858
# The user must provide a container_id, or have one with the client
59-
if container_id == None and self.container_id == None:
59+
if container_id is None and self.container_id is None:
6060
bot.exit('You must provide a container_id.')
6161

6262
# Choose whichever is not None, with preference for function provided
@@ -72,7 +72,7 @@ def get_uri(self):
7272
# Naming
7373

7474
def __str__(self):
75-
if self.container_id != None:
75+
if self.container_id is not None:
7676
return "[singularity-python-oci:%s]" % self.container_id
7777
return "[singularity-python-oci]"
7878

@@ -92,7 +92,7 @@ def _get_sudo(self, sudo=None):
9292
==========
9393
sudo: if None, use self.sudo. Otherwise return sudo.
9494
'''
95-
if sudo == None:
95+
if sudo is None:
9696
sudo = self.sudo
9797
return sudo
9898

spython/oci/cmd/actions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ def _run(self, bundle,
119119
# Additional Logging Files
120120
cmd = cmd + ['--log-format', log_format]
121121

122-
if log_path != None:
122+
if log_path is not None:
123123
cmd = cmd + ['--log-path', log_path]
124-
if pid_file != None:
124+
if pid_file is not None:
125125
cmd = cmd + ['--pid-file', pid_file]
126-
if sync_socket != None:
126+
if sync_socket is not None:
127127
cmd = cmd + ['--sync-socket', sync_socket]
128128
if empty_process:
129129
cmd.append('--empty-process')
@@ -225,7 +225,7 @@ def execute(self, command=None, container_id=None, sudo=False, stream=False):
225225
# Add the container_id
226226
cmd.append(container_id)
227227

228-
if command != None:
228+
if command is not None:
229229
if not isinstance(command, list):
230230
command = [command]
231231

@@ -255,7 +255,7 @@ def update(self, container_id, from_file=None):
255255
# singularity oci delete
256256
cmd = self._init_command('update')
257257

258-
if from_file != None:
258+
if from_file is not None:
259259
cmd = cmd + ['--from-file', from_file]
260260

261261
# Add the container_id

0 commit comments

Comments
 (0)