From 61b0b2e03846f3d743b8dafa604632e15ca47ea1 Mon Sep 17 00:00:00 2001 From: Luigi Toscano Date: Mon, 26 Nov 2018 19:03:02 +0100 Subject: [PATCH] Bump the version of hacking to 1.1.0, with few fixes Also switch to pycodestyle from pep8 which requires a bump of the the version of flake8 too. Skip the following checks for now: - E123 Closing bracket does not match indentation of opening bracket's line - E226 Missing whitespace around arithmetic operator - E402 Module level import not at top of file - E731 Do not assign a lambda expression, use a def - W503 Line break occurred before a binary operator They should be probably revisited and fixed, if possible, or skipped individually using # noqa The following checks reported a limited number of errors and they were fixed directly in this review: - E241 Multiple spaces after ',' - E501 Line too long (82 > 79 characters) Change-Id: I1f185d2efd1adf27a26e3ac93f2e1011c0b63124 --- lower-constraints.txt | 6 +++--- sahara/plugins/cdh/plugin_utils.py | 2 +- sahara/plugins/cdh/validation.py | 4 ++-- sahara/plugins/mapr/services/oozie/oozie.py | 3 ++- sahara/service/heat/templates.py | 2 +- sahara/service/ops.py | 2 +- sahara/service/quotas.py | 2 +- sahara/service/validations/cluster_templates.py | 2 +- sahara/tests/unit/db/migration/test_migrations.py | 2 +- sahara/utils/hacking/checks.py | 4 ++-- test-requirements.txt | 2 +- tox.ini | 6 ++++++ 12 files changed, 22 insertions(+), 15 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index 8567363e5f..efaf3f8ee9 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -32,14 +32,14 @@ eventlet==0.18.2 extras==1.0.0 fasteners==0.14.1 fixtures==3.0.0 -flake8==2.5.5 +flake8==2.6.2 Flask==1.0.2 future==0.16.0 futurist==1.6.0 gitdb2==2.0.3 GitPython==2.1.8 greenlet==0.4.13 -hacking==0.12.0 +hacking==1.1.0 idna==2.6 imagesize==1.0.0 iso8601==0.1.11 @@ -91,7 +91,6 @@ paramiko==2.0.0 Paste==2.0.3 PasteDeploy==1.5.2 pbr==2.0.0 -pep8==1.5.7 pika-pool==0.1.3 pika==0.10.0 prettytable==0.7.2 @@ -99,6 +98,7 @@ psycopg2==2.6.2 pyasn1==0.4.2 pycadf==2.7.0 pycparser==2.18 +pycodestyle==2.4.0 pyflakes==0.8.1 Pygments==2.2.0 pyinotify==0.9.6 diff --git a/sahara/plugins/cdh/plugin_utils.py b/sahara/plugins/cdh/plugin_utils.py index 662b769e99..e5e2fe4bbd 100644 --- a/sahara/plugins/cdh/plugin_utils.py +++ b/sahara/plugins/cdh/plugin_utils.py @@ -365,7 +365,7 @@ class AbstractPluginUtils(object): if r.execute_command('ls %s/ext-2.2' % extjs_vm_location_dir, raise_when_error=False)[0] != 0: r.execute_command('curl -L -o \'%s\' %s' % ( - extjs_vm_location_path, extjs_remote_location), + extjs_vm_location_path, extjs_remote_location), run_as_root=True) r.execute_command('unzip %s -d %s' % ( extjs_vm_location_path, extjs_vm_location_dir), diff --git a/sahara/plugins/cdh/validation.py b/sahara/plugins/cdh/validation.py index a22705bd46..0c29b4f77d 100644 --- a/sahara/plugins/cdh/validation.py +++ b/sahara/plugins/cdh/validation.py @@ -105,7 +105,7 @@ class Validator(object): if oo_count > 1: raise ex.InvalidComponentCountException( - 'OOZIE_SERVER', _('0 or 1'), oo_count) + 'OOZIE_SERVER', _('0 or 1'), oo_count) if oo_count == 1: if dn_count < 1: @@ -148,7 +148,7 @@ class Validator(object): hue_count = cls.get_inst_count(cluster, 'HUE_SERVER') if hue_count > 1: raise ex.InvalidComponentCountException( - 'HUE_SERVER', _('0 or 1'), hue_count) + 'HUE_SERVER', _('0 or 1'), hue_count) shs_count = cls.get_inst_count(cluster, 'SPARK_YARN_HISTORY_SERVER') hms_count = cls.get_inst_count(cluster, 'HIVE_METASTORE') diff --git a/sahara/plugins/mapr/services/oozie/oozie.py b/sahara/plugins/mapr/services/oozie/oozie.py index aeee93de78..691a19653d 100644 --- a/sahara/plugins/mapr/services/oozie/oozie.py +++ b/sahara/plugins/mapr/services/oozie/oozie.py @@ -120,7 +120,8 @@ class Oozie(s.Service): @el.provision_event(instance_reference=1) @g.remote_command(1) def _rebuild_oozie_war(self, remote, cluster_context): - cmd = 'cp -f /opt/mapr-repository/ext-2.2.zip %(home)s/libext/ext-2.2.zip &&' \ + cmd = 'cp -f /opt/mapr-repository/ext-2.2.zip ' \ + '%(home)s/libext/ext-2.2.zip &&' \ ' %(home)s/bin/oozie-setup.sh -hadoop %(version)s' \ ' /opt/mapr/hadoop/hadoop-%(version)s' args = {'home': self.home_dir(cluster_context), diff --git a/sahara/service/heat/templates.py b/sahara/service/heat/templates.py index 44e60b0e7d..7bbaacbad0 100644 --- a/sahara/service/heat/templates.py +++ b/sahara/service/heat/templates.py @@ -448,7 +448,7 @@ class ClusterStack(object): EXTERNAL_DESIGNATE_REV_REC: { 'type': 'OS::Designate::Record', 'properties': { - 'name': _generate_reversed_ip( + 'name': _generate_reversed_ip( {'get_attr': ['floating_ip', 'ip']}), 'type': 'PTR', 'data': hostname, diff --git a/sahara/service/ops.py b/sahara/service/ops.py index 9280fd8485..4112c0bd0f 100644 --- a/sahara/service/ops.py +++ b/sahara/service/ops.py @@ -279,7 +279,7 @@ def _update_sahara_info(ctx, cluster): 'remote': remote.get_remote_type_and_version()} return conductor.cluster_update( - ctx, cluster, {'sahara_info': sahara_info}) + ctx, cluster, {'sahara_info': sahara_info}) @ops_error_handler( diff --git a/sahara/service/quotas.py b/sahara/service/quotas.py index 7c5e916d86..0f3c24b275 100644 --- a/sahara/service/quotas.py +++ b/sahara/service/quotas.py @@ -152,7 +152,7 @@ def _get_neutron_limits(): # tmckay-fp here we would just get the limits all the time usage_fip = b.execute_with_retries( - neutron.list_floatingips, tenant_id=tenant_id)['floatingips'] + neutron.list_floatingips, tenant_id=tenant_id)['floatingips'] limits['floatingips'] = _sub_limit(total_lim['floatingip'], len(usage_fip)) diff --git a/sahara/service/validations/cluster_templates.py b/sahara/service/validations/cluster_templates.py index d8957c3630..c4c1dee8b9 100644 --- a/sahara/service/validations/cluster_templates.py +++ b/sahara/service/validations/cluster_templates.py @@ -61,7 +61,7 @@ def check_cluster_template_usage(cluster_template_id, **kwargs): raise ex.InvalidReferenceException( _("Cluster template %(id)s in use by %(clusters)s") % {'id': cluster_template_id, - 'clusters': ', '.join(users)}) + 'clusters': ', '.join(users)}) def check_cluster_template_update(cluster_template_id, data, **kwargs): diff --git a/sahara/tests/unit/db/migration/test_migrations.py b/sahara/tests/unit/db/migration/test_migrations.py index 706a047bdf..139d7789fb 100644 --- a/sahara/tests/unit/db/migration/test_migrations.py +++ b/sahara/tests/unit/db/migration/test_migrations.py @@ -348,7 +348,7 @@ class SaharaMigrationsCheckers(object): desc = 'magic' t = db_utils.get_table(engine, 'clusters') engine.execute(t.insert(), id='123', name='name', plugin_name='pname', - hadoop_version='1', management_private_key='2', + hadoop_version='1', management_private_key='2', management_public_key='3', status_description=desc) def _check_007(self, engine, data): diff --git a/sahara/utils/hacking/checks.py b/sahara/utils/hacking/checks.py index e623e64c7f..1abcb1dfe2 100644 --- a/sahara/utils/hacking/checks.py +++ b/sahara/utils/hacking/checks.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pep8 +import pycodestyle import re import tokenize @@ -106,7 +106,7 @@ def use_jsonutils(logical_line, filename): S375 """ - if pep8.noqa(logical_line): + if pycodestyle.noqa(logical_line): return if (RE_USE_JSONUTILS_INVALID_LINE.match(logical_line) and not RE_USE_JSONUTILS_VALID_LINE.match(logical_line)): diff --git a/test-requirements.txt b/test-requirements.txt index 52c0626004..51cba973de 100644 --- a/test-requirements.txt +++ b/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!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 +hacking>=1.1.0 # Apache-2.0 PyMySQL>=0.7.6 # MIT License bandit>=1.1.0 # Apache-2.0 diff --git a/tox.ini b/tox.ini index 1633d0238a..5c16d20680 100644 --- a/tox.ini +++ b/tox.ini @@ -128,6 +128,12 @@ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,tools # [H204] Use assert(Not)Equal to check for equality # [H205] Use assert(Greater|Less)(Equal) for comparison enable-extensions=H904,H106,H203,H204,H205 +# [E123] Closing bracket does not match indentation of opening bracket's line +# [E226] Missing whitespace around arithmetic operator +# [E402] Module level import not at top of file +# [E731] Do not assign a lambda expression, use a def +# [W503] Line break occurred before a binary operator +ignore=E123,E226,E402,E731,W503 [hacking] import_exceptions = sahara.i18n