Browse Source

Enable F841

F841 detects local variable is assigned to but never used.
This commit fix the violations and enable F841 in gate.

Change-Id: I52419f5e17db70e511ff2d4d61c85458c958e9c3
ChangBo Guo(gcb) 4 years ago
parent
commit
88d0b6f2d9

+ 2
- 2
novaclient/tests/test_client.py View File

@@ -215,7 +215,7 @@ class ClientTest(utils.TestCase):
215 215
         fake_client = mock.Mock()
216 216
         mock_http_client.return_value = fake_client
217 217
         with novaclient.v1_1.client.Client("user", "password", "project_id",
218
-                auth_url="foo/v2") as client:
218
+                auth_url="foo/v2"):
219 219
             pass
220 220
         self.assertTrue(fake_client.open_session.called)
221 221
         self.assertTrue(fake_client.close_session.called)
@@ -225,7 +225,7 @@ class ClientTest(utils.TestCase):
225 225
         fake_client = mock.Mock()
226 226
         mock_http_client.return_value = fake_client
227 227
         with novaclient.v3.client.Client("user", "password", "project_id",
228
-                auth_url="foo/v2") as client:
228
+                auth_url="foo/v2"):
229 229
             pass
230 230
         self.assertTrue(fake_client.open_session.called)
231 231
         self.assertTrue(fake_client.close_session.called)

+ 1
- 1
novaclient/tests/test_shell.py View File

@@ -265,7 +265,7 @@ class ShellTest(utils.TestCase):
265 265
         # Ensure that main works with no command-line arguments
266 266
         try:
267 267
             novaclient.shell.main()
268
-        except SystemExit as exc:
268
+        except SystemExit:
269 269
             self.fail('Unexpected SystemExit')
270 270
 
271 271
         # We expect the normal usage as a result

+ 2
- 2
novaclient/tests/v1_1/contrib/test_assisted_volume_snapshots.py View File

@@ -32,10 +32,10 @@ cs = fakes.FakeClient(extensions=extensions)
32 32
 class AssistedVolumeSnapshotsTestCase(utils.TestCase):
33 33
 
34 34
     def test_create_snap(self):
35
-        res = cs.assisted_volume_snapshots.create('1', {})
35
+        cs.assisted_volume_snapshots.create('1', {})
36 36
         cs.assert_called('POST', '/os-assisted-volume-snapshots')
37 37
 
38 38
     def test_delete_snap(self):
39
-        res = cs.assisted_volume_snapshots.delete('x', {})
39
+        cs.assisted_volume_snapshots.delete('x', {})
40 40
         cs.assert_called('DELETE',
41 41
                 '/os-assisted-volume-snapshots/x?delete_info={}')

+ 2
- 2
novaclient/tests/v1_1/test_fixed_ips.py View File

@@ -33,10 +33,10 @@ class FixedIpsTest(utils.FixturedTestCase):
33 33
 
34 34
     def test_reserve_fixed_ip(self):
35 35
         body = {"reserve": None}
36
-        res = self.cs.fixed_ips.reserve(fixed_ip='192.168.1.1')
36
+        self.cs.fixed_ips.reserve(fixed_ip='192.168.1.1')
37 37
         self.assert_called('POST', '/os-fixed-ips/192.168.1.1/action', body)
38 38
 
39 39
     def test_unreserve_fixed_ip(self):
40 40
         body = {"unreserve": None}
41
-        res = self.cs.fixed_ips.unreserve(fixed_ip='192.168.1.1')
41
+        self.cs.fixed_ips.unreserve(fixed_ip='192.168.1.1')
42 42
         self.assert_called('POST', '/os-fixed-ips/192.168.1.1/action', body)

+ 3
- 3
novaclient/tests/v1_1/test_hosts.py View File

@@ -62,18 +62,18 @@ class HostsTest(utils.TestCase):
62 62
 
63 63
     def test_host_startup(self):
64 64
         host = cs.hosts.get('sample_host')[0]
65
-        result = host.startup()
65
+        host.startup()
66 66
         cs.assert_called(
67 67
             'GET', '/os-hosts/sample_host/startup')
68 68
 
69 69
     def test_host_reboot(self):
70 70
         host = cs.hosts.get('sample_host')[0]
71
-        result = host.reboot()
71
+        host.reboot()
72 72
         cs.assert_called(
73 73
             'GET', '/os-hosts/sample_host/reboot')
