This is an automated email from the ASF dual-hosted git repository.
husseinawala pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 0a5e2281e0 Remove some useless try/except from providers code (#33967)
0a5e2281e0 is described below
commit 0a5e2281e084b228e697ffdd5d825b927fce9483
Author: Hussein Awala <[email protected]>
AuthorDate: Thu Aug 31 21:10:47 2023 +0200
Remove some useless try/except from providers code (#33967)
---
.../providers/amazon/aws/hooks/redshift_cluster.py | 20 ++++++++------------
airflow/providers/dbt/cloud/hooks/dbt.py | 13 ++++---------
airflow/providers/google/cloud/hooks/cloud_sql.py | 15 ++++++---------
3 files changed, 18 insertions(+), 30 deletions(-)
diff --git a/airflow/providers/amazon/aws/hooks/redshift_cluster.py
b/airflow/providers/amazon/aws/hooks/redshift_cluster.py
index 7c44c9ec72..a5bf33e253 100644
--- a/airflow/providers/amazon/aws/hooks/redshift_cluster.py
+++ b/airflow/providers/amazon/aws/hooks/redshift_cluster.py
@@ -21,7 +21,6 @@ import warnings
from typing import Any, Sequence
import botocore.exceptions
-from botocore.exceptions import ClientError
from airflow.exceptions import AirflowProviderDeprecationWarning
from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseAsyncHook,
AwsBaseHook
@@ -70,17 +69,14 @@ class RedshiftHook(AwsBaseHook):
for the cluster that is being created.
:param params: Remaining AWS Create cluster API params.
"""
- try:
- response = self.get_conn().create_cluster(
- ClusterIdentifier=cluster_identifier,
- NodeType=node_type,
- MasterUsername=master_username,
- MasterUserPassword=master_user_password,
- **params,
- )
- return response
- except ClientError as e:
- raise e
+ response = self.get_conn().create_cluster(
+ ClusterIdentifier=cluster_identifier,
+ NodeType=node_type,
+ MasterUsername=master_username,
+ MasterUserPassword=master_user_password,
+ **params,
+ )
+ return response
# TODO: Wrap create_cluster_snapshot
def cluster_status(self, cluster_identifier: str) -> str:
diff --git a/airflow/providers/dbt/cloud/hooks/dbt.py
b/airflow/providers/dbt/cloud/hooks/dbt.py
index 72446efecc..a894890c31 100644
--- a/airflow/providers/dbt/cloud/hooks/dbt.py
+++ b/airflow/providers/dbt/cloud/hooks/dbt.py
@@ -254,15 +254,10 @@ class DbtCloudHook(HttpHook):
:param include_related: Optional. List of related fields to pull with
the run.
Valid values are "trigger", "job", "repository", and "environment".
"""
- try:
- self.log.info("Getting the status of job run %s.", run_id)
- response = await self.get_job_details(
- run_id, account_id=account_id, include_related=include_related
- )
- job_run_status: int = response["data"]["status"]
- return job_run_status
- except Exception as e:
- raise e
+ self.log.info("Getting the status of job run %s.", run_id)
+ response = await self.get_job_details(run_id, account_id=account_id,
include_related=include_related)
+ job_run_status: int = response["data"]["status"]
+ return job_run_status
@cached_property
def connection(self) -> Connection:
diff --git a/airflow/providers/google/cloud/hooks/cloud_sql.py
b/airflow/providers/google/cloud/hooks/cloud_sql.py
index f3fa10bb97..b84e05892c 100644
--- a/airflow/providers/google/cloud/hooks/cloud_sql.py
+++ b/airflow/providers/google/cloud/hooks/cloud_sql.py
@@ -437,15 +437,12 @@ class CloudSQLAsyncHook(GoogleBaseAsyncHook):
async def get_operation(self, project_id: str, operation_name: str):
async with ClientSession() as session:
- try:
- operation = await self.get_operation_name(
- project_id=project_id,
- operation_name=operation_name,
- session=session,
- )
- operation = await operation.json(content_type=None)
- except HttpError as e:
- raise e
+ operation = await self.get_operation_name(
+ project_id=project_id,
+ operation_name=operation_name,
+ session=session,
+ )
+ operation = await operation.json(content_type=None)
return operation