From bde6982ded5ae8995d6ba0b758ea990086b7fa05 Mon Sep 17 00:00:00 2001 From: Al Bailey Date: Tue, 21 Jan 2020 16:31:33 -0600 Subject: [PATCH] Updating flake8 version for distributed cloud This also fixes the linters target which fails when yamllint does not find any inputs. Most new failures are being suppressed for now, and will be cleaned up by future submissions. Story: 2004515 Task: 38739 Change-Id: I8bddba83408be19a487837e326c86432579c50db Signed-off-by: Al Bailey --- .../dcmanager/api/controllers/v1/subclouds.py | 2 +- .../dcmanager/manager/sw_update_manager.py | 2 +- .../dcorch/engine/sync_services/volume.py | 4 +- distributedcloud/tox.ini | 38 +++++++++++++++++-- tox.ini | 2 +- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/distributedcloud/dcmanager/api/controllers/v1/subclouds.py b/distributedcloud/dcmanager/api/controllers/v1/subclouds.py index 55714f26b..5bcae9b77 100644 --- a/distributedcloud/dcmanager/api/controllers/v1/subclouds.py +++ b/distributedcloud/dcmanager/api/controllers/v1/subclouds.py @@ -265,7 +265,7 @@ class SubcloudsController(object): if 'nexthop_gateway' in install_values: try: gateway_ip = IPAddress(install_values['nexthop_gateway']) - except AddrFormatError: + except AddrFormatError as e: LOG.exception(e) pecan.abort(400, _("nexthop_gateway address invalid: %s") % e) if gateway_ip.version != ip_version: diff --git a/distributedcloud/dcmanager/manager/sw_update_manager.py b/distributedcloud/dcmanager/manager/sw_update_manager.py index 78cbe475d..448a78e96 100644 --- a/distributedcloud/dcmanager/manager/sw_update_manager.py +++ b/distributedcloud/dcmanager/manager/sw_update_manager.py @@ -1078,7 +1078,7 @@ class PatchOrchThread(threading.Thread): try: ks_client = self.get_ks_client(region) - except (keystone_exceptions.EndpointNotFound, IndexError) as e: + except (keystone_exceptions.EndpointNotFound, IndexError): message = ("Identity endpoint for subcloud: %s not found." % region) LOG.error(message) diff --git a/distributedcloud/dcorch/engine/sync_services/volume.py b/distributedcloud/dcorch/engine/sync_services/volume.py index f8523409b..36c499683 100644 --- a/distributedcloud/dcorch/engine/sync_services/volume.py +++ b/distributedcloud/dcorch/engine/sync_services/volume.py @@ -80,7 +80,7 @@ class VolumeSyncThread(SyncThread): func_name = request.orch_job.operation_type + \ "_" + rsrc.resource_type getattr(self, func_name)(request, rsrc) - except keystone_exceptions.EndpointNotFound as e: + except keystone_exceptions.EndpointNotFound: # Cinder is optional in the subcloud, so this isn't considered # an error. LOG.info("sync_volume_resource: {} does not have a volume " @@ -247,7 +247,7 @@ class VolumeSyncThread(SyncThread): .format(self.subcloud_engine.subcloud.region_name, str(e)), extra=self.log_extra) return None - except keystone_exceptions.EndpointNotFound as e: + except keystone_exceptions.EndpointNotFound: LOG.info("get_quota_class: subcloud {} does not have a volume " "endpoint in keystone" .format(self.subcloud_engine.subcloud.region_name), diff --git a/distributedcloud/tox.ini b/distributedcloud/tox.ini index 3790cd86f..4cb03782d 100644 --- a/distributedcloud/tox.ini +++ b/distributedcloud/tox.ini @@ -66,7 +66,9 @@ commands = oslo_debug_helper {posargs} [testenv:pep8] basepython = python3 -deps = hacking<0.11,>=0.10.2 +deps = hacking>=1.1.0,<=2.0.0 + pycodestyle>=2.0.0 + flake8-bugbear commands = flake8 [testenv:venv] @@ -138,9 +140,27 @@ basepython = python3 commands = oslo_debug_helper {posargs} [flake8] -# E123, E125 skipped as they are invalid PEP-8. show-source = True -ignore = E123,E125,H233 +# Suppressed flake8 codes +# W503 line break before binary operator +# W504 line break after binary operator +# W605 invalid escape sequence +# E117 over-indented +# E123 closing bracket does not match indentation of opening bracket's line +# E125 continuation line with same indent as next logical line +# E305 expected 2 blank lines after class or function definition +# E402 module level import not at top of file +# E501 line too long +# E731 do not assign a lambda expression, use a def +# -B- codes are bugbear errors +# B005 Using .strip() with multi-character strings is misleading the reader. +# B006 Do not use mutable data structures for argument defaults. +# B007 Loop control variable not used within the loop body. +# B009 Do not call getattr with a constant attribute value, +# B306 `BaseException.message` has been deprecated as of Python 2.6 and is removed in Python 3 +ignore = W503,W504,W605, + E117,E123,E125,E305,E402,E501,E731, + B005,B006,B007,B009,B306 builtins = _ exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build @@ -160,3 +180,15 @@ deps = {[testenv]deps} commands = pylint {posargs} dcmanager dcorch --rcfile=./pylint.rc + +[testenv:linters] +basepython = python3 +# bashate ignore: +# E006 - accept long lines +# E040 - false positive on |& syntax (new in bash 4) +whitelist_externals = bash +commands = + bash -c "find {toxinidir} \ + \( -name .tox -prune \) \ + -o -type f -name '*.yaml' \ + -print0 | xargs -r -0 yamllint" diff --git a/tox.ini b/tox.ini index 34bb8e79d..6f6cf142a 100644 --- a/tox.ini +++ b/tox.ini @@ -47,7 +47,7 @@ commands = bash -c "find {toxinidir} \ \( -name .tox -prune \) \ -o -type f -name '*.yaml' \ - -print0 | xargs -0 yamllint" + -print0 | xargs -r -0 yamllint" [testenv:docs] basepython = python3