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