From ecd5a624e22d1a81d44c84bf1e0192dd3af3ad0d Mon Sep 17 00:00:00 2001 From: Al Bailey Date: Mon, 16 Dec 2019 08:48:14 -0600 Subject: [PATCH] Fix zuul tox flake8 failures from newer version of hacking A newer version of hacking was released which enables additional checks and is breaking flake8 and zuul. Hacking has now been clamped at 2.0.0 in test-requirements.txt Added the same for patch-alarm, although it was not failing. The new checks that are fixed are: H106: Don't put vim configuration in source files W605 invalid escape sequence F632 use ==/!= to compare str, bytes, and int literals F841 local variable is assigned to but never used The following flake8 extension check has been removed: H904 Delay string interpolations at logging calls Partial-Bug: 1856585 Change-Id: I8bdc94539f4a6ce243c4e30efc07eed3bad1ce62 Signed-off-by: Al Bailey (cherry picked from commit 5d2da5d041028afa916149da660809ca6fc4fb73) --- .../cgcs_make_patch/make_patch_functions.py | 2 +- .../cgcs-patch/cgcs_patch/authapi/auth_token.py | 1 - cgcs-patch/cgcs-patch/cgcs_patch/authapi/policy.py | 3 +-- cgcs-patch/cgcs-patch/cgcs_patch/base.py | 2 +- cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py | 8 ++++---- cgcs-patch/cgcs-patch/test-requirements.txt | 2 +- cgcs-patch/cgcs-patch/tox.ini | 11 ++++++----- patch-alarm/patch-alarm/test-requirements.txt | 2 +- 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/cgcs-patch/cgcs-patch/cgcs_make_patch/make_patch_functions.py b/cgcs-patch/cgcs-patch/cgcs_make_patch/make_patch_functions.py index 0ab82e79..6cec6f36 100644 --- a/cgcs-patch/cgcs-patch/cgcs_make_patch/make_patch_functions.py +++ b/cgcs-patch/cgcs-patch/cgcs_make_patch/make_patch_functions.py @@ -1498,7 +1498,7 @@ def set_capture_source_path(): old_path = "%s/stx/extras.ND/scripts/source_collect_package" % my_repo if os.path.isfile(old_path): rc = issue_cmd_rc("mkdir -p %s" % new_dir) - rc = issue_cmd_rc("\cp -f %s %s" % (old_path, new_path)) + rc = issue_cmd_rc("\\cp -f %s %s" % (old_path, new_path)) if rc == 0: capture_source_path = new_path diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/authapi/auth_token.py b/cgcs-patch/cgcs-patch/cgcs_patch/authapi/auth_token.py index 87e78a58..8b375fc4 100755 --- a/cgcs-patch/cgcs-patch/cgcs_patch/authapi/auth_token.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/authapi/auth_token.py @@ -1,4 +1,3 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 # -*- encoding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/authapi/policy.py b/cgcs-patch/cgcs-patch/cgcs_patch/authapi/policy.py index 81c94582..285c6a16 100755 --- a/cgcs-patch/cgcs-patch/cgcs_patch/authapi/policy.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/authapi/policy.py @@ -1,5 +1,4 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - +# # Copyright (c) 2011 OpenStack Foundation # All Rights Reserved. # diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/base.py b/cgcs-patch/cgcs-patch/cgcs_patch/base.py index 8e479053..bf20505c 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/base.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/base.py @@ -1,5 +1,5 @@ """ -Copyright (c) 2017-2017 Wind River Systems, Inc. +Copyright (c) 2017-2019 Wind River Systems, Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py b/cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py index 832e4e95..a4d55c46 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py @@ -375,11 +375,11 @@ class PatchData(object): for pkgver in self.package_versions[patch_sw_version][pkgname][arch].keys(): if self.package_versions[patch_sw_version][pkgname][arch][pkgver] == patch_id: del self.package_versions[patch_sw_version][pkgname][arch][pkgver] - if len(self.package_versions[patch_sw_version][pkgname][arch]) is 0: + if len(self.package_versions[patch_sw_version][pkgname][arch]) == 0: del self.package_versions[patch_sw_version][pkgname][arch] - if len(self.package_versions[patch_sw_version][pkgname]) is 0: + if len(self.package_versions[patch_sw_version][pkgname]) == 0: del self.package_versions[patch_sw_version][pkgname] - if len(self.package_versions[patch_sw_version]) is 0: + if len(self.package_versions[patch_sw_version]) == 0: del self.package_versions[patch_sw_version] for patch_sw_version in self.groups.keys(): @@ -1018,7 +1018,7 @@ class PatchFile(object): for cert_type_str in cert_type_all: try: PatchFile.read_patch(abs_patch, metadata_only=True, cert_type=[cert_type_str]) - except PatchValidationFailure as e: + except PatchValidationFailure: pass else: # Successfully opened the file for reading, and we have discovered the cert_type diff --git a/cgcs-patch/cgcs-patch/test-requirements.txt b/cgcs-patch/cgcs-patch/test-requirements.txt index 3f4e581e..dadd6c56 100644 --- a/cgcs-patch/cgcs-patch/test-requirements.txt +++ b/cgcs-patch/cgcs-patch/test-requirements.txt @@ -2,7 +2,7 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking>=1.1.0 # Apache-2.0 +hacking>=1.1.0,<=2.0.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 mock>=2.0.0 # BSD diff --git a/cgcs-patch/cgcs-patch/tox.ini b/cgcs-patch/cgcs-patch/tox.ini index ba9c568b..f3fb049a 100644 --- a/cgcs-patch/cgcs-patch/tox.ini +++ b/cgcs-patch/cgcs-patch/tox.ini @@ -62,18 +62,19 @@ commands = {[testenv:stestr]commands} # H401 docstring should not start with a space # H404 multi line docstring should start without a leading new line # H405 multi line docstring summary not separated with an empty line +# Note: W503 and W504 are mutually exclusive. Must select one of them to suppress. +# W504 line break after binary operator # E501 line too long. skipped because some of the code files include templates # that end up quite wide # F401 'XXXXX' imported but unused -# F841 local variable 'XXXXXX' is assigned to but never used show-source = True -#ignore = H101,H102,H105,H306,H401,H404,H405,E501,F401,F841 -ignore = H101,H102,H105,H306,H401,H404,H405,E501,F401 +ignore = H101,H102,H105,H306,H401,H404,H405, + W504,E501,F401 exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,release-tag-* # H106: Don't put vim configuration in source files (off by default). # H203: Use assertIs(Not)None to check for None (off by default). -# enable: H904 Delay string interpolations at logging calls (off by default). -enable-extensions = H106 H203 H904 +# (todo) enable H904 Delay string interpolations at logging calls (off by default) +enable-extensions = H106 H203 max-line-length = 120 diff --git a/patch-alarm/patch-alarm/test-requirements.txt b/patch-alarm/patch-alarm/test-requirements.txt index 3f4e581e..dadd6c56 100644 --- a/patch-alarm/patch-alarm/test-requirements.txt +++ b/patch-alarm/patch-alarm/test-requirements.txt @@ -2,7 +2,7 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking>=1.1.0 # Apache-2.0 +hacking>=1.1.0,<=2.0.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 mock>=2.0.0 # BSD