Skip to content

Commit 1606f9a

Browse files
#1068 fixed a bunch of 'no-else-raise' warnings
1 parent 555dd70 commit 1606f9a

File tree

8 files changed

+31
-54
lines changed

8 files changed

+31
-54
lines changed

SoftLayer/CLI/block/access/authorize.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
@click.option('--virtual-id', '-v', multiple=True,
1515
help='The id of one SoftLayer_Virtual_Guest to authorize')
1616
@click.option('--ip-address-id', '-i', multiple=True,
17-
help='The id of one SoftLayer_Network_Subnet_IpAddress'
18-
' to authorize')
17+
help='The id of one SoftLayer_Network_Subnet_IpAddress to authorize')
1918
@click.option('--ip-address', multiple=True,
2019
help='An IP address to authorize')
2120
@environment.pass_env
@@ -30,16 +29,11 @@ def cli(env, volume_id, hardware_id, virtual_id, ip_address_id, ip_address):
3029
for ip_address_value in ip_address:
3130
ip_address_object = network_manager.ip_lookup(ip_address_value)
3231
if ip_address_object == "":
33-
click.echo("IP Address not found on your account. " +
34-
"Please confirm IP and try again.")
32+
click.echo("IP Address not found on your account. Please confirm IP and try again.")
3533
raise exceptions.ArgumentError('Incorrect IP Address')
36-
else:
37-
ip_address_id_list.append(ip_address_object['id'])
34+
ip_address_id_list.append(ip_address_object['id'])
3835

39-
block_manager.authorize_host_to_volume(volume_id,
40-
hardware_id,
41-
virtual_id,
42-
ip_address_id_list)
36+
block_manager.authorize_host_to_volume(volume_id, hardware_id, virtual_id, ip_address_id_list)
4337

4438
# If no exception was raised, the command succeeded
4539
click.echo('The specified hosts were authorized to access %s' % volume_id)

