Skip to content

Commit 5c9fedc

Browse files
committed
more fixes to linting
Signed-off-by: Vanessa Sochat <vsochat@stanford.edu>
1 parent ce9125a commit 5c9fedc

15 files changed

Lines changed: 76 additions & 71 deletions

File tree

.pylintrc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,14 @@ confidence=
6363
disable=attribute-defined-outside-init,
6464
bad-continuation,
6565
bare-except,
66-
blacklisted-name,
6766
duplicate-code,
6867
fixme,
6968
invalid-name,
70-
len-as-condition,
7169
line-too-long,
7270
missing-docstring,
73-
multiple-statements,
7471
no-member,
7572
protected-access,
7673
R,
77-
redefined-builtin,
78-
redefined-outer-name,
7974
trailing-whitespace,
8075
unused-argument,
8176
wrong-import-order

spython/client/__init__.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def main():
9797

9898
parser = get_parser()
9999

100-
def help(return_code=0):
100+
def print_help(return_code=0):
101101
'''print help, including the software version and active client
102102
and exit with return code.
103103
'''
@@ -107,15 +107,15 @@ def help(return_code=0):
107107
sys.exit(return_code)
108108

109109
if len(sys.argv) == 1:
110-
help()
110+
print_help()
111111
try:
112112
# We capture all primary arguments, and take secondary to pass on
113113
args, options = parser.parse_known_args()
114114
except:
115115
sys.exit(0)
116116

117117
# The main function
118-
main = None
118+
func = None
119119

120120
# If the user wants the version
121121
if args.version is True:
@@ -126,14 +126,21 @@ def help(return_code=0):
126126
set_verbosity(args)
127127

128128
# Does the user want help for a subcommand?
129-
if args.command == 'recipe': from .recipe import main
130-
elif args.command == 'shell': from .shell import main
131-
elif args.command == 'test': from .test import main
132-
else: help()
129+
if args.command == 'recipe':
130+
from .recipe import main as func
131+
132+
elif args.command == 'shell':
133+
from .shell import main as func
134+
135+
elif args.command == 'test':
136+
from .test import main as func
137+
138+
else:
139+
print_help()
133140

134141
# Pass on to the correct parser
135142
if args.command is not None:
136-
main(args=args, options=options, parser=parser)
143+
func(args=args, options=options, parser=parser)
137144

138145

139146
if __name__ == '__main__':

spython/client/shell.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
def main(args, options, parser):
1010
# If we have options, first is image
1111
image = None
12-
if len(options) > 0:
12+
if options:
1313
image = options.pop(0)
1414

1515
lookup = {'ipython': ipython,
1616
'python': python,
17-
'bpython': bpython}
17+
'bpython': run_bpython}
1818

1919
shells = ['ipython', 'python', 'bpython']
2020

@@ -53,7 +53,7 @@ def ipython(image):
5353

5454
embed()
5555

56-
def bpython(image):
56+
def run_bpython(image):
5757
'''give the user a bpython shell
5858
'''
5959
client = prepare_client(image)

spython/instance/cmd/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def generate_instance_commands():
1515
from spython.instance import Instance
1616

1717
from spython.main.base.logger import println
18-
from spython.main.instances import instances
18+
from spython.main.instances import list_instances
1919
from spython.utils import run_command as run_cmd
2020

2121
# run_command uses run_cmd, but wraps to catch error
@@ -28,7 +28,7 @@ def generate_instance_commands():
2828
Instance._init_command = init_command
2929
Instance.run_command = run_cmd
3030
Instance._run_command = run_command
31-
Instance._list = instances # list command is used to get metadata
31+
Instance._list = list_instances # list command is used to get metadata
3232
Instance._println = println
3333
Instance.start = start # intended to be called on init, not by user
3434
Instance.stop = stop

