Browse Source

Enable check for E128 rule

Fix E128 failures in novaclient/client and
novaclient/shell and enable check for E128

E128 continuation line under-indented for visual indent

Change-Id: Id3ac46ccdbb8a9f97e54b4643240d93b06fac6ea
tags/2.21.0
Eugeniya Kudryashova 4 years ago
parent
commit
1aa020989e
4 changed files with 115 additions and 77 deletions
  1. 2
    2
      novaclient/client.py
  2. 108
    72
      novaclient/shell.py
  3. 4
    2
      novaclient/tests/test_shell.py
  4. 1
    1
      tox.ini

+ 2
- 2
novaclient/client.py View File

@@ -208,7 +208,7 @@ class HTTPClient(object):
208 208
         self.tenant_id = tenant_id
209 209
 
210 210
         self._connection_pool = (_ClientConnectionPool()
211
-                                if connection_pool else None)
211
+                                 if connection_pool else None)
212 212
 
213 213
         # This will be called by #_get_password if self.password is None.
214 214
         # EG if a password can only be obtained by prompting the user, but a
@@ -396,7 +396,7 @@ class HTTPClient(object):
396 396
                     "New session created for: (%s)" % service_url)
397 397
                 self._session = requests.Session()
398 398
                 self._session.mount(service_url,
399
-                        self._connection_pool.get(service_url))
399
+                                    self._connection_pool.get(service_url))
400 400
             return self._session
401 401
         elif self._session:
402 402
             return self._session

+ 108
- 72
novaclient/shell.py View File

@@ -229,10 +229,10 @@ class NovaClientArgumentParser(argparse.ArgumentParser):
229 229
         choose_from = ' (choose from'
230 230
         progparts = self.prog.partition(' ')
231 231
         self.exit(2, _("error: %(errmsg)s\nTry '%(mainp)s help %(subp)s'"
232
-                     " for more information.\n") %
233
-                     {'errmsg': message.split(choose_from)[0],
234
-                      'mainp': progparts[0],
235
-                      'subp': progparts[2]})
232
+                       " for more information.\n") %
233
+                  {'errmsg': message.split(choose_from)[0],
234
+                   'mainp': progparts[0],
235
+                   'subp': progparts[2]})
236 236
 
237 237
 
238 238
 class OpenStackComputeShell(object):
@@ -264,7 +264,8 @@ class OpenStackComputeShell(object):
264 264
         )
265 265
 
266 266
         # Global arguments
267
-        parser.add_argument('-h', '--help',
267
+        parser.add_argument(
268
+            '-h', '--help',
268 269
             action='store_true',
269 270
             help=argparse.SUPPRESS,
270 271
         )
@@ -273,93 +274,117 @@ class OpenStackComputeShell(object):
273 274
                             action='version',
274 275
                             version=novaclient.__version__)
275 276
 
