From 8d1521e96c6b3163f7f6598ef15a11af0052cf04 Mon Sep 17 00:00:00 2001 From: Tin Lam Date: Tue, 8 May 2018 23:03:16 -0500 Subject: [PATCH] style(pep8): remove E722 exclusion This patch set removes E722 pep8 exclusion that allows for "bare" except: statement. Change-Id: Icdce885366541b88aabbef35166cf196a588676b Signed-off-by: Tin Lam --- armada/api/middleware.py | 2 +- armada/cli/__init__.py | 2 +- armada/handlers/k8s.py | 2 +- armada/tests/unit/utils/test_source.py | 2 +- armada/utils/validate.py | 2 +- tox.ini | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/armada/api/middleware.py b/armada/api/middleware.py index 6c8738bb..c3b5596f 100644 --- a/armada/api/middleware.py +++ b/armada/api/middleware.py @@ -86,7 +86,7 @@ class ContextMiddleware(object): def is_valid_uuid(self, id, version=4): try: uuid_obj = UUID(id, version=version) - except: + except (TypeError, ValueError): return False return str(uuid_obj) == id diff --git a/armada/cli/__init__.py b/armada/cli/__init__.py index 0256c8d3..8f924f72 100644 --- a/armada/cli/__init__.py +++ b/armada/cli/__init__.py @@ -41,7 +41,7 @@ class CliAction(object): except ArmadaBaseException: self.logger.exception('Caught internal exception') sys.exit(1) - except: + except Exception: self.logger.exception('Caught unexpected exception') sys.exit(1) diff --git a/armada/handlers/k8s.py b/armada/handlers/k8s.py index 6a1045e0..5d48fcb5 100644 --- a/armada/handlers/k8s.py +++ b/armada/handlers/k8s.py @@ -41,7 +41,7 @@ class K8s(object): ''' try: config.load_incluster_config() - except: + except config.config_exception.ConfigException: config.load_kube_config() self.client = client.CoreV1Api() diff --git a/armada/tests/unit/utils/test_source.py b/armada/tests/unit/utils/test_source.py index c07de599..caa6968b 100644 --- a/armada/tests/unit/utils/test_source.py +++ b/armada/tests/unit/utils/test_source.py @@ -35,7 +35,7 @@ def is_connected(): host = socket.gethostbyname("www.github.com") socket.create_connection((host, 80), 2) return True - except: + except (socket.error, socket.herror, socket.timeout): pass return False diff --git a/armada/utils/validate.py b/armada/utils/validate.py index 5fad56c7..9e38c95b 100644 --- a/armada/utils/validate.py +++ b/armada/utils/validate.py @@ -229,7 +229,7 @@ def validate_armada_documents(documents): def validate_manifest_url(value): try: return (requests.get(value).status_code == 200) - except: + except requests.exceptions.RequestException: return False diff --git a/tox.ini b/tox.ini index d61790e3..c464841f 100644 --- a/tox.ini +++ b/tox.ini @@ -55,5 +55,5 @@ commands = [flake8] filename = *.py -ignore = E722 +ignore = exclude = .git,.tox,dist,*lib/python*,*egg,build,releasenotes,docs/*,hapi,venv