Skip to content

Commit f038ddd

Browse files
committed
Improves Style Issues
1 parent 680eabf commit f038ddd

8 files changed

Lines changed: 52 additions & 42 deletions

File tree

SoftLayer/CLI/core.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
# pylint: disable=too-many-public-methods, broad-except, unused-argument
2121
# pylint: disable=redefined-builtin, super-init-not-called
2222

23+
# Disable the cyclic import error. This is handled by an inline import.
24+
# pylint: disable=cyclic-import
25+
2326
DEBUG_LOGGING_MAP = {
2427
0: logging.CRITICAL,
2528
1: logging.WARNING,
@@ -160,8 +163,8 @@ def cli(ctx,
160163
if env.client is None:
161164
# Environment can be passed in explicitly. This is used for testing
162165
if fixtures:
163-
from SoftLayer import testing
164-
real_client = testing.FixtureClient()
166+
from SoftLayer import fixture_client
167+
real_client = fixture_client.FixtureClient()
165168
else:
166169
# Create SL Client
167170
real_client = SoftLayer.Client(proxy=proxy, config_file=config)

SoftLayer/CLI/environment.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
class Environment(object):
2323
"""Provides access to the current CLI environment."""
24+
2425
def __init__(self):
2526
# {'path:to:command': ModuleLoader()}
2627
# {'vs:list': ModuleLoader()}
@@ -70,9 +71,12 @@ def list_commands(self, *path):
7071

7172
commands = []
7273
for command in self.commands.keys():
74+
7375
# Filter based on prefix and the segment length
7476
if all([command.startswith(path_str),
7577
len(path) == command.count(":")]):
78+
79+
# offset is used to exclude the path that the caller requested.
7680
offset = len(path_str)+1 if path_str else 0
7781
commands.append(command[offset:])
7882

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def __getitem__(self, service_name):
4141
return service
4242

4343
def call(self, service, method, *args, **kwargs):
44+
"""Call the method on the service."""
4445
return getattr(self[service], method)(*args, **kwargs)
4546

4647
def reset_mock(self):
@@ -88,6 +89,7 @@ def _wrap_fixture(fixture):
8889
return call_handler
8990

9091
def wrapped(*args, **kwargs):
92+
"""When this is called, return the fixture (ignoring the arguments)."""
9193
return fixture
9294

9395
return wrapped

SoftLayer/testing/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from SoftLayer.CLI import core
1616
from SoftLayer.CLI import environment
17-
from SoftLayer.testing import fixture_client
17+
from SoftLayer import fixture_client
1818

1919
from click import testing
2020

@@ -47,12 +47,17 @@ def run_command(self,
4747
env=None,
4848
fixtures=True,
4949
fmt='json'):
50+
"""A helper that runs a SoftLayer CLI command.
5051
51-
runner = testing.CliRunner()
52-
if fixtures:
52+
This returns a click.testing.Result object.
53+
"""
54+
args = args or []
55+
56+
if fixtures is True:
5357
args.insert(0, '--fixtures')
5458
args.insert(0, '--format=%s' % fmt)
5559

60+
runner = testing.CliRunner()
5661
return runner.invoke(core.cli, args=args, obj=env or self.env)
5762

5863
__all__ = ['unittest', 'FixtureClient']

SoftLayer/utils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99

1010
import six
1111

12+
# pylint: disable=pointless-except, no-member, invalid-name
13+
1214
UUID_RE = re.compile(r'^[0-9a-f\-]{36}$', re.I)
1315
KNOWN_OPERATIONS = ['<=', '>=', '<', '>', '~', '!~', '*=', '^=', '$=', '_=']
1416

15-
configparser = six.moves.configparser # pylint: disable=E1101,C0103
16-
console_input = six.moves.input # pylint: disable=E1101,C0103
17-
string_types = six.string_types # pylint: disable=C0103
18-
StringIO = six.StringIO # pylint: disable=C0103
19-
xmlrpc_client = six.moves.xmlrpc_client # pylint: disable=E1101,C0103
17+
configparser = six.moves.configparser
18+
console_input = six.moves.input
19+
string_types = six.string_types
20+
StringIO = six.StringIO
21+
xmlrpc_client = six.moves.xmlrpc_client
2022

2123

2224
def lookup(dic, key, *keys):

fabfile.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ def upload():
1818

1919
def clean():
2020
puts("* Cleaning Repo")
21-
dirs = ['.tox', 'SoftLayer.egg-info', 'build', 'dist']
22-
for d in dirs:
23-
if os.path.exists(d) and os.path.isdir(d):
24-
shutil.rmtree(d)
21+
directories = ['.tox', 'SoftLayer.egg-info', 'build', 'dist']
22+
for directory in directories:
23+
if os.path.exists(directory) and os.path.isdir(directory):
24+
shutil.rmtree(directory)
2525

2626

2727
def release(version, force=False):
@@ -37,8 +37,8 @@ def release(version, force=False):
3737
clean()
3838

3939
puts(" * Tagging Version %s" % version_str)
40-
f = 'f' if force else ''
41-
local("git tag -%sam \"%s\" %s" % (f, version_str, version_str))
40+
force_option = 'f' if force else ''
41+
local("git tag -%sam \"%s\" %s" % (force_option, version_str, version_str))
4242

4343
local("pip install wheel")
4444

setup.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import sys
23
import os
34

@@ -13,34 +14,29 @@
1314
print("Python 2.6 or greater is required.")
1415
sys.exit(1)
1516

16-
extra = {}
17-
18-
requires = [
17+
REQUIRES = [
1918
'six >= 1.7.0',
2019
'prettytable >= 0.7.0',
2120
'click',
2221
'requests',
2322
]
2423

2524
if sys.version_info < (2, 7):
26-
requires.append('importlib')
25+
REQUIRES.append('importlib')
2726

28-
description = "A library for SoftLayer's API"
27+
DESCRIPTION = "A library for SoftLayer's API"
2928

3029
if os.path.exists('README.rst'):
31-
f = open('README.rst')
32-
try:
33-
long_description = f.read()
34-
finally:
35-
f.close()
30+
with open('README.rst') as readme_file:
31+
LONG_DESCRIPTION = readme_file.read()
3632
else:
37-
long_description = description
33+
LONG_DESCRIPTION = DESCRIPTION
3834

3935
setup(
4036
name='SoftLayer',
4137
version='3.3.0',
42-
description=description,
43-
long_description=long_description,
38+
description=DESCRIPTION,
39+
long_description=LONG_DESCRIPTION,
4440
author='SoftLayer Technologies, Inc.',
4541
author_email='[email protected]',
4642
packages=find_packages(exclude=["SoftLayer.tests"]),
@@ -50,9 +46,9 @@
5046
entry_points={
5147
'console_scripts': ['sl = SoftLayer.CLI.core:main'],
5248
},
53-
package_data={'SoftLayer': ['tests/fixtures/*.conf']},
5449
test_suite='nose.collector',
55-
install_requires=requires,
50+
install_requires=REQUIRES,
51+
keywords=['softlayer', 'cloud'],
5652
classifiers=[
5753
'Environment :: Console',
5854
'Environment :: Web Environment',
@@ -69,5 +65,4 @@
6965
'Programming Language :: Python :: Implementation :: CPython',
7066
'Programming Language :: Python :: Implementation :: PyPy',
7167
],
72-
**extra
7368
)

tox.ini

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,21 @@ commands =
2424
flake8 SoftLayer
2525
pylint SoftLayer \
2626
-r n \ # Don't show the long report
27-
--ignore=tests,testing \
28-
-d R0903 \ # Too few public methods
29-
-d R0914 \ # Too many local variables
30-
-d R0201 \ # Method could be a function
31-
-d I0011 \ # Locally Disabling
32-
-d W0142 \ # Used * or ** magic
27+
--ignore=tests,fixtures \
28+
-d too-many-locals \ # Too many local variables
29+
-d no-self-use \ # Method could be a function
30+
-d star-args \ # Used * or ** magic
31+
-d I0011 \ # Locally Disabling
3332
--max-args=20 \
3433
--max-branches=40 \
3534
--max-statements=86 \
3635
--max-module-lines=1200 \
3736
--max-returns=8 \
37+
--min-public-methods=0 \
3838
--min-similarity-lines=50
39-
pylint SoftLayer/testing \
40-
-d C0103 \ # Fixtures don't follow proper naming conventions
41-
-d C0111 \ # Fixtures don't have docstrings
42-
-d I0011 \ # Locally Disabling
39+
pylint SoftLayer/testing/fixtures \
40+
-d invalid-name \ # Fixtures don't follow proper naming conventions
41+
-d missing-docstring \ # Fixtures don't have docstrings
4342
--max-module-lines=2000 \
4443
--min-similarity-lines=50 \
4544
-r n

0 commit comments

Comments
 (0)