276
-        parser.add_argument('--debug',
277
+        parser.add_argument(
278
+            '--debug',
277 279
             default=False,
278 280
             action='store_true',
279 281
             help=_("Print debugging output"))
280 282
 
281
-        parser.add_argument('--os-cache',
283
+        parser.add_argument(
284
+            '--os-cache',
282 285
             default=strutils.bool_from_string(
283 286
                 utils.env('OS_CACHE', default=False), True),
284 287
             action='store_true',
285 288
             help=_("Use the auth token cache. Defaults to False if "
286 289
                    "env[OS_CACHE] is not set."))
287 290
 
288
-        parser.add_argument('--timings',
291
+        parser.add_argument(
292
+            '--timings',
289 293
             default=False,
290 294
             action='store_true',
291 295
             help=_("Print call timing info"))
292 296
 
293
-        parser.add_argument('--os-auth-token',
294
-                default=utils.env('OS_AUTH_TOKEN'),
295
-                help='Defaults to env[OS_AUTH_TOKEN]')
297
+        parser.add_argument(
298
+            '--os-auth-token',
299
+            default=utils.env('OS_AUTH_TOKEN'),
300
+            help='Defaults to env[OS_AUTH_TOKEN]')
296 301
 
297
-        parser.add_argument('--os_username',
302
+        parser.add_argument(
303
+            '--os_username',
298 304
             help=argparse.SUPPRESS)
299 305
 
300
-        parser.add_argument('--os_password',
306
+        parser.add_argument(
307
+            '--os_password',
301 308
             help=argparse.SUPPRESS)
302 309
 
303
-        parser.add_argument('--os-tenant-name',
310
+        parser.add_argument(
311
+            '--os-tenant-name',
304 312
             metavar='<auth-tenant-name>',
305 313
             default=utils.env('OS_TENANT_NAME', 'NOVA_PROJECT_ID'),
306 314
             help=_('Defaults to env[OS_TENANT_NAME].'))
307
-        parser.add_argument('--os_tenant_name',
315
+        parser.add_argument(
316
+            '--os_tenant_name',
308 317
             help=argparse.SUPPRESS)
309 318
 
310
-        parser.add_argument('--os-tenant-id',
319
+        parser.add_argument(
320
+            '--os-tenant-id',
311 321
             metavar='<auth-tenant-id>',
312 322
             default=utils.env('OS_TENANT_ID'),
313 323
             help=_('Defaults to env[OS_TENANT_ID].'))
314 324
 
315
-        parser.add_argument('--os_auth_url',
325
+        parser.add_argument(
326
+            '--os_auth_url',
316 327
             help=argparse.SUPPRESS)
317 328
 
318
-        parser.add_argument('--os-region-name',
329
+        parser.add_argument(
330
+            '--os-region-name',
319 331
             metavar='<region-name>',
320 332
             default=utils.env('OS_REGION_NAME', 'NOVA_REGION_NAME'),
321 333
             help=_('Defaults to env[OS_REGION_NAME].'))
322
-        parser.add_argument('--os_region_name',
334
+        parser.add_argument(
335
+            '--os_region_name',
323 336
             help=argparse.SUPPRESS)
324 337
 
325
-        parser.add_argument('--os-auth-system',
338
+        parser.add_argument(
339
+            '--os-auth-system',
326 340
             metavar='<auth-system>',
327 341
             default=utils.env('OS_AUTH_SYSTEM'),
328 342
             help='Defaults to env[OS_AUTH_SYSTEM].')
329
-        parser.add_argument('--os_auth_system',
343
+        parser.add_argument(
344
+            '--os_auth_system',
330 345
             help=argparse.SUPPRESS)
331 346
 
332
-        parser.add_argument('--service-type',
347
+        parser.add_argument(
348
+            '--service-type',
333 349
             metavar='<service-type>',
334 350
             help=_('Defaults to compute for most actions'))
335
-        parser.add_argument('--service_type',
351
+        parser.add_argument(
352
+            '--service_type',
336 353
             help=argparse.SUPPRESS)
337 354
 
338
-        parser.add_argument('--service-name',
355
+        parser.add_argument(
356
+            '--service-name',
339 357
             metavar='<service-name>',
340 358
             default=utils.env('NOVA_SERVICE_NAME'),
341 359
             help=_('Defaults to env[NOVA_SERVICE_NAME]'))
342
-        parser.add_argument('--service_name',
360
+        parser.add_argument(
361
+            '--service_name',
343 362
             help=argparse.SUPPRESS)
344 363
 
345
-        parser.add_argument('--volume-service-name',
364
+        parser.add_argument(
365
+            '--volume-service-name',
346 366
             metavar='<volume-service-name>',
347 367
             default=utils.env('NOVA_VOLUME_SERVICE_NAME'),
348 368
             help=_('Defaults to env[NOVA_VOLUME_SERVICE_NAME]'))
349
-        parser.add_argument('--volume_service_name',
369
+        parser.add_argument(
370
+            '--volume_service_name',
350 371
             help=argparse.SUPPRESS)
351 372
 
352
-        parser.add_argument('--os-endpoint-type',
373
+        parser.add_argument(
374
+            '--os-endpoint-type',
353 375
             metavar='<endpoint-type>',
354 376
             dest='endpoint_type',
355
-            default=utils.env('NOVA_ENDPOINT_TYPE',
356
-                default=utils.env('OS_ENDPOINT_TYPE',
377
+            default=utils.env(
378
+                'NOVA_ENDPOINT_TYPE',
379
+                default=utils.env(
380
+                    'OS_ENDPOINT_TYPE',
357 381
                     default=DEFAULT_NOVA_ENDPOINT_TYPE)),
358 382
             help=_('Defaults to env[NOVA_ENDPOINT_TYPE], '
359
-                   'env[OS_ENDPOINT_TYPE] or ')
360
-                 + DEFAULT_NOVA_ENDPOINT_TYPE + '.')
383
+                   'env[OS_ENDPOINT_TYPE] or ') +
384
+                 DEFAULT_NOVA_ENDPOINT_TYPE + '.')
361 385
 
362
-        parser.add_argument('--endpoint-type',
386
+        parser.add_argument(
387
+            '--endpoint-type',
363 388
             help=argparse.SUPPRESS)
364 389
         # NOTE(dtroyer): We can't add --endpoint_type here due to argparse
365 390
         #                thinking usage-list --end is ambiguous; but it
@@ -368,23 +393,26 @@ class OpenStackComputeShell(object):
368 393
         # parser.add_argument('--endpoint_type',
369 394
         #     help=argparse.SUPPRESS)
370 395
 
371
-        parser.add_argument('--os-compute-api-version',
396
+        parser.add_argument(
397
+            '--os-compute-api-version',
372 398
             metavar='<compute-api-ver>',
373 399
             default=utils.env('OS_COMPUTE_API_VERSION',
374
-                default=DEFAULT_OS_COMPUTE_API_VERSION),
400
+                              default=DEFAULT_OS_COMPUTE_API_VERSION),
375 401
             help=_('Accepts 1.1 or 3, '
376
-                 'defaults to env[OS_COMPUTE_API_VERSION].'))
377
-        parser.add_argument('--os_compute_api_version',
402
+                   'defaults to env[OS_COMPUTE_API_VERSION].'))
403
+        parser.add_argument(
404
+            '--os_compute_api_version',
378 405
             help=argparse.SUPPRESS)
379 406
 
380
-        parser.add_argument('--bypass-url',
407
+        parser.add_argument(
408
+            '--bypass-url',
381 409
             metavar='<bypass-url>',
382 410
             dest='bypass_url',
383 411
             default=utils.env('NOVACLIENT_BYPASS_URL'),
384 412
             help="Use this API endpoint instead of the Service Catalog. "
385 413
                  "Defaults to env[NOVACLIENT_BYPASS_URL]")
386 414
         parser.add_argument('--bypass_url',
387
-            help=argparse.SUPPRESS)
415
+                            help=argparse.SUPPRESS)
388 416
 
389 417
         # The auth-system-plugins might require some extra options
390 418
         novaclient.auth_plugin.load_auth_system_opts(parser)
@@ -466,7 +494,8 @@ class OpenStackComputeShell(object):
466 494
             yield name, module
467 495
 
468 496
     def _add_bash_completion_subparser(self, subparsers):
469
-        subparser = subparsers.add_parser('bash_completion',
497
+        subparser = subparsers.add_parser(
498
+            'bash_completion',
470 499
             add_help=False,
471 500
             formatter_class=OpenStackHelpFormatter
472 501
         )
@@ -482,13 +511,14 @@ class OpenStackComputeShell(object):
482 511
             action_help = desc.strip()
483 512
             arguments = getattr(callback, 'arguments', [])
484 513
 
485
-            subparser = subparsers.add_parser(command,
514
+            subparser = subparsers.add_parser(
515
+                command,
486 516
                 help=action_help,
487 517
                 description=desc,
488 518
                 add_help=False,
489
-                formatter_class=OpenStackHelpFormatter
490
-            )
491
-            subparser.add_argument('-h', '--help',
519
+                formatter_class=OpenStackHelpFormatter)
520
+            subparser.add_argument(
521
+                '-h', '--help',
492 522
                 action='help',
493 523
                 help=argparse.SUPPRESS,
494 524
             )
@@ -512,7 +542,8 @@ class OpenStackComputeShell(object):
512 542
         if auth_token:
513 543
             return token.Token(auth_url, auth_token, **kwargs)
514 544
         else:
515
-            return password.Password(auth_url,
545
+            return password.Password(
546
+                auth_url,
516 547
                 username=kwargs.pop('username'),
517 548
                 user_id=kwargs.pop('user_id'),
518 549
                 password=kwargs.pop('password'),
@@ -630,9 +661,10 @@ class OpenStackComputeShell(object):
630 661
 
631 662
             if not auth_plugin or not auth_plugin.opts:
632 663
                 if not os_username and not os_user_id:
633
-                    raise exc.CommandError(_("You must provide a username "
634
-                            "or user id via --os-username, --os-user-id, "
635
-                            "env[OS_USERNAME] or env[OS_USER_ID]"))
664
+                    raise exc.CommandError(
665
+                        _("You must provide a username "
666
+                          "or user id via --os-username, --os-user-id, "
667
+                          "env[OS_USERNAME] or env[OS_USER_ID]"))
636 668
 
637 669
             if not any([args.os_tenant_name, args.os_tenant_id,
638 670
                         args.os_project_id, args.os_project_name]):
@@ -648,11 +680,12 @@ class OpenStackComputeShell(object):
648 680
                     os_auth_url = auth_plugin.get_auth_url()
649 681
 
650 682
             if not os_auth_url:
651
-                    raise exc.CommandError(_("You must provide an auth url "
652
-                            "via either --os-auth-url or env[OS_AUTH_URL] "
653
-                            "or specify an auth_system which defines a "
654
-                            "default url with --os-auth-system "
655
-                            "or env[OS_AUTH_SYSTEM]"))
683
+                    raise exc.CommandError(
684
+                        _("You must provide an auth url "
685
+                          "via either --os-auth-url or env[OS_AUTH_URL] "
686
+                          "or specify an auth_system which defines a "
687
+                          "default url with --os-auth-system "
688
+                          "or env[OS_AUTH_SYSTEM]"))
656 689
 
657 690
             project_id = args.os_project_id or args.os_tenant_id
658 691
             project_name = args.os_project_name or args.os_tenant_name
@@ -674,8 +707,9 @@ class OpenStackComputeShell(object):
674 707
                     project_domain_id=args.os_project_domain_id,
675 708
                     project_domain_name=args.os_project_domain_name)
676 709
                 end_time = time.time()
677
-                self.times.append(('%s %s' % ('auth_url', args.os_auth_url),
678
-                    start_time, end_time))
710
+                self.times.append(
711
+                    ('%s %s' % ('auth_url', args.os_auth_url),
712
+                     start_time, end_time))
679 713
 
680 714
         if (options.os_compute_api_version and
681 715
                 options.os_compute_api_version != '1.0'):
@@ -689,25 +723,27 @@ class OpenStackComputeShell(object):
689 723
                                          " interchangeably."))
690 724
 
691 725
             if not os_auth_url:
692
-                raise exc.CommandError(_("You must provide an auth url "
693
-                        "via either --os-auth-url or env[OS_AUTH_URL]"))
726
+                raise exc.CommandError(
727
+                    _("You must provide an auth url "
728
+                      "via either --os-auth-url or env[OS_AUTH_URL]"))
694 729
 
695 730
         completion_cache = client.CompletionCache(os_username, os_auth_url)
696 731
 
697
-        self.cs = client.Client(options.os_compute_api_version,
698
-                os_username, os_password, os_tenant_name,
699
-                tenant_id=os_tenant_id, user_id=os_user_id,
700
-                auth_url=os_auth_url, insecure=insecure,
701
-                region_name=os_region_name, endpoint_type=endpoint_type,
702
-                extensions=self.extensions, service_type=service_type,
703
-                service_name=service_name, auth_system=os_auth_system,
704
-                auth_plugin=auth_plugin, auth_token=auth_token,
705
-                volume_service_name=volume_service_name,
706
-                timings=args.timings, bypass_url=bypass_url,
707
-                os_cache=os_cache, http_log_debug=options.debug,
708
-                cacert=cacert, timeout=timeout,
709
-                session=keystone_session, auth=keystone_auth,
710
-                completion_cache=completion_cache)
732
+        self.cs = client.Client(
733
+            options.os_compute_api_version,
734
+            os_username, os_password, os_tenant_name,
735
+            tenant_id=os_tenant_id, user_id=os_user_id,
736
+            auth_url=os_auth_url, insecure=insecure,
737
+            region_name=os_region_name, endpoint_type=endpoint_type,
738
+            extensions=self.extensions, service_type=service_type,
739
+            service_name=service_name, auth_system=os_auth_system,
740
+            auth_plugin=auth_plugin, auth_token=auth_token,
741
+            volume_service_name=volume_service_name,
742
+            timings=args.timings, bypass_url=bypass_url,
743
+            os_cache=os_cache, http_log_debug=options.debug,
744
+            cacert=cacert, timeout=timeout,
745
+            session=keystone_session, auth=keystone_auth,
746
+            completion_cache=completion_cache)
711 747
 
712 748
         # Now check for the password/token of which pieces of the
713 749
         # identifying keyring key can come from the underlying client
@@ -838,7 +874,7 @@ class OpenStackHelpFormatter(argparse.HelpFormatter):
838 874
     def __init__(self, prog, indent_increment=2, max_help_position=32,
839 875
                  width=None):
840 876
         super(OpenStackHelpFormatter, self).__init__(prog, indent_increment,
841
-              max_help_position, width)
877
+                                                     max_help_position, width)
842 878
 
843 879
     def start_section(self, heading):
844 880
         # Title-case the headings

+ 4
- 2
novaclient/tests/test_shell.py View File

@@ -94,7 +94,8 @@ class ShellTest(utils.TestCase):
94 94
     def register_keystone_discovery_fixture(self, mreq):
95 95
         v2_url = "http://no.where/v2.0"
96 96
         v2_version = fixture.V2Discovery(v2_url)
97
-        mreq.register_uri('GET', v2_url, json=_create_ver_list([v2_version]),
97
+        mreq.register_uri(
98
+            'GET', v2_url, json=_create_ver_list([v2_version]),
98 99
             status_code=200)
99 100
 
100 101
     def test_help_unknown_command(self):
@@ -342,5 +343,6 @@ class ShellTestKeystoneV3(ShellTest):
342 343
     def register_keystone_discovery_fixture(self, mreq):
343 344
         v3_url = "http://no.where/v3"
344 345
         v3_version = fixture.V3Discovery(v3_url)
345
-        mreq.register_uri('GET', v3_url, json=_create_ver_list([v3_version]),
346
+        mreq.register_uri(
347
+            'GET', v3_url, json=_create_ver_list([v3_version]),
346 348
             status_code=200)

+ 1
- 1
tox.ini View File

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

Loading…
Cancel
Save