diff --git a/airflow/providers/google/cloud/transfers/gcs_to_gcs.py b/airflow/providers/google/cloud/transfers/gcs_to_gcs.py index f6114889b7ce3..499b331da19c5 100644 --- a/airflow/providers/google/cloud/transfers/gcs_to_gcs.py +++ b/airflow/providers/google/cloud/transfers/gcs_to_gcs.py @@ -90,9 +90,8 @@ class GCSToGCSOperator(BaseOperator): If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account (templated). - :param source_object_required: When source_object_required is True, if you want to copy / move a specific blob - and it doesn't exist, an exception is raised and the task is marked as failed. - This parameter doesn't have any effect when the source_object that you pass is a folder or pattern. + :param source_object_required: Whether you want to raise an exception when the source object + doesn't exist. It doesn't have any effect when the source objects are folders or patterns. :Example: @@ -319,9 +318,7 @@ def _copy_source_without_wildcard(self, hook, prefix): hook=hook, source_object=prefix, destination_object=self.destination_object ) elif self.source_object_required: - msg = ( - f'{prefix} does not exist in bucket {self.source_bucket}' - ) + msg = f"{prefix} does not exist in bucket {self.source_bucket}" self.log.warning(msg) raise AirflowException(msg) diff --git a/tests/providers/google/cloud/transfers/test_gcs_to_gcs.py b/tests/providers/google/cloud/transfers/test_gcs_to_gcs.py index 27ce7bacfe63e..dec0d378279a4 100644 --- a/tests/providers/google/cloud/transfers/test_gcs_to_gcs.py +++ b/tests/providers/google/cloud/transfers/test_gcs_to_gcs.py @@ -556,11 +556,10 @@ def test_execute_source_object_required_flag_true(self, mock_hook): source_objects=SOURCE_OBJECTS_SINGLE_FILE, destination_bucket=DESTINATION_BUCKET, destination_object=DESTINATION_OBJECT_PREFIX, - source_object_required=True + source_object_required=True, ) with pytest.raises( - AirflowException, - match=f"{SOURCE_OBJECTS_SINGLE_FILE} does not exist in bucket {TEST_BUCKET}" + AirflowException, match=f"{SOURCE_OBJECTS_SINGLE_FILE} does not exist in bucket {TEST_BUCKET}" ): operator.execute(None)