From a7b25f0cc42349fd0428c02b35469b872a87500f Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Mon, 16 Dec 2019 03:52:13 +0900 Subject: [PATCH] Fix pep8 failures with hacking 2.0.0 It seems hacking 2.0.0 was shipped with incompatible changes (which is not surprising as this is a new major version). Let's fix these errors and use a newer hacking. Change-Id: I8da9dca5d8d74f6dfc2340dabc8d50e6253358e2 --- horizon/defaults.py | 2 +- horizon/test/settings.py | 4 ++-- horizon/test/unit/templatetags/test_templatetags.py | 6 ++++-- openstack_dashboard/defaults.py | 2 +- openstack_dashboard/settings.py | 2 +- openstack_dashboard/test/test_data/cinder_data.py | 1 - test-requirements.txt | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/horizon/defaults.py b/horizon/defaults.py index 5574f18fe6..eefc438791 100644 --- a/horizon/defaults.py +++ b/horizon/defaults.py @@ -13,7 +13,7 @@ from django.urls import reverse_lazy from django.utils.translation import ugettext_lazy as _ -from openstack_auth.defaults import * # noqa: F403,H303 +from openstack_auth.defaults import * # noqa: F401,F403,H303 from horizon.contrib import bootstrap_datepicker diff --git a/horizon/test/settings.py b/horizon/test/settings.py index e97037ba53..17031debba 100644 --- a/horizon/test/settings.py +++ b/horizon/test/settings.py @@ -19,8 +19,8 @@ import os import socket -from horizon.defaults import * # noqa: F403,H303 -from openstack_auth.defaults import * # noqa: F403,H303 +from horizon.defaults import * # noqa: F401,F403,H303 +from openstack_auth.defaults import * # noqa: F401,F403,H303 from openstack_dashboard.utils import settings as settings_utils socket.setdefaulttimeout(1) diff --git a/horizon/test/unit/templatetags/test_templatetags.py b/horizon/test/unit/templatetags/test_templatetags.py index 8abfa2e284..9266640400 100644 --- a/horizon/test/unit/templatetags/test_templatetags.py +++ b/horizon/test/unit/templatetags/test_templatetags.py @@ -25,10 +25,12 @@ from django.utils.text import normalize_newlines from horizon.test import helpers as test # The following imports are required to register the dashboards. +# NOTE(amotoki): When an import line is wrapped, noqa F401 seems not to work, +# so we don't wrap lines and ignore E501 (too long line) too. from horizon.test.test_dashboards.cats.dashboard import Cats # noqa: F401 -from horizon.test.test_dashboards.cats.kittens.panel import Kittens # noqa: F401 +from horizon.test.test_dashboards.cats.kittens.panel import Kittens # noqa: F401,E501 from horizon.test.test_dashboards.dogs.dashboard import Dogs # noqa: F401 -from horizon.test.test_dashboards.dogs.puppies.panel import Puppies # noqa: F401 +from horizon.test.test_dashboards.dogs.puppies.panel import Puppies # noqa: F401,E501 def single_line(text): diff --git a/openstack_dashboard/defaults.py b/openstack_dashboard/defaults.py index 87ecc84398..51ef91ce1e 100644 --- a/openstack_dashboard/defaults.py +++ b/openstack_dashboard/defaults.py @@ -18,7 +18,7 @@ from django.utils.translation import pgettext_lazy from django.utils.translation import ugettext_lazy as _ # openstack_auth.default is imported in horizon.defaults. -from horizon.defaults import * # noqa: F403,H303 +from horizon.defaults import * # noqa: F401,F403,H303 def _get_root_path(): diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py index 02cd17ef3b..29c5cc7795 100644 --- a/openstack_dashboard/settings.py +++ b/openstack_dashboard/settings.py @@ -274,7 +274,7 @@ if os.path.exists(LOCAL_SETTINGS_DIR_PATH): with open(os.path.join(dirpath, filename)) as f: # pylint: disable=exec-used exec(f.read()) - except Exception as e: + except Exception: _LOG.exception( "Can not exec settings snippet %s", filename) diff --git a/openstack_dashboard/test/test_data/cinder_data.py b/openstack_dashboard/test/test_data/cinder_data.py index e71e1f755e..2dc59a39a5 100644 --- a/openstack_dashboard/test/test_data/cinder_data.py +++ b/openstack_dashboard/test/test_data/cinder_data.py @@ -145,7 +145,6 @@ def data(TEST): 'created_at': '2013-04-01 10:30:00', 'volume_type': None, 'bootable': 'false', - 'bootable': False, 'attachments': [{"id": "21023e92-8008-1234-8059-7f2293ff3890", "server_id": '1', "device": "/dev/hda"}]}) diff --git a/test-requirements.txt b/test-requirements.txt index 6c3d0f482b..3bc838f09c 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -7,7 +7,7 @@ # be installed in a specific order. # # Hacking should appear first in case something else depends on pep8 -hacking>=1.1.0,<2 # Apache-2.0 +hacking>=2.0.0 # Apache-2.0 # astroid==2.1.0;python_version>='3.0' # LGPLv2.1 bandit!=1.6.0,>=1.4.0 # Apache-2.0