From 65d66ecb580a54103448b4251d094dbb9149b06a Mon Sep 17 00:00:00 2001 From: Frode Nordahl Date: Fri, 28 Aug 2020 16:10:19 +0200 Subject: [PATCH] Unpin flake8, fix lint Change-Id: Id899936da7721fcc359e63db455a5349603fe559 --- actions/openstack_upgrade.py | 1 + actions/security_checklist.py | 1 + hooks/glance_utils.py | 3 ++- test-requirements.txt | 2 +- tox.ini | 2 +- unit_tests/test_actions_openstack_upgrade.py | 16 ++++++++-------- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/actions/openstack_upgrade.py b/actions/openstack_upgrade.py index 70504cc9..e9547021 100755 --- a/actions/openstack_upgrade.py +++ b/actions/openstack_upgrade.py @@ -57,5 +57,6 @@ def openstack_upgrade(): register_configs())): config_changed() + if __name__ == '__main__': openstack_upgrade() diff --git a/actions/security_checklist.py b/actions/security_checklist.py index 9c713447..28b95f9c 100755 --- a/actions/security_checklist.py +++ b/actions/security_checklist.py @@ -128,5 +128,6 @@ def main(): } return audits.action_parse_results(audits.run(config)) + if __name__ == "__main__": sys.exit(main()) diff --git a/hooks/glance_utils.py b/hooks/glance_utils.py index 8e3e8168..c3ef0bd8 100644 --- a/hooks/glance_utils.py +++ b/hooks/glance_utils.py @@ -150,6 +150,7 @@ REQUIRED_INTERFACES = { def ceph_config_file(): return CHARM_CEPH_CONF.format(service_name()) + CONFIG_FILES = OrderedDict([ (GLANCE_REGISTRY_CONF, { 'hook_contexts': [context.SharedDBContext(ssl_dir=GLANCE_CONF_DIR), @@ -475,7 +476,7 @@ def check_optional_relations(configs): if relation_ids('ha'): try: get_hacluster_config() - except: + except Exception: return ('blocked', 'hacluster missing configuration: ' 'vip, vip_iface, vip_cidr') diff --git a/test-requirements.txt b/test-requirements.txt index 7d9c2587..44b50231 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -10,7 +10,7 @@ charm-tools>=2.4.4 requests>=2.18.4 mock>=1.2 -flake8>=2.2.4,<=2.4.1 +flake8>=2.2.4 stestr>=2.2.0 coverage>=4.5.2 pyudev # for ceph-* charm unit tests (need to fix the ceph-* charm unit tests/mocking) diff --git a/tox.ini b/tox.ini index b835733a..8080ba6d 100644 --- a/tox.ini +++ b/tox.ini @@ -116,5 +116,5 @@ commands = functest-run-suite --keep-model --bundle {posargs} [flake8] -ignore = E402,E226 +ignore = E402,E226,W504 exclude = */charmhelpers diff --git a/unit_tests/test_actions_openstack_upgrade.py b/unit_tests/test_actions_openstack_upgrade.py index 4e6cb639..8d7f69d7 100644 --- a/unit_tests/test_actions_openstack_upgrade.py +++ b/unit_tests/test_actions_openstack_upgrade.py @@ -26,16 +26,16 @@ sys.modules['apt'] = mock_apt mock_apt.apt_pkg = MagicMock() with patch('charmhelpers.contrib.hardening.harden.harden') as mock_dec, \ - patch('charmhelpers.contrib.openstack.utils.' - 'os_requires_version') as mock_os, \ - patch('glance_utils.register_configs'), \ + patch('charmhelpers.contrib.openstack.utils.' + 'os_requires_version') as mock_os, \ + patch('glance_utils.register_configs'), \ patch('glance_utils.restart_map'): - mock_dec.side_effect = (lambda *dargs, **dkwargs: lambda f: - lambda *args, **kwargs: f(*args, **kwargs)) + mock_dec.side_effect = (lambda *dargs, **dkwargs: lambda f: + lambda *args, **kwargs: f(*args, **kwargs)) - mock_os.side_effect = (lambda *dargs, **dkwargs: lambda f: - lambda *args, **kwargs: f(*args, **kwargs)) - import openstack_upgrade + mock_os.side_effect = (lambda *dargs, **dkwargs: lambda f: + lambda *args, **kwargs: f(*args, **kwargs)) + import openstack_upgrade from test_utils import CharmTestCase