SoftLayer/CLI/file/access/authorize.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@ def cli(env, volume_id, hardware_id, virtual_id, ip_address_id,
3333
for ip_address_value in ip_address:
3434
ip_address_object = network_manager.ip_lookup(ip_address_value)
3535
if ip_address_object == "":
36-
click.echo("IP Address not found on your account. " +
37-
"Please confirm IP and try again.")
36+
click.echo("IP Address not found on your account. Please confirm IP and try again.")
3837
raise exceptions.ArgumentError('Incorrect IP Address')
39-
else:
40-
ip_address_id_list.append(ip_address_object['id'])
38+
ip_address_id_list.append(ip_address_object['id'])
4139

4240
file_manager.authorize_host_to_volume(volume_id,
4341
hardware_id,

SoftLayer/CLI/hardware/edit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
help="Tags to set or empty string to remove all")
1919
@click.option('--hostname', '-H', help="Host portion of the FQDN")
2020
@click.option('--userdata', '-u', help="User defined metadata string")
21-
@click.option('--public-speed', default=None, type=click.Choice(['0', '10', '100', '1000', '10000', '-1']),
21+
@click.option('--public-speed', default=None, type=click.Choice(['0', '10', '100', '1000', '10000', '-1']),
2222
help="Public port speed. -1 is best speed available")
2323
@click.option('--private-speed', default=None, type=click.Choice(['0', '10', '100', '1000', '10000', '-1']),
2424
help="Private port speed. -1 is best speed available")

SoftLayer/CLI/ticket/attach.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,25 @@
1111

1212
@click.command()
1313
@click.argument('identifier', type=int)
14-
@click.option('--hardware',
15-
'hardware_identifier',
14+
@click.option('--hardware', 'hardware_identifier',
1615
help="The identifier for hardware to attach")
17-
@click.option('--virtual',
18-
'virtual_identifier',
16+
@click.option('--virtual', 'virtual_identifier',
1917
help="The identifier for a virtual server to attach")
2018
@environment.pass_env
2119
def cli(env, identifier, hardware_identifier, virtual_identifier):
2220
"""Attach devices to a ticket."""
2321
ticket_mgr = SoftLayer.TicketManager(env.client)
2422

2523
if hardware_identifier and virtual_identifier:
26-
raise exceptions.ArgumentError(
27-
"Cannot attach hardware and a virtual server at the same time")
28-
elif hardware_identifier:
24+
raise exceptions.ArgumentError("Cannot attach hardware and a virtual server at the same time")
25+
26+
if hardware_identifier:
2927
hardware_mgr = SoftLayer.HardwareManager(env.client)
30-
hardware_id = helpers.resolve_id(hardware_mgr.resolve_ids,
31-
hardware_identifier,
32-
'hardware')
28+
hardware_id = helpers.resolve_id(hardware_mgr.resolve_ids, hardware_identifier, 'hardware')
3329
ticket_mgr.attach_hardware(identifier, hardware_id)
3430
elif virtual_identifier:
3531
vs_mgr = SoftLayer.VSManager(env.client)
36-
vs_id = helpers.resolve_id(vs_mgr.resolve_ids,
37-
virtual_identifier,
38-
'VS')
32+
vs_id = helpers.resolve_id(vs_mgr.resolve_ids, virtual_identifier, 'VS')
3933
ticket_mgr.attach_virtual_server(identifier, vs_id)
4034
else:
41-
raise exceptions.ArgumentError(
42-
"Must have a hardware or virtual server identifier to attach")
35+
raise exceptions.ArgumentError("Must have a hardware or virtual server identifier to attach")

SoftLayer/CLI/ticket/detach.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,25 @@
1111

1212
@click.command()
1313
@click.argument('identifier', type=int)
14-
@click.option('--hardware',
15-
'hardware_identifier',
14+
@click.option('--hardware', 'hardware_identifier',
1615
help="The identifier for hardware to detach")
17-
@click.option('--virtual',
18-
'virtual_identifier',
16+
@click.option('--virtual', 'virtual_identifier',
1917
help="The identifier for a virtual server to detach")
2018
@environment.pass_env
2119
def cli(env, identifier, hardware_identifier, virtual_identifier):
2220
"""Detach devices from a ticket."""
2321
ticket_mgr = SoftLayer.TicketManager(env.client)
2422

2523
if hardware_identifier and virtual_identifier:
26-
raise exceptions.ArgumentError(
27-
"Cannot detach hardware and a virtual server at the same time")
28-
elif hardware_identifier:
24+
raise exceptions.ArgumentError("Cannot detach hardware and a virtual server at the same time")
25+
26+
if hardware_identifier:
2927
hardware_mgr = SoftLayer.HardwareManager(env.client)
30-
hardware_id = helpers.resolve_id(hardware_mgr.resolve_ids,
31-
hardware_identifier,
32-
'hardware')
28+
hardware_id = helpers.resolve_id(hardware_mgr.resolve_ids, hardware_identifier, 'hardware')
3329
ticket_mgr.detach_hardware(identifier, hardware_id)
3430
elif virtual_identifier:
3531
vs_mgr = SoftLayer.VSManager(env.client)
36-
vs_id = helpers.resolve_id(vs_mgr.resolve_ids,
37-
virtual_identifier,
38-
'VS')
32+
vs_id = helpers.resolve_id(vs_mgr.resolve_ids, virtual_identifier, 'VS')
3933
ticket_mgr.detach_virtual_server(identifier, vs_id)
4034
else:
41-
raise exceptions.ArgumentError(
42-
"Must have a hardware or virtual server identifier to detach")
35+
raise exceptions.ArgumentError("Must have a hardware or virtual server identifier to detach")

SoftLayer/managers/vs.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,14 +428,13 @@ def _create_network_components(
428428
if public_subnet:
429429
if public_vlan is None:
430430
raise exceptions.SoftLayerError("You need to specify a public_vlan with public_subnet")
431-
else:
432-
parameters['primaryNetworkComponent']['networkVlan']['primarySubnet'] = {'id': int(public_subnet)}
431+
432+
parameters['primaryNetworkComponent']['networkVlan']['primarySubnet'] = {'id': int(public_subnet)}
433433
if private_subnet:
434434
if private_vlan is None:
435435
raise exceptions.SoftLayerError("You need to specify a private_vlan with private_subnet")
436-
else:
437-
parameters['primaryBackendNetworkComponent']['networkVlan']['primarySubnet'] = {
438-
"id": int(private_subnet)}
436+
437+
parameters['primaryBackendNetworkComponent']['networkVlan']['primarySubnet'] = {'id': int(private_subnet)}
439438

440439
return parameters
441440

SoftLayer/managers/vs_placement.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ def create(self, placement_object):
5757
'name': 'Test Name',
5858
'ruleId': 12345
5959
}
60-
60+
6161
- https://softlayer.github.io/reference/datatypes/SoftLayer_Virtual_PlacementGroup/
6262
63-
:param dictionary placement_object:
63+
:param dictionary placement_object:
6464
6565
"""
6666
return self.client.call('SoftLayer_Virtual_PlacementGroup', 'createObject', placement_object)

SoftLayer/transports.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@ def __call__(self, request):
402402
except ValueError as json_ex:
403403
if ex.response.text == "":
404404
raise exceptions.SoftLayerAPIError(resp.status_code, "Empty response.")
405-
else:
406-
raise exceptions.SoftLayerAPIError(resp.status_code, str(json_ex))
405+
406+
raise exceptions.SoftLayerAPIError(resp.status_code, str(json_ex))
407407

408408
raise exceptions.SoftLayerAPIError(ex.response.status_code, message)
409409
except requests.RequestException as ex:

0 commit comments

Comments
 (0)