Enable check for E127

E127 continuation line over-indented for visual indent

Change-Id: I9dfd489565ee2d1469b2048a930c3a8384dd245d
This commit is contained in:
Andrey Kurilin 2014-09-24 23:45:27 +03:00
parent 8de2237cc4
commit ae6c39397e
20 changed files with 120 additions and 144 deletions

@ -765,7 +765,10 @@ class OpenStackComputeShell(object):
commands.remove('bash_completion') commands.remove('bash_completion')
print(' '.join(commands | options)) print(' '.join(commands | options))
@utils.arg('command', metavar='<subcommand>', nargs='?', @utils.arg(
'command',
metavar='<subcommand>',
nargs='?',
help='Display help for <subcommand>') help='Display help for <subcommand>')
def do_help(self, args): def do_help(self, args):
""" """

@ -45,8 +45,8 @@ class FakeClient(object):
assert self.client.callstack, \ assert self.client.callstack, \
"Expected %s %s but no calls were made." % expected "Expected %s %s but no calls were made." % expected
assert expected == called, 'Expected %s %s; got %s %s' % \ assert expected == called, \
(expected + called) 'Expected %s %s; got %s %s' % (expected + called)
if body is not None: if body is not None:
if self.client.callstack[pos][2] != body: if self.client.callstack[pos][2] != body:
@ -68,8 +68,7 @@ class FakeClient(object):
found = True found = True
break break
assert found, 'Expected %s; got %s' % \ assert found, 'Expected %s; got %s' % (expected, self.client.callstack)
(expected, self.client.callstack)
if body is not None: if body is not None:
try: try:
assert entry[2] == body assert entry[2] == body

@ -57,9 +57,8 @@ class ClientTest(utils.TestCase):
} }
with mock.patch('requests.request', mock_request): with mock.patch('requests.request', mock_request):
instance.authenticate() instance.authenticate()
requests.request.assert_called_with(mock.ANY, mock.ANY, requests.request.assert_called_with(
timeout=2, mock.ANY, mock.ANY, timeout=2, headers=mock.ANY,
headers=mock.ANY,
verify=mock.ANY) verify=mock.ANY)
def test_client_reauth(self): def test_client_reauth(self):
@ -220,10 +219,8 @@ class ClientTest(utils.TestCase):
fake_attribute_name1 = "FakeAttribute1" fake_attribute_name1 = "FakeAttribute1"
fake_attribute_name2 = "FakeAttribute2" fake_attribute_name2 = "FakeAttribute2"
extensions = [ extensions = [
novaclient.extension.Extension(fake_attribute_name1, novaclient.extension.Extension(fake_attribute_name1, fakes),
fakes), novaclient.extension.Extension(fake_attribute_name2, utils),
novaclient.extension.Extension(fake_attribute_name2,
utils),
] ]
cs = novaclient.v3.client.Client("user", "password", "project_id", cs = novaclient.v3.client.Client("user", "password", "project_id",

@ -895,14 +895,13 @@ class FakeHTTPClient(base_client.HTTPClient):
def get_os_floating_ip_dns_testdomain_entries(self, **kw): def get_os_floating_ip_dns_testdomain_entries(self, **kw):
if kw.get('ip'): if kw.get('ip'):
return (205, {}, {'dns_entries': return (205, {}, {
[{'dns_entry': 'dns_entries': [
{'ip': kw.get('ip'), {'dns_entry': {'ip': kw.get('ip'),
'name': "host1", 'name': "host1",
'type': "A", 'type': "A",
'domain': 'testdomain'}}, 'domain': 'testdomain'}},
{'dns_entry': {'dns_entry': {'ip': kw.get('ip'),
{'ip': kw.get('ip'),
'name': "host2", 'name': "host2",
'type': "A", 'type': "A",
'domain': 'testdomain'}}]}) 'domain': 'testdomain'}}]})
@ -910,8 +909,8 @@ class FakeHTTPClient(base_client.HTTPClient):
return (404, {}, None) return (404, {}, None)
def get_os_floating_ip_dns_testdomain_entries_testname(self, **kw): def get_os_floating_ip_dns_testdomain_entries_testname(self, **kw):
return (205, {}, {'dns_entry': return (205, {}, {
{'ip': "10.10.10.10", 'dns_entry': {'ip': "10.10.10.10",
'name': 'testname', 'name': 'testname',
'type': "A", 'type': "A",
'domain': 'testdomain'}}) 'domain': 'testdomain'}})
@ -1271,8 +1270,7 @@ class FakeHTTPClient(base_client.HTTPClient):
return (200, {}, {"security_groups": [ return (200, {}, {"security_groups": [
{"name": "test", {"name": "test",
"description": "FAKE_SECURITY_GROUP", "description": "FAKE_SECURITY_GROUP",
"tenant_id": "tenant_id": "4ffc664c198e435e9853f2538fbcd7a7",
"4ffc664c198e435e9853f2538fbcd7a7",
"id": 1, "id": 1,
"rules": [ "rules": [
{"id": 11, {"id": 11,
@ -1363,7 +1361,8 @@ class FakeHTTPClient(base_client.HTTPClient):
def post_os_security_group_rules(self, body, **kw): def post_os_security_group_rules(self, body, **kw):
assert list(body) == ['security_group_rule'] assert list(body) == ['security_group_rule']
fakes.assert_has_keys(body['security_group_rule'], fakes.assert_has_keys(
body['security_group_rule'],
required=['parent_group_id'], required=['parent_group_id'],
optional=['group_id', 'ip_protocol', 'from_port', optional=['group_id', 'ip_protocol', 'from_port',
'to_port', 'cidr']) 'to_port', 'cidr'])
@ -2160,12 +2159,10 @@ class FakeHTTPClient(base_client.HTTPClient):
def post_os_server_groups(self, body, **kw): def post_os_server_groups(self, body, **kw):
return self._return_server_group() return self._return_server_group()
def get_os_server_groups_2cbd51f4_fafe_4cdb_801b_cf913a6f288b(self, def get_os_server_groups_2cbd51f4_fafe_4cdb_801b_cf913a6f288b(self, **kw):
**kw):
return self._return_server_group() return self._return_server_group()
def put_os_server_groups_2cbd51f4_fafe_4cdb_801b_cf913a6f288b(self, def put_os_server_groups_2cbd51f4_fafe_4cdb_801b_cf913a6f288b(self, **kw):
**kw):
return self._return_server_group() return self._return_server_group()
def post_os_server_groups_2cbd51f4_fafe_4cdb_801b_cf913a6f288b_action( def post_os_server_groups_2cbd51f4_fafe_4cdb_801b_cf913a6f288b_action(

@ -28,5 +28,5 @@ class TestFloatingIPPools(utils.FixturedTestCase):
def test_list_floating_ips(self): def test_list_floating_ips(self):
fl = self.cs.floating_ip_pools.list() fl = self.cs.floating_ip_pools.list()
self.assert_called('GET', '/os-floating-ip-pools') self.assert_called('GET', '/os-floating-ip-pools')
[self.assertIsInstance(f, floating_ip_pools.FloatingIPPool) for f in fl:
for f in fl] self.assertIsInstance(f, floating_ip_pools.FloatingIPPool)

@ -46,8 +46,8 @@ class FloatingIPsBulkTest(utils.FixturedTestCase):
def test_create_floating_ips_bulk_with_pool_and_host(self): def test_create_floating_ips_bulk_with_pool_and_host(self):
fl = self.cs.floating_ips_bulk.create('192.168.1.0/30', 'poolTest', fl = self.cs.floating_ips_bulk.create('192.168.1.0/30', 'poolTest',
'interfaceTest') 'interfaceTest')
body = {'floating_ips_bulk_create': body = {'floating_ips_bulk_create': {
{'ip_range': '192.168.1.0/30', 'pool': 'poolTest', 'ip_range': '192.168.1.0/30', 'pool': 'poolTest',
'interface': 'interfaceTest'}} 'interface': 'interfaceTest'}}
self.assert_called('POST', '/os-floating-ips-bulk', body) self.assert_called('POST', '/os-floating-ips-bulk', body)
self.assertEqual(fl.ip_range, self.assertEqual(fl.ip_range,

@ -800,8 +800,8 @@ class ShellTest(utils.TestCase):
) )
def test_create_image_show(self): def test_create_image_show(self):
output = self.run_command('image-create ' output = self.run_command(
'sample-server mysnapshot --show') 'image-create sample-server mysnapshot --show')
self.assert_called_anytime( self.assert_called_anytime(
'POST', '/servers/1234/action', 'POST', '/servers/1234/action',
{'createImage': {'name': 'mysnapshot', 'metadata': {}}}, {'createImage': {'name': 'mysnapshot', 'metadata': {}}},
@ -2243,10 +2243,8 @@ class ShellTest(utils.TestCase):
mock.mock_open(read_data='FAKE_PUBLIC_KEY')) mock.mock_open(read_data='FAKE_PUBLIC_KEY'))
def test_keypair_import(self): def test_keypair_import(self):
self.run_command('keypair-add --pub-key test.pub test') self.run_command('keypair-add --pub-key test.pub test')
self.assert_called('POST', '/os-keypairs', self.assert_called('POST', '/os-keypairs', {
{'keypair': 'keypair': {'public_key': 'FAKE_PUBLIC_KEY', 'name': 'test'}})
{'public_key': 'FAKE_PUBLIC_KEY',
'name': 'test'}})
def test_keypair_list(self): def test_keypair_list(self):
self.run_command('keypair-list') self.run_command('keypair-list')
@ -2263,8 +2261,7 @@ class ShellTest(utils.TestCase):
def test_create_server_group(self): def test_create_server_group(self):
self.run_command('server-group-create wjsg affinity') self.run_command('server-group-create wjsg affinity')
self.assert_called('POST', '/os-server-groups', self.assert_called('POST', '/os-server-groups',
{'server_group': {'server_group': {'name': 'wjsg',
{'name': 'wjsg',
'policies': ['affinity']}}) 'policies': ['affinity']}})
def test_delete_multi_server_groups(self): def test_delete_multi_server_groups(self):

@ -56,8 +56,7 @@ class FloatingIPDNSDomainManager(base.Manager):
def create_private(self, fqdomain, availability_zone): def create_private(self, fqdomain, availability_zone):
"""Add or modify a private DNS domain.""" """Add or modify a private DNS domain."""
body = {'domain_entry': body = {'domain_entry': {'scope': 'private',
{'scope': 'private',
'availability_zone': availability_zone}} 'availability_zone': availability_zone}}
return self._update('/os-floating-ip-dns/%s' % _quote_domain(fqdomain), return self._update('/os-floating-ip-dns/%s' % _quote_domain(fqdomain),
body, body,
@ -65,13 +64,10 @@ class FloatingIPDNSDomainManager(base.Manager):
def create_public(self, fqdomain, project): def create_public(self, fqdomain, project):
"""Add or modify a public DNS domain.""" """Add or modify a public DNS domain."""
body = {'domain_entry': body = {'domain_entry': {'scope': 'public', 'project': project}}
{'scope': 'public',
'project': project}}
return self._update('/os-floating-ip-dns/%s' % _quote_domain(fqdomain), return self._update('/os-floating-ip-dns/%s' % _quote_domain(fqdomain),
body, body, 'domain_entry')
'domain_entry')
def delete(self, fqdomain): def delete(self, fqdomain):
"""Delete the specified domain.""" """Delete the specified domain."""
@ -83,8 +79,7 @@ class FloatingIPDNSEntry(base.Resource):
self.manager.delete(self.name, self.domain) self.manager.delete(self.name, self.domain)
def create(self): def create(self):
self.manager.create(self.domain, self.name, self.manager.create(self.domain, self.name, self.ip, self.dns_type)
self.ip, self.dns_type)
def get(self): def get(self):
return self.manager.get(self.domain, self.name) return self.manager.get(self.domain, self.name)
@ -96,8 +91,7 @@ class FloatingIPDNSEntryManager(base.Manager):
def get(self, domain, name): def get(self, domain, name):
"""Return a list of entries for the given domain and ip or name.""" """Return a list of entries for the given domain and ip or name."""
return self._get("/os-floating-ip-dns/%s/entries/%s" % return self._get("/os-floating-ip-dns/%s/entries/%s" %
(_quote_domain(domain), name), (_quote_domain(domain), name), "dns_entry")
"dns_entry")
def get_for_ip(self, domain, ip): def get_for_ip(self, domain, ip):
"""Return a list of entries for the given domain and ip or name.""" """Return a list of entries for the given domain and ip or name."""
@ -105,30 +99,21 @@ class FloatingIPDNSEntryManager(base.Manager):
params = "?%s" % parse.urlencode(qparams) params = "?%s" % parse.urlencode(qparams)
return self._list("/os-floating-ip-dns/%s/entries%s" % return self._list("/os-floating-ip-dns/%s/entries%s" %
(_quote_domain(domain), params), (_quote_domain(domain), params), "dns_entries")
"dns_entries")
def create(self, domain, name, ip, dns_type): def create(self, domain, name, ip, dns_type):
"""Add a new DNS entry.""" """Add a new DNS entry."""
body = {'dns_entry': body = {'dns_entry': {'ip': ip, 'dns_type': dns_type}}
{'ip': ip,
'dns_type': dns_type}}
return self._update("/os-floating-ip-dns/%s/entries/%s" % return self._update("/os-floating-ip-dns/%s/entries/%s" %
(_quote_domain(domain), name), (_quote_domain(domain), name), body, "dns_entry")
body,
"dns_entry")
def modify_ip(self, domain, name, ip): def modify_ip(self, domain, name, ip):
"""Add a new DNS entry.""" """Add a new DNS entry."""
body = {'dns_entry': body = {'dns_entry': {'ip': ip, 'dns_type': 'A'}}
{'ip': ip,
'dns_type': 'A'}}
return self._update("/os-floating-ip-dns/%s/entries/%s" % return self._update("/os-floating-ip-dns/%s/entries/%s" %
(_quote_domain(domain), name), (_quote_domain(domain), name), body, "dns_entry")
body,
"dns_entry")
def delete(self, domain, name): def delete(self, domain, name):
"""Delete entry specified by name and domain.""" """Delete entry specified by name and domain."""

@ -87,8 +87,8 @@ class ImageManager(base.ManagerWithFind):
:param metadata: A dict of metadata to add to the image :param metadata: A dict of metadata to add to the image
""" """
body = {'metadata': metadata} body = {'metadata': metadata}
return self._create("/images/%s/metadata" % base.getid(image), body, return self._create("/images/%s/metadata" % base.getid(image),
"metadata") body, "metadata")
def delete_meta(self, image, keys): def delete_meta(self, image, keys):
""" """

@ -2367,8 +2367,8 @@ def _print_secgroups(secgroups):
def _get_secgroup(cs, secgroup): def _get_secgroup(cs, secgroup):
# Check secgroup is an ID (nova-network) or UUID (neutron) # Check secgroup is an ID (nova-network) or UUID (neutron)
if (utils.is_integer_like(encodeutils.safe_encode(secgroup)) if (utils.is_integer_like(encodeutils.safe_encode(secgroup)) or
or uuidutils.is_uuid_like(secgroup)): uuidutils.is_uuid_like(secgroup)):
try: try:
return cs.security_groups.get(secgroup) return cs.security_groups.get(secgroup)
except exceptions.NotFound: except exceptions.NotFound:
@ -2377,9 +2377,8 @@ def _get_secgroup(cs, secgroup):
# Check secgroup as a name # Check secgroup as a name
match_found = False match_found = False
for s in cs.security_groups.list(): for s in cs.security_groups.list():
encoding = (locale.getpreferredencoding() or encoding = (
sys.stdin.encoding or locale.getpreferredencoding() or sys.stdin.encoding or 'UTF-8')
'UTF-8')
if not six.PY3: if not six.PY3:
s.name = s.name.encode(encoding) s.name = s.name.encode(encoding)
if secgroup == s.name: if secgroup == s.name:
@ -3379,8 +3378,8 @@ def do_ssh(cs, args):
match = lambda addr: all(( match = lambda addr: all((
addr.get('version') == version, addr.get('version') == version,
addr.get('OS-EXT-IPS:type', 'floating') == address_type)) addr.get('OS-EXT-IPS:type', 'floating') == address_type))
matching_addresses = [address.get('addr') for address in network_addresses matching_addresses = [address.get('addr')
if match(address)] for address in network_addresses if match(address)]
if not any(matching_addresses): if not any(matching_addresses):
msg = _("No address that would match network '%(network)s'" msg = _("No address that would match network '%(network)s'"
" and type '%(address_type)s' of version %(pretty_version)s " " and type '%(address_type)s' of version %(pretty_version)s "
@ -3568,8 +3567,8 @@ def do_quota_defaults(cs, args):
dest='force', dest='force',
action="store_true", action="store_true",
default=None, default=None,
help=_('Whether force update the quota even if the already used' help=_('Whether force update the quota even if the already used and '
' and reserved exceeds the new quota')) 'reserved exceeds the new quota'))
def do_quota_update(cs, args): def do_quota_update(cs, args):
"""Update the quotas for a tenant/user.""" """Update the quotas for a tenant/user."""

@ -42,8 +42,8 @@ class SnapshotManager(base.ManagerWithFind):
""" """
resource_class = Snapshot resource_class = Snapshot
def create(self, volume_id, force=False, def create(self, volume_id, force=False, display_name=None,
display_name=None, display_description=None): display_description=None):
""" """
Create a snapshot of the given volume. Create a snapshot of the given volume.

@ -45,10 +45,9 @@ class VolumeManager(base.ManagerWithFind):
""" """
resource_class = Volume resource_class = Volume
def create(self, size, snapshot_id=None, def create(self, size, snapshot_id=None, display_name=None,
display_name=None, display_description=None, display_description=None, volume_type=None,
volume_type=None, availability_zone=None, availability_zone=None, imageRef=None):
imageRef=None):
""" """
Create a volume. Create a volume.

@ -893,8 +893,8 @@ class ServerManager(base.BootingManagerWithFind):
:param metadata: A dict of metadata to add to the server :param metadata: A dict of metadata to add to the server
""" """
body = {'metadata': metadata} body = {'metadata': metadata}
return self._create("/servers/%s/metadata" % base.getid(server), return self._create(
body, "metadata") "/servers/%s/metadata" % base.getid(server), body, "metadata")
def get_console_output(self, server, length=None): def get_console_output(self, server, length=None):
""" """

@ -94,8 +94,8 @@ def _boot(cs, args):
max_count = args.num_instances max_count = args.num_instances
elif (args.num_instances is not None and elif (args.num_instances is not None and
(args.min_count is not None or args.max_count is not None)): (args.min_count is not None or args.max_count is not None)):
raise exceptions.CommandError("Don't mix num-instances and " raise exceptions.CommandError(
"max/min-count") "Don't mix num-instances and max/min-count")
if args.min_count is not None: if args.min_count is not None:
if args.min_count < 1: if args.min_count < 1:
raise exceptions.CommandError("min_count should be >= 1") raise exceptions.CommandError("min_count should be >= 1")
@ -1945,8 +1945,8 @@ def do_secgroup_add_group_rule(cs, args):
if args.ip_proto or args.from_port or args.to_port: if args.ip_proto or args.from_port or args.to_port:
if not (args.ip_proto and args.from_port and args.to_port): if not (args.ip_proto and args.from_port and args.to_port):
raise exceptions.CommandError("ip_proto, from_port, and to_port" raise exceptions.CommandError(
" must be specified together") "ip_proto, from_port, and to_port must be specified together")
params['ip_protocol'] = args.ip_proto.upper() params['ip_protocol'] = args.ip_proto.upper()
params['from_port'] = args.from_port params['from_port'] = args.from_port
params['to_port'] = args.to_port params['to_port'] = args.to_port
@ -1979,8 +1979,8 @@ def do_secgroup_delete_group_rule(cs, args):
if args.ip_proto or args.from_port or args.to_port: if args.ip_proto or args.from_port or args.to_port:
if not (args.ip_proto and args.from_port and args.to_port): if not (args.ip_proto and args.from_port and args.to_port):
raise exceptions.CommandError("ip_proto, from_port, and to_port" raise exceptions.CommandError(
" must be specified together") "ip_proto, from_port, and to_port must be specified together")
params['ip_protocol'] = args.ip_proto.upper() params['ip_protocol'] = args.ip_proto.upper()
params['from_port'] = int(args.from_port) params['from_port'] = int(args.from_port)
params['to_port'] = int(args.to_port) params['to_port'] = int(args.to_port)
@ -2013,8 +2013,8 @@ def do_keypair_add(cs, args):
with open(os.path.expanduser(pub_key)) as f: with open(os.path.expanduser(pub_key)) as f:
pub_key = f.read() pub_key = f.read()
except IOError as e: except IOError as e:
raise exceptions.CommandError("Can't open or read '%s': %s" % raise exceptions.CommandError(
(pub_key, e)) "Can't open or read '%s': %s" % (pub_key, e))
keypair = cs.keypairs.create(name, pub_key) keypair = cs.keypairs.create(name, pub_key)
@ -2822,8 +2822,8 @@ def do_ssh(cs, args):
match = lambda addr: all(( match = lambda addr: all((
addr.get('version') == version, addr.get('version') == version,
addr.get('OS-EXT-IPS:type', 'floating') == address_type)) addr.get('OS-EXT-IPS:type', 'floating') == address_type))
matching_addresses = [address.get('addr') for address in network_addresses matching_addresses = [address.get('addr')
if match(address)] for address in network_addresses if match(address)]
if not any(matching_addresses): if not any(matching_addresses):
msg = _("No address that would match network '%(network)s'" msg = _("No address that would match network '%(network)s'"
" and type '%(address_type)s' of version %(pretty_version)s " " and type '%(address_type)s' of version %(pretty_version)s "
@ -2980,8 +2980,8 @@ def do_quota_defaults(cs, args):
dest='force', dest='force',
action="store_true", action="store_true",
default=None, default=None,
help='Whether force update the quota even if the already used' help='Whether force update the quota even if the already used and '
' and reserved exceeds the new quota') 'reserved exceeds the new quota')
def do_quota_update(cs, args): def do_quota_update(cs, args):
"""Update the quotas for a tenant.""" """Update the quotas for a tenant."""

@ -42,7 +42,7 @@ downloadcache = ~/cache/pip
# reason: removed in hacking (https://review.openstack.org/#/c/101701/) # reason: removed in hacking (https://review.openstack.org/#/c/101701/)
# #
# Additional checks are also ignored on purpose: F811, F821 # Additional checks are also ignored on purpose: F811, F821
ignore = E124,E127,E128,E129,F811,F821,H402,H404,H405,H904 ignore = E124,E128,E129,F811,F821,H402,H404,H405,H904
show-source = True show-source = True
exclude=.venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,build,doc/source/conf.py exclude=.venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,build,doc/source/conf.py