From f529a7e337be672d5cf423c2a3f8a1506c173d8b Mon Sep 17 00:00:00 2001 From: albailey Date: Wed, 2 Dec 2020 09:13:48 -0600 Subject: [PATCH] Cleanup pep8 and flake8 errors in nova-api-proxy A newer version of flake8 needed to be used, and several error codes are no longer being suppressed. Closes-Bug: 1906529 Signed-off-by: albailey Change-Id: Ifc38b664722da533fbf46614d59c00670c8f8780 --- .../nova-api-proxy/nova_api_proxy/apps/acceptor.py | 6 +++--- .../nova-api-proxy/nova_api_proxy/apps/proxy.py | 3 +-- .../nova_api_proxy/common/histogram.py | 4 ++-- .../nova-api-proxy/nova_api_proxy/common/service.py | 2 +- .../nova-api-proxy/nova_api_proxy/common/utils.py | 2 +- nova-api-proxy/tox.ini | 13 ++----------- 6 files changed, 10 insertions(+), 20 deletions(-) diff --git a/nova-api-proxy/nova-api-proxy/nova_api_proxy/apps/acceptor.py b/nova-api-proxy/nova-api-proxy/nova_api_proxy/apps/acceptor.py index 6db69b08..78f3a8b5 100644 --- a/nova-api-proxy/nova-api-proxy/nova_api_proxy/apps/acceptor.py +++ b/nova-api-proxy/nova-api-proxy/nova_api_proxy/apps/acceptor.py @@ -53,8 +53,8 @@ class APIController(Middleware): def __call__(self, req): self._generate_log(req) LOG.debug("Check if it is a NFVI action") - if (req.environ['REQUEST_METHOD'] == 'POST' and - self._is_nfvi_request(req)): + if (req.environ['REQUEST_METHOD'] == 'POST' and self._is_nfvi_request( + req)): remote_host = CONF.nfvi_compute_listen remote_port = CONF.nfvi_compute_listen_port return APIDispatcher(self.application, remote_host, remote_port) @@ -169,7 +169,7 @@ class DebugHeaders(Middleware): translate_keys = { 'CONTENT_LENGTH': 'HTTP_CONTENT_LENGTH', 'CONTENT_TYPE': 'HTTP_CONTENT_TYPE', - } + } def __init__(self, app, conf): self._show_body = CONF.show_request_body diff --git a/nova-api-proxy/nova-api-proxy/nova_api_proxy/apps/proxy.py b/nova-api-proxy/nova-api-proxy/nova_api_proxy/apps/proxy.py index 3793bff7..dc9342d6 100644 --- a/nova-api-proxy/nova-api-proxy/nova_api_proxy/apps/proxy.py +++ b/nova-api-proxy/nova-api-proxy/nova_api_proxy/apps/proxy.py @@ -89,8 +89,7 @@ class DebugProxy(Application): else: body = '' - path = (environ.get('SCRIPT_NAME', '') + - environ.get('PATH_INFO', '')) + path = (environ.get('SCRIPT_NAME', '') + environ.get('PATH_INFO', '')) path = urllib.quote(path) if 'QUERY_STRING' in environ: path += '?' + environ['QUERY_STRING'] diff --git a/nova-api-proxy/nova-api-proxy/nova_api_proxy/common/histogram.py b/nova-api-proxy/nova-api-proxy/nova_api_proxy/common/histogram.py index a657d989..d51e257a 100644 --- a/nova-api-proxy/nova-api-proxy/nova_api_proxy/common/histogram.py +++ b/nova-api-proxy/nova-api-proxy/nova_api_proxy/common/histogram.py @@ -101,8 +101,8 @@ class Histogram(object): for idx, bucket_value in enumerate(self._buckets): if 0 != bucket_value: LOG.info(" %03i [up to %03i secs]: %07i %s" - % (idx, math.pow(2, idx), bucket_value, - '*' * min(60, bucket_value))) + % (idx, math.pow(2, idx), bucket_value, + '*' * min(60, bucket_value))) LOG.info("%s" % '-' * 120) diff --git a/nova-api-proxy/nova-api-proxy/nova_api_proxy/common/service.py b/nova-api-proxy/nova-api-proxy/nova_api_proxy/common/service.py index 4a1eb563..67cfa135 100644 --- a/nova-api-proxy/nova-api-proxy/nova_api_proxy/common/service.py +++ b/nova-api-proxy/nova-api-proxy/nova_api_proxy/common/service.py @@ -70,7 +70,7 @@ server_opts = [ "If an incoming connection is idle for this number of " "seconds it will be closed. A value of '0' means " "wait forever."), - ] +] CONF = cfg.CONF CONF.register_opts(server_opts) diff --git a/nova-api-proxy/nova-api-proxy/nova_api_proxy/common/utils.py b/nova-api-proxy/nova-api-proxy/nova_api_proxy/common/utils.py index f0823514..a24d8ca2 100644 --- a/nova-api-proxy/nova-api-proxy/nova_api_proxy/common/utils.py +++ b/nova-api-proxy/nova-api-proxy/nova_api_proxy/common/utils.py @@ -17,5 +17,5 @@ def set_request_forward_environ(req, remote_host, remote_port): req.environ['SERVER_NAME'] = remote_host req.environ['SERVER_PORT'] = remote_port if ('REMOTE_ADDR' in req.environ and 'HTTP_X_FORWARDED_FOR' not in - req.environ): + req.environ): req.environ['HTTP_X_FORWARDED_FOR'] = req.environ['REMOTE_ADDR'] diff --git a/nova-api-proxy/tox.ini b/nova-api-proxy/tox.ini index 7d9a55a6..e4073772 100644 --- a/nova-api-proxy/tox.ini +++ b/nova-api-proxy/tox.ini @@ -20,24 +20,16 @@ whitelist_externals = find commands = {posargs} [flake8] -# Temporarily ignoring these warnings -# E123 closing bracket does not match indentation of opening bracket -# E127 continuation line over-indented for visual indent -# E129 visually indented line with same indent as next logical line # - hacking codes - # H104: File contains nothing but comments # H301: one import per line # H404: multi line docstring should start without a leading new line # H405: multi line docstring summary not separated with an empty line # H501: Do not use self.__dict__ for string formatting -# - flake8 codes - -# F821 undefined name 'unicode' (python3 specific) -ignore=E123,E127,E129 - H104,H301,H404,H405,H501, - F821 +ignore=H104,H301,H404,H405,H501 # H106 Don’t put vim configuration in source files (off by default). # H203 Use assertIs(Not)None to check for None (off by default). -# TODO: enable: H904 Delay string interpolations at logging calls (off by default). +# TODO: enable: H904 Delay string interpolations at logging calls enable-extensions = H106,H203 max-line-length=84 @@ -47,7 +39,6 @@ skip_install = True deps = hacking flake8-bugbear - flake8<3.6.0 commands = flake8