From d38078cce3c7fcfeb21a9653b49a201eff02e5d7 Mon Sep 17 00:00:00 2001 From: Rick Bartra Date: Tue, 1 Sep 2020 13:40:08 -0400 Subject: [PATCH] fix: Gate fix for Shipyard docs and pep8 gates Now that the Shipyard gates are running on Focal(20.04), flake8, grpcio, and pyflakes need to use a version compatible with python3.8 and Ubuntu 20.04 which is the default python version in Ubuntu focal. Also unpinning setuptools so that it is compatible with python3.8. Additionally, address pep8 violations that arise from using a newer version of flake8 Change-Id: Idc3c5d66b48fc9e4497a71d1b640bcd2872c22eb --- src/bin/shipyard_airflow/requirements.txt | 2 +- src/bin/shipyard_airflow/test-requirements.txt | 3 ++- src/bin/shipyard_airflow/tox.ini | 6 ++++-- .../shipyard_client/api_client/base_client.py | 3 ++- .../shipyard_client/cli/create/commands.py | 2 +- .../shipyard_client/cli/describe/commands.py | 3 ++- .../shipyard_client/shipyard_client/cli/format_utils.py | 2 ++ .../shipyard_client/shipyard_client/cli/get/commands.py | 6 ++++-- src/bin/shipyard_client/test-requirements.txt | 3 ++- src/bin/shipyard_client/tox.ini | 8 +++++--- 10 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/bin/shipyard_airflow/requirements.txt b/src/bin/shipyard_airflow/requirements.txt index f457fe0b..7be5bee1 100644 --- a/src/bin/shipyard_airflow/requirements.txt +++ b/src/bin/shipyard_airflow/requirements.txt @@ -21,6 +21,7 @@ configparser==3.5.0 cryptography==2.3 falcon==1.4.1 jsonschema==2.6.0 +grpcio>=1.16.0 keystoneauth1==3.11.0 keystonemiddleware==5.2.0 networkx==2.1 # common/deployment_group @@ -31,7 +32,6 @@ psycopg2-binary==2.8.4 python-dateutil==2.7.3 python-memcached==1.59 requests==2.20.0 -setuptools==40.4.1 SQLAlchemy==1.3.15 ulid==1.1 uwsgi~=2.0.19.1 diff --git a/src/bin/shipyard_airflow/test-requirements.txt b/src/bin/shipyard_airflow/test-requirements.txt index 4dc208d2..75ba6c2f 100644 --- a/src/bin/shipyard_airflow/test-requirements.txt +++ b/src/bin/shipyard_airflow/test-requirements.txt @@ -1,4 +1,5 @@ # Testing +pyflakes>=2.1.1 amqp~=2.6.0 pytest==3.5.0 pytest-cov==2.5.1 @@ -11,7 +12,7 @@ apache-airflow[crypto,celery,postgres,hive,hdfs,jdbc]==1.10.1 git+https://opendev.org/airship/promenade.git@master#egg=promenade # Linting -flake8==3.3.0 +flake8>=3.3.0 # Security scanning bandit>=1.5.0 # Apache-2.0 diff --git a/src/bin/shipyard_airflow/tox.ini b/src/bin/shipyard_airflow/tox.ini index e2e43c12..537cb57f 100644 --- a/src/bin/shipyard_airflow/tox.ini +++ b/src/bin/shipyard_airflow/tox.ini @@ -36,7 +36,7 @@ commands = [testenv:pep8] basepython=python3 deps= - flake8==3.3.0 + flake8>=3.3.0 bandit>=1.5.0 commands = flake8 {toxinidir}/shipyard_airflow @@ -76,7 +76,9 @@ filename = *.py # cases need to be un-ignored and fixed up. These are ignored because of # the method in which test requirements bring in the hacking rules from # other projects. -ignore = F841, H101, H201, H210, H238, H301, H304, H306, H401, H403, H404, H405 +# W504 line break after binary operator +# TODO(rb560u): Address E722 violations +ignore = F841, H101, H201, H210, H238, H301, H304, H306, H401, H403, H404, H405, W504, E722 # NOTE(Bryan Strassner) excluding 3rd party and generated code that is brought into the # codebase. exclude = .venv,.git,.tox,build,dist,*lib/python*,*egg,alembic/env.py,docs diff --git a/src/bin/shipyard_client/shipyard_client/api_client/base_client.py b/src/bin/shipyard_client/shipyard_client/api_client/base_client.py index d806beb5..5e64d871 100644 --- a/src/bin/shipyard_client/shipyard_client/api_client/base_client.py +++ b/src/bin/shipyard_client/shipyard_client/api_client/base_client.py @@ -145,7 +145,8 @@ class BaseClient(metaclass=abc.ABCMeta): if token: return token else: - return self._get_ks_session().get_auth_headers().get('X-Auth-Token') + return self._get_ks_session().get_auth_headers().\ + get('X-Auth-Token') def _get_ks_session(self): self.logger.debug('Accessing keystone for keystone session') diff --git a/src/bin/shipyard_client/shipyard_client/cli/create/commands.py b/src/bin/shipyard_client/shipyard_client/cli/create/commands.py index 6ef0779d..a837989e 100644 --- a/src/bin/shipyard_client/shipyard_client/cli/create/commands.py +++ b/src/bin/shipyard_client/shipyard_client/cli/create/commands.py @@ -66,7 +66,7 @@ SHORT_DESC_ACTION = ( def create_action(ctx, action_name, param, allow_intermediate_commits=False): check_action_command(ctx, action_name) - if not param and action_name is 'redeploy_server': + if not param and action_name == 'redeploy_server': ctx.fail('At least one parameter must be specified using ' '--param="" with action redeploy_server') else: diff --git a/src/bin/shipyard_client/shipyard_client/cli/describe/commands.py b/src/bin/shipyard_client/shipyard_client/cli/describe/commands.py index 9da41ef5..fa092bff 100644 --- a/src/bin/shipyard_client/shipyard_client/cli/describe/commands.py +++ b/src/bin/shipyard_client/shipyard_client/cli/describe/commands.py @@ -120,7 +120,8 @@ SHORT_DESC_NOTEDETAILS = ( "Retrieves the detailed information about the supplied action id.") -@describe.command('notedetails', +@describe.command( + 'notedetails', help=DESC_NOTEDETAILS, short_help=SHORT_DESC_NOTEDETAILS) @click.argument('note_id') @click.pass_context diff --git a/src/bin/shipyard_client/shipyard_client/cli/format_utils.py b/src/bin/shipyard_client/shipyard_client/cli/format_utils.py index 9680e287..efe3e903 100644 --- a/src/bin/shipyard_client/shipyard_client/cli/format_utils.py +++ b/src/bin/shipyard_client/shipyard_client/cli/format_utils.py @@ -62,6 +62,7 @@ def cli_format_status_handler(response, is_error=False): return "Error: Unable to decode response. Value: {}".format( response.text) + def cli_format_exception_handler(exc_msg): """ Formatter for custom error raised by Shipyard """ try: @@ -73,6 +74,7 @@ def cli_format_exception_handler(exc_msg): return "Error: Unable to decode response. Value: {}".format( exc_msg) + def cli_format_response(formatted, response): """ Handler for Shipyard status and error responses diff --git a/src/bin/shipyard_client/shipyard_client/cli/get/commands.py b/src/bin/shipyard_client/shipyard_client/cli/get/commands.py index 69892d09..ed74f2ba 100644 --- a/src/bin/shipyard_client/shipyard_client/cli/get/commands.py +++ b/src/bin/shipyard_client/shipyard_client/cli/get/commands.py @@ -180,8 +180,10 @@ def get_renderedconfigdocs(ctx, buffer, committed, last_site_action, _version = get_version(ctx, buffer, committed, last_site_action, successful_site_action) - click.echo(GetRenderedConfigdocs(ctx, _version, - cleartext_secrets).invoke_and_return_resp()) + click.echo(GetRenderedConfigdocs( + ctx, + _version, + cleartext_secrets).invoke_and_return_resp()) DESC_WORKFLOWS = """ diff --git a/src/bin/shipyard_client/test-requirements.txt b/src/bin/shipyard_client/test-requirements.txt index 6099c76f..a5f9b1fb 100644 --- a/src/bin/shipyard_client/test-requirements.txt +++ b/src/bin/shipyard_client/test-requirements.txt @@ -1,4 +1,5 @@ # Testing +pyflakes>=2.1.1 amqp~=2.6.0 pytest==3.5.0 pytest-cov==2.5.1 @@ -6,7 +7,7 @@ responses==0.10.2 testfixtures==5.1.1 # Linting -flake8==3.3.0 +flake8>=3.3.0 # Security scanning bandit>=1.1.0 # Apache-2.0 diff --git a/src/bin/shipyard_client/tox.ini b/src/bin/shipyard_client/tox.ini index d00fe3e3..6a030ffa 100644 --- a/src/bin/shipyard_client/tox.ini +++ b/src/bin/shipyard_client/tox.ini @@ -33,10 +33,10 @@ commands = [testenv:pep8] basepython=python3 deps= - flake8==3.3.0 + flake8>=3.3.0 bandit>=1.5.0 commands = - flake8 {toxinidir}/shipyard_airflow + flake8 {toxinidir}/shipyard_client bandit -r shipyard_airflow [testenv:bandit] @@ -47,5 +47,7 @@ commands = [flake8] filename = *.py -ignore = F841 +# W504 line break after binary operator +# TODO(rb560u): Address E722 violations +ignore = F841,W504,E722 exclude = .venv,.git,.tox,build,dist,*lib/python*,*egg,docs