From 89786dd47d3d6f0916fdb8da892010a6170860e8 Mon Sep 17 00:00:00 2001 From: Bernardo Couto Date: Sat, 28 May 2022 22:34:54 -0300 Subject: [PATCH 1/2] Removing magic numbers from exceptions --- airflow/exceptions.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/airflow/exceptions.py b/airflow/exceptions.py index 95fa9e3276545..5a4c77769ed89 100644 --- a/airflow/exceptions.py +++ b/airflow/exceptions.py @@ -22,6 +22,7 @@ import datetime import warnings from typing import Any, Dict, List, NamedTuple, Optional, Sized +from http import HTTPStatus class AirflowException(Exception): @@ -31,19 +32,19 @@ class AirflowException(Exception): Each custom exception should be derived from this class. """ - status_code = 500 + status_code = HTTPStatus.INTERNAL_SERVER_ERROR class AirflowBadRequest(AirflowException): """Raise when the application or server cannot handle the request.""" - status_code = 400 + status_code = HTTPStatus.BAD_REQUEST class AirflowNotFoundException(AirflowException): """Raise when the requested object/resource is not available in the system.""" - status_code = 404 + status_code = HTTPStatus.NOT_FOUND class AirflowConfigException(AirflowException): From d0bc5a5910095df710df0fed775f2f85a63dccaf Mon Sep 17 00:00:00 2001 From: Bernardo Couto Date: Sat, 28 May 2022 23:26:42 -0300 Subject: [PATCH 2/2] Running pre-commit --- airflow/exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow/exceptions.py b/airflow/exceptions.py index 5a4c77769ed89..2f1e53e182a10 100644 --- a/airflow/exceptions.py +++ b/airflow/exceptions.py @@ -21,8 +21,8 @@ """Exceptions used by Airflow""" import datetime import warnings -from typing import Any, Dict, List, NamedTuple, Optional, Sized from http import HTTPStatus +from typing import Any, Dict, List, NamedTuple, Optional, Sized class AirflowException(Exception):