spython/logger/progress.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def bar(it, label='', width=32, hide=None, empty_char=BAR_EMPTY_CHAR,
106106

107107
with ProgressBar(label=label, width=width, hide=hide, empty_char=BAR_EMPTY_CHAR,
108108
filled_char=BAR_FILLED_CHAR, expected_size=count, every=every) \
109-
as bar:
109+
as pbar:
110110
for i, item in enumerate(it):
111111
yield item
112-
bar.show(i + 1)
112+
pbar.show(i + 1)

spython/logger/spinner.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,20 @@ class Spinner:
1818
@staticmethod
1919
def spinning_cursor():
2020
while 1:
21-
for cursor in '|/-\\': yield cursor
21+
for cursor in '|/-\\':
22+
yield cursor
2223

2324
@staticmethod
2425
def balloons_cursor():
2526
while 1:
26-
for cursor in '. o O @ *': yield cursor
27+
for cursor in '. o O @ *':
28+
yield cursor
2729

2830
@staticmethod
2931
def changing_arrows():
3032
while 1:
31-
for cursor in '<^>v': yield cursor
33+
for cursor in '<^>v':
34+
yield cursor
3235

3336
def select_generator(self, generator):
3437
if generator is None:
@@ -47,7 +50,8 @@ def __init__(self, delay=None, generator=None):
4750
self.spinner_generator = self.changing_arrows()
4851
elif generator == 'balloons':
4952
self.spinner_generator = self.balloons_cursor()
50-
if delay is None: delay = 0.2
53+
if delay is None:
54+
delay = 0.2
5155
else:
5256
self.spinner_generator = self.spinning_cursor()
5357

spython/main/__init__.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,53 +18,53 @@ def get_client(quiet=False, debug=False):
1818
1919
'''
2020
from spython.utils import get_singularity_version
21-
from .base import Client
21+
from .base import Client as client
2222

23-
Client.quiet = quiet
24-
Client.debug = debug
23+
client.quiet = quiet
24+
client.debug = debug
2525

2626
# Do imports here, can be customized
2727
from .apps import apps
2828
from .build import build
2929
from .execute import execute
30-
from .help import help
30+
from .help import helpcmd
3131
from .inspect import inspect
32-
from .instances import (instances, stopall) # global instance commands
32+
from .instances import (list_instances, stopall) # global instance commands
3333
from .run import run
3434
from .pull import pull
3535
from .export import (export, _export)
3636

3737
# Actions
38-
Client.apps = apps
39-
Client.build = build
40-
Client.execute = execute
41-
Client.export = export
42-
Client._export = _export
43-
Client.help = help
44-
Client.inspect = inspect
45-
Client.instances = instances
46-
Client.run = run
47-
Client.pull = pull
38+
client.apps = apps
39+
client.build = build
40+
client.execute = execute
41+
client.export = export
42+
client._export = _export
43+
client.help = helpcmd
44+
client.inspect = inspect
45+
client.instances = list_instances
46+
client.run = run
47+
client.pull = pull
4848

4949
# Command Groups, Images
5050
from spython.image.cmd import generate_image_commands # deprecated
51-
Client.image = generate_image_commands()
51+
client.image = generate_image_commands()
5252

5353
# Commands Groups, Instances
5454
from spython.instance.cmd import generate_instance_commands # instance level commands
55-
Client.instance = generate_instance_commands()
56-
Client.instance_stopall = stopall
57-
Client.instance.version = Client.version
55+
client.instance = generate_instance_commands()
56+
client.instance_stopall = stopall
57+
client.instance.version = client.version
5858

5959
# Commands Groups, OCI (Singularity version 3 and up)
6060
if "version 3" in get_singularity_version():
6161
from spython.oci.cmd import generate_oci_commands
62-
Client.oci = generate_oci_commands()() # first () runs function, second
62+
client.oci = generate_oci_commands()() # first () runs function, second
6363
# initializes OciImage class
64-
Client.oci.debug = Client.debug
65-
Client.oci.quiet = Client.quiet
66-
Client.oci.OciImage.quiet = Client.quiet
67-
Client.oci.OciImage.debug = Client.debug
64+
client.oci.debug = client.debug
65+
client.oci.quiet = client.quiet
66+
client.oci.OciImage.quiet = client.quiet
67+
client.oci.OciImage.debug = client.debug
6868

6969

7070
# Initialize

spython/main/apps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def apps(self, image=None, full_path=False, root=''):
3232
if full_path is True:
3333
root = '/scif/apps/'
3434

35-
if len(output) > 0:
35+
if output:
3636
output = ''.join(output).split('\n')
3737
output = ['%s%s' %(root, x) for x in output if x]
3838

spython/main/help.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
77

88

9-
def help(self, command=None):
9+
def helpcmd(self, command=None):
1010
'''help prints the general function help, or help for a specific command
1111
1212
Parameters
@@ -20,5 +20,4 @@ def help(self, command=None):
2020
cmd = ['singularity', '--help']
2121
if command is not None:
2222
cmd.append(command)
23-
help = self._run_command(cmd)
24-
return help
23+
return self._run_command(cmd)

spython/main/instances.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from spython.logger import bot
1010
from spython.utils import run_command
1111

12-
def instances(self, name=None, return_json=False, quiet=False):
12+
def list_instances(self, name=None, return_json=False, quiet=False):
1313
'''list instances. For Singularity, this is provided as a command sub
1414
group.
1515

0 commit comments

Comments
 (0)