74 74
 
75 75
     def test_host_shutdown(self):
76 76
         host = cs.hosts.get('sample_host')[0]
77
-        result = host.shutdown()
77
+        host.shutdown()
78 78
         cs.assert_called(
79 79
             'GET', '/os-hosts/sample_host/shutdown')

+ 1
- 1
novaclient/tests/v1_1/test_images.py View File

@@ -32,7 +32,7 @@ class ImagesTest(utils.TestCase):
32 32
         [self.assertIsInstance(i, images.Image) for i in il]
33 33
 
34 34
     def test_list_images_with_limit(self):
35
-        il = cs.images.list(limit=4)
35
+        cs.images.list(limit=4)
36 36
         cs.assert_called('GET', '/images/detail?limit=4')
37 37
 
38 38
     def test_get_image_details(self):

+ 5
- 5
novaclient/tests/v1_1/test_servers.py View File

@@ -222,17 +222,17 @@ class ServersTest(utils.TestCase):
222 222
         cs.assert_called('DELETE', '/servers/1234')
223 223
 
224 224
     def test_delete_server_meta(self):
225
-        s = cs.servers.delete_meta(1234, ['test_key'])
225
+        cs.servers.delete_meta(1234, ['test_key'])
226 226
         cs.assert_called('DELETE', '/servers/1234/metadata/test_key')
227 227
 
228 228
     def test_set_server_meta(self):
229
-        s = cs.servers.set_meta(1234, {'test_key': 'test_value'})
230
-        reval = cs.assert_called('POST', '/servers/1234/metadata',
229
+        cs.servers.set_meta(1234, {'test_key': 'test_value'})
230
+        cs.assert_called('POST', '/servers/1234/metadata',
231 231
                          {'metadata': {'test_key': 'test_value'}})
232 232
 
233 233
     def test_set_server_meta_item(self):
234
-        s = cs.servers.set_meta_item(1234, 'test_key', 'test_value')
235
-        reval = cs.assert_called('PUT', '/servers/1234/metadata/test_key',
234
+        cs.servers.set_meta_item(1234, 'test_key', 'test_value')
235
+        cs.assert_called('PUT', '/servers/1234/metadata/test_key',
236 236
                          {'meta': {'test_key': 'test_value'}})
237 237
 
238 238
     def test_find(self):

+ 1
- 1
novaclient/tests/v1_1/test_services.py View File

@@ -79,7 +79,7 @@ class ServicesTest(utils.TestCase):
79 79
         self.assertEqual(service.status, 'enabled')
80 80
 
81 81
     def test_services_delete(self):
82
-        service = self.cs.services.delete('1')
82
+        self.cs.services.delete('1')
83 83
         self.cs.assert_called('DELETE', '/os-services/1')
84 84
 
85 85
     def test_services_disable(self):

+ 3
- 3
novaclient/tests/v3/test_hosts.py View File

@@ -66,18 +66,18 @@ class HostsTest(utils.TestCase):
66 66
 
67 67
     def test_host_startup(self):
68 68
         host = cs.hosts.get('sample_host')[0]
69
-        result = host.startup()
69
+        host.startup()
70 70
         cs.assert_called(
71 71
             'GET', '/os-hosts/sample_host/startup')
72 72
 
73 73
     def test_host_reboot(self):
74 74
         host = cs.hosts.get('sample_host')[0]
75
-        result = host.reboot()
75
+        host.reboot()
76 76
         cs.assert_called(
77 77
             'GET', '/os-hosts/sample_host/reboot')
78 78
 
79 79
     def test_host_shutdown(self):
80 80
         host = cs.hosts.get('sample_host')[0]
81
-        result = host.shutdown()
81
+        host.shutdown()
82 82
         cs.assert_called(
83 83
             'GET', '/os-hosts/sample_host/shutdown')

+ 1
- 1
novaclient/tests/v3/test_images.py View File

@@ -36,7 +36,7 @@ class ImagesTest(utils.TestCase):
36 36
             self.assertIsInstance(i, images.Image)
37 37
 
38 38
     def test_list_images_with_limit(self):
39
-        il = cs.images.list(limit=4)
39
+        cs.images.list(limit=4)
40 40
         cs.assert_called('GET', '/v1/images/detail?limit=4')
41 41
 
42 42
     def test_get_image_details(self):

+ 3
- 3
novaclient/tests/v3/test_servers.py View File

@@ -212,12 +212,12 @@ class ServersTest(utils.TestCase):
212 212
         cs.assert_called('DELETE', '/servers/1234')
213 213
 
214 214
     def test_delete_server_meta(self):
215
-        s = cs.servers.delete_meta(1234, ['test_key'])
215
+        cs.servers.delete_meta(1234, ['test_key'])
216 216
         cs.assert_called('DELETE', '/servers/1234/metadata/test_key')
217 217
 
218 218
     def test_set_server_meta(self):
219
-        s = cs.servers.set_meta(1234, {'test_key': 'test_value'})
220
-        reval = cs.assert_called('POST', '/servers/1234/metadata',
219
+        cs.servers.set_meta(1234, {'test_key': 'test_value'})
220
+        cs.assert_called('POST', '/servers/1234/metadata',
221 221
                          {'metadata': {'test_key': 'test_value'}})
222 222
 
223 223
     def test_find(self):

+ 2
- 2
novaclient/tests/v3/test_volumes.py View File

@@ -26,7 +26,7 @@ class VolumesTest(utils.TestCase):
26 26
         return fakes.FakeClient()
27 27
 
28 28
     def test_attach_server_volume(self):
29
-        v = self.cs.volumes.attach_server_volume(
29
+        self.cs.volumes.attach_server_volume(
30 30
             server=1234,
31 31
             volume_id='15e59938-07d5-11e1-90e3-e3dffe0c5983',
32 32
             device='/dev/vdb'
@@ -35,7 +35,7 @@ class VolumesTest(utils.TestCase):
35 35
 
36 36
     def test_update_server_volume(self):
37 37
         vol_id = '15e59938-07d5-11e1-90e3-e3dffe0c5983'
38
-        v = self.cs.volumes.update_server_volume(
38
+        self.cs.volumes.update_server_volume(
39 39
             server=1234,
40 40
             old_volume_id='Work',
41 41
             new_volume_id=vol_id

+ 1
- 1
novaclient/utils.py View File

@@ -351,7 +351,7 @@ def _load_entry_point(ep_name, name=None):
351 351
 def is_integer_like(val):
352 352
     """Returns validation of a value as an integer."""
353 353
     try:
354
-        value = int(val)
354
+        int(val)
355 355
         return True
356 356
     except (TypeError, ValueError, AttributeError):
357 357
         return False

+ 4
- 6
novaclient/v3/shell.py View File

@@ -1437,9 +1437,8 @@ def do_volume_attach(cs, args):
1437 1437
     if args.device == 'auto':
1438 1438
         args.device = None
1439 1439
 
1440
-    volume = cs.volumes.attach_server_volume(_find_server(cs, args.server).id,
1441
-                                             args.volume,
1442
-                                             args.device)
1440
+    cs.volumes.attach_server_volume(_find_server(cs, args.server).id,
1441
+                                    args.volume, args.device)
1443 1442
 
1444 1443
 
1445 1444
 @utils.arg('server',
@@ -1453,9 +1452,8 @@ def do_volume_attach(cs, args):
1453 1452
     help='ID of the volume to attach.')
1454 1453
 def do_volume_update(cs, args):
1455 1454
     """Update volume attachment."""
1456
-    volume = cs.volumes.update_server_volume(_find_server(cs, args.server).id,
1457
-                                             args.attachment_id,
1458
-                                             args.new_volume)
1455
+    cs.volumes.update_server_volume(_find_server(cs, args.server).id,
1456
+                                    args.attachment_id, args.new_volume)
1459 1457
 
1460 1458
 
1461 1459
 @utils.arg('server',

+ 1
- 1
tox.ini View File

@@ -28,6 +28,6 @@ downloadcache = ~/cache/pip
28 28
 [flake8]
29 29
 # TODO fix following rules from hacking 0.9
30 30
 # E131,E265,H233,H305,H307,H402,H405,H904
31
-ignore = E12,E131,E265,F841,F811,F821,H233,H302,H305,H307,H402,H404,H405,H904
31
+ignore = E12,E131,E265,F811,F821,H233,H302,H305,H307,H402,H404,H405,H904
32 32
 show-source = True
33 33
 exclude=.venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,build

Loading…
Cancel
Save