Enable F841
F841 detects local variable is assigned to but never used. This commit fixes the violations and enables F841 in gate. Change-Id: Ic4dcac2733dfe334009327ac17aa3952cafaa63a
This commit is contained in:
parent
d613adc434
commit
1db17aaad9
@ -434,7 +434,7 @@ class OpenStackImagesShell(object):
|
||||
|
||||
with open(schema_file_path, 'w') as f:
|
||||
f.write(json.dumps(schema.raw()))
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
#NOTE(esheffield) do nothing here, we'll get a message later
|
||||
#if the schema is missing
|
||||
pass
|
||||
|
@ -117,7 +117,6 @@ def do_image_list(gc, args):
|
||||
def do_image_show(gc, args):
|
||||
"""Describe a specific image."""
|
||||
image = gc.images.get(args.id)
|
||||
ignore = ['self', 'access', 'file', 'schema']
|
||||
utils.print_image(image, int(args.max_column_width))
|
||||
|
||||
|
||||
@ -285,7 +284,7 @@ def do_location_add(gc, args):
|
||||
help='ID of image whose locations are to be removed.')
|
||||
def do_location_delete(gc, args):
|
||||
"""Remove locations (and related metadata) from an image."""
|
||||
image = gc.images.delete_locations(args.id, set(args.url))
|
||||
gc.images.delete_locations(args.id, set(args.url))
|
||||
|
||||
|
||||
@utils.arg('--url', metavar='<URL>', required=True,
|
||||
|
@ -35,10 +35,10 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
|
||||
cert_file = os.path.join(TEST_VAR_DIR, 'certificate.crt')
|
||||
cacert = os.path.join(TEST_VAR_DIR, 'ca.crt')
|
||||
try:
|
||||
conn = http.VerifiedHTTPSConnection('127.0.0.1', 0,
|
||||
key_file=key_file,
|
||||
cert_file=cert_file,
|
||||
cacert=cacert)
|
||||
http.VerifiedHTTPSConnection('127.0.0.1', 0,
|
||||
key_file=key_file,
|
||||
cert_file=cert_file,
|
||||
cacert=cacert)
|
||||
except exc.SSLConfigurationError:
|
||||
self.fail('Failed to init VerifiedHTTPSConnection.')
|
||||
|
||||
@ -49,9 +49,9 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
|
||||
cert_file = os.path.join(TEST_VAR_DIR, 'certificate.crt')
|
||||
cacert = os.path.join(TEST_VAR_DIR, 'ca.crt')
|
||||
try:
|
||||
conn = http.VerifiedHTTPSConnection('127.0.0.1', 0,
|
||||
cert_file=cert_file,
|
||||
cacert=cacert)
|
||||
http.VerifiedHTTPSConnection('127.0.0.1', 0,
|
||||
cert_file=cert_file,
|
||||
cacert=cacert)
|
||||
self.fail('Failed to raise assertion.')
|
||||
except exc.SSLConfigurationError:
|
||||
pass
|
||||
@ -63,9 +63,9 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
|
||||
key_file = os.path.join(TEST_VAR_DIR, 'privatekey.key')
|
||||
cacert = os.path.join(TEST_VAR_DIR, 'ca.crt')
|
||||
try:
|
||||
conn = http.VerifiedHTTPSConnection('127.0.0.1', 0,
|
||||
key_file=key_file,
|
||||
cacert=cacert)
|
||||
http.VerifiedHTTPSConnection('127.0.0.1', 0,
|
||||
key_file=key_file,
|
||||
cacert=cacert)
|
||||
except exc.SSLConfigurationError:
|
||||
pass
|
||||
except Exception:
|
||||
@ -75,13 +75,12 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
|
||||
"""
|
||||
Test VerifiedHTTPSConnection: bad key.
|
||||
"""
|
||||
key_file = os.path.join(TEST_VAR_DIR, 'badkey.key')
|
||||
cert_file = os.path.join(TEST_VAR_DIR, 'certificate.crt')
|
||||
cacert = os.path.join(TEST_VAR_DIR, 'ca.crt')
|
||||
try:
|
||||
conn = http.VerifiedHTTPSConnection('127.0.0.1', 0,
|
||||
cert_file=cert_file,
|
||||
cacert=cacert)
|
||||
http.VerifiedHTTPSConnection('127.0.0.1', 0,
|
||||
cert_file=cert_file,
|
||||
cacert=cacert)
|
||||
self.fail('Failed to raise assertion.')
|
||||
except exc.SSLConfigurationError:
|
||||
pass
|
||||
@ -90,13 +89,12 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
|
||||
"""
|
||||
Test VerifiedHTTPSConnection: bad cert.
|
||||
"""
|
||||
key_file = os.path.join(TEST_VAR_DIR, 'privatekey.key')
|
||||
cert_file = os.path.join(TEST_VAR_DIR, 'badcert.crt')
|
||||
cacert = os.path.join(TEST_VAR_DIR, 'ca.crt')
|
||||
try:
|
||||
conn = http.VerifiedHTTPSConnection('127.0.0.1', 0,
|
||||
cert_file=cert_file,
|
||||
cacert=cacert)
|
||||
http.VerifiedHTTPSConnection('127.0.0.1', 0,
|
||||
cert_file=cert_file,
|
||||
cacert=cacert)
|
||||
self.fail('Failed to raise assertion.')
|
||||
except exc.SSLConfigurationError:
|
||||
pass
|
||||
@ -105,13 +103,12 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
|
||||
"""
|
||||
Test VerifiedHTTPSConnection: bad CA.
|
||||
"""
|
||||
key_file = os.path.join(TEST_VAR_DIR, 'privatekey.key')
|
||||
cert_file = os.path.join(TEST_VAR_DIR, 'certificate.crt')
|
||||
cacert = os.path.join(TEST_VAR_DIR, 'badca.crt')
|
||||
try:
|
||||
conn = http.VerifiedHTTPSConnection('127.0.0.1', 0,
|
||||
cert_file=cert_file,
|
||||
cacert=cacert)
|
||||
http.VerifiedHTTPSConnection('127.0.0.1', 0,
|
||||
cert_file=cert_file,
|
||||
cacert=cacert)
|
||||
self.fail('Failed to raise assertion.')
|
||||
except exc.SSLConfigurationError:
|
||||
pass
|
||||
@ -251,7 +248,7 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
|
||||
cert_file = os.path.join(TEST_VAR_DIR, 'certificate.crt')
|
||||
cacert = os.path.join(TEST_VAR_DIR, 'ca.crt')
|
||||
try:
|
||||
conn = http.VerifiedHTTPSConnection(
|
||||
http.VerifiedHTTPSConnection(
|
||||
'127.0.0.1', 0,
|
||||
key_file=key_file,
|
||||
cert_file=cert_file,
|
||||
@ -267,7 +264,7 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
|
||||
cert_file = os.path.join(TEST_VAR_DIR, 'certificate.crt')
|
||||
cacert = os.path.join(TEST_VAR_DIR, 'ca.crt')
|
||||
try:
|
||||
conn = http.VerifiedHTTPSConnection(
|
||||
http.VerifiedHTTPSConnection(
|
||||
'127.0.0.1', 0,
|
||||
key_file=key_file,
|
||||
cert_file=cert_file,
|
||||
@ -289,9 +286,9 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
|
||||
cert_file = cert_file.encode('ascii', 'strict').decode('utf-8')
|
||||
cacert = cacert.encode('ascii', 'strict').decode('utf-8')
|
||||
try:
|
||||
conn = http.VerifiedHTTPSConnection('127.0.0.1', 0,
|
||||
key_file=key_file,
|
||||
cert_file=cert_file,
|
||||
cacert=cacert)
|
||||
http.VerifiedHTTPSConnection('127.0.0.1', 0,
|
||||
key_file=key_file,
|
||||
cert_file=cert_file,
|
||||
cacert=cacert)
|
||||
except exc.SSLConfigurationError:
|
||||
self.fail('Failed to init VerifiedHTTPSConnection.')
|
||||
|
@ -522,12 +522,11 @@ class ImageManagerTest(testtools.TestCase):
|
||||
|
||||
def test_get_encoding(self):
|
||||
image = self.mgr.get('3')
|
||||
expect = [('HEAD', '/v1/images/3', {}, None)]
|
||||
self.assertEqual(u"ni\xf1o", image.name)
|
||||
|
||||
def test_get_req_id(self):
|
||||
params = {'return_req_id': []}
|
||||
image = self.mgr.get('4', **params)
|
||||
self.mgr.get('4', **params)
|
||||
expect_req_id = ['req-1234']
|
||||
self.assertEqual(expect_req_id, params['return_req_id'])
|
||||
|
||||
@ -564,7 +563,7 @@ class ImageManagerTest(testtools.TestCase):
|
||||
'do_checksum': False,
|
||||
'return_req_id': [],
|
||||
}
|
||||
data = ''.join([b for b in self.mgr.data('4', **params)])
|
||||
''.join([b for b in self.mgr.data('4', **params)])
|
||||
expect_req_id = ['req-1234']
|
||||
self.assertEqual(expect_req_id, params['return_req_id'])
|
||||
|
||||
|
@ -330,7 +330,7 @@ class LegacyShellV1Test(testtools.TestCase):
|
||||
def __init__(self):
|
||||
self.images = FakeImage1()
|
||||
|
||||
actual = test_shell.do_delete(FakeClient(), FakeImage1())
|
||||
test_shell.do_delete(FakeClient(), FakeImage1())
|
||||
|
||||
def test_show(self):
|
||||
class Image():
|
||||
@ -376,7 +376,7 @@ class LegacyShellV1Test(testtools.TestCase):
|
||||
gc = client.Client('1', 'http://is.invalid')
|
||||
with mock.patch.object(gc.images, 'list') as mocked_list:
|
||||
mocked_list.return_value = [Image(), Image()]
|
||||
actual = test_shell.do_index(gc, args)
|
||||
test_shell.do_index(gc, args)
|
||||
|
||||
def test_index_return_empty(self):
|
||||
class Image():
|
||||
@ -424,7 +424,7 @@ class LegacyShellV1Test(testtools.TestCase):
|
||||
gc = client.Client('1', 'http://is.invalid')
|
||||
with mock.patch.object(gc.images, 'list') as mocked_list:
|
||||
mocked_list.return_value = [Image(), Image()]
|
||||
actual = test_shell.do_details(gc, args)
|
||||
test_shell.do_details(gc, args)
|
||||
|
||||
def test_do_image_members(self):
|
||||
class FakeImage1():
|
||||
@ -463,7 +463,7 @@ class LegacyShellV1Test(testtools.TestCase):
|
||||
def list(self, image):
|
||||
return [ImageMembers(), ImageMembers()]
|
||||
|
||||
actual = test_shell.do_image_members(FakeClient(), FakeImage1())
|
||||
test_shell.do_image_members(FakeClient(), FakeImage1())
|
||||
|
||||
def test_do_member_add_error(self):
|
||||
class FakeClient():
|
||||
@ -492,7 +492,7 @@ class LegacyShellV1Test(testtools.TestCase):
|
||||
def list(self, image):
|
||||
return [ImageMembers(), ImageMembers()]
|
||||
|
||||
actual = test_shell.do_member_add(FakeClient(), FakeImage1())
|
||||
test_shell.do_member_add(FakeClient(), FakeImage1())
|
||||
|
||||
def test_do_member_images_empty_result(self):
|
||||
class FakeImage1():
|
||||
@ -520,7 +520,7 @@ class LegacyShellV1Test(testtools.TestCase):
|
||||
def list(self, image):
|
||||
return [ImageMembers(), ImageMembers()]
|
||||
|
||||
actual = test_shell.do_member_add(FakeClient(), ImageMembers())
|
||||
test_shell.do_member_add(FakeClient(), ImageMembers())
|
||||
|
||||
def test_do_members_replace_dry_run_true(self):
|
||||
class Fake():
|
||||
@ -531,7 +531,7 @@ class LegacyShellV1Test(testtools.TestCase):
|
||||
self.member_id = 'test'
|
||||
|
||||
gc = client.Client('1', 'http://is.invalid')
|
||||
actual = test_shell.do_members_replace(gc, Fake())
|
||||
test_shell.do_members_replace(gc, Fake())
|
||||
|
||||
def test_do_members_replace_dry_run_false(self):
|
||||
class Fake():
|
||||
@ -546,7 +546,7 @@ class LegacyShellV1Test(testtools.TestCase):
|
||||
with mock.patch.object(gc.image_members, 'list') as mocked_list:
|
||||
mocked_list.return_value = []
|
||||
with mock.patch.object(gc.image_members, 'create'):
|
||||
actual = test_shell.do_members_replace(gc, Fake())
|
||||
test_shell.do_members_replace(gc, Fake())
|
||||
|
||||
def test_do_member_images(self):
|
||||
class FakeClient():
|
||||
@ -563,7 +563,7 @@ class LegacyShellV1Test(testtools.TestCase):
|
||||
def list(self, member):
|
||||
return [ImageMembers(), ImageMembers()]
|
||||
|
||||
actual = test_shell.do_member_images(FakeClient(), ImageMembers())
|
||||
test_shell.do_member_images(FakeClient(), ImageMembers())
|
||||
|
||||
def test_create_pretty_table(self):
|
||||
class MyPrettyTable(test_shell.PrettyTable):
|
||||
|
@ -697,7 +697,7 @@ class TestController(testtools.TestCase):
|
||||
image_id = 'a2b83adc-888e-11e3-8872-78acc0b951d8'
|
||||
new_loc = {'url': 'http://spam.com/', 'metadata': {'spam': 'ham'}}
|
||||
add_patch = {'path': '/locations/-', 'value': new_loc, 'op': 'add'}
|
||||
image = self.controller.add_location(image_id, **new_loc)
|
||||
self.controller.add_location(image_id, **new_loc)
|
||||
self.assertEqual(self.api.calls, [
|
||||
self._empty_get(image_id),
|
||||
self._patch_req(image_id, [add_patch]),
|
||||
@ -719,7 +719,7 @@ class TestController(testtools.TestCase):
|
||||
url_set = set(['http://foo.com/', 'http://bar.com/'])
|
||||
del_patches = [{'path': '/locations/1', 'op': 'remove'},
|
||||
{'path': '/locations/0', 'op': 'remove'}]
|
||||
image = self.controller.delete_locations(image_id, url_set)
|
||||
self.controller.delete_locations(image_id, url_set)
|
||||
self.assertEqual(self.api.calls, [
|
||||
self._empty_get(image_id),
|
||||
self._patch_req(image_id, del_patches)
|
||||
@ -746,7 +746,7 @@ class TestController(testtools.TestCase):
|
||||
'value': []},
|
||||
{'path': '/locations', 'op': 'replace',
|
||||
'value': list(loc_map.values())}]
|
||||
image = self.controller.update_location(image_id, **new_loc)
|
||||
self.controller.update_location(image_id, **new_loc)
|
||||
self.assertEqual(self.api.calls, [
|
||||
self._empty_get(image_id),
|
||||
self._patch_req(image_id, mod_patch),
|
||||
|
@ -241,7 +241,6 @@ class ShellV2Test(testtools.TestCase):
|
||||
args = self._make_args({'id': 'pass', 'url': loc_set})
|
||||
|
||||
with mock.patch.object(gc.images, 'delete_locations') as mocked_rmloc:
|
||||
expect_image = {'id': 'pass', 'locations': []}
|
||||
test_shell.do_location_delete(self.gc, args)
|
||||
mocked_rmloc.assert_called_once_with('pass', loc_set)
|
||||
|
||||
|
2
tox.ini
2
tox.ini
@ -32,6 +32,6 @@ downloadcache = ~/cache/pip
|
||||
# H302 import only modules
|
||||
# H303 no wildcard import
|
||||
# H404 multi line docstring should start with a summary
|
||||
ignore = F403,F841,F812,F821,H233,H302,H303,H404
|
||||
ignore = F403,F812,F821,H233,H302,H303,H404
|
||||
show-source = True
|
||||
exclude = .venv,.tox,dist,doc,*egg,build
|
||||
|
Loading…
x
Reference in New Issue
Block a user