This is an automated email from the ASF dual-hosted git repository.

eladkal 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 0acd6b27af templated fields logic checks for 
cloud_storage_transfer_service (#37519)
0acd6b27af is described below

commit 0acd6b27af6469e3b35143247388cf0aab3dea5a
Author: Albert Okiri <[email protected]>
AuthorDate: Sat Mar 16 14:46:02 2024 +0300

    templated fields logic checks for cloud_storage_transfer_service (#37519)
    
    * templated fields init check and test update
    
    * update pre-commit file list
---
 .pre-commit-config.yaml                                   |  6 ------
 .../cloud/operators/cloud_storage_transfer_service.py     | 15 ++++++++++-----
 .../operators/test_cloud_storage_transfer_service.py      |  2 +-
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 6eebeacbed..988f7dddf6 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -330,12 +330,6 @@ repos:
         pass_filenames: true
         files: ^airflow/providers/.*/(operators|transfers|sensors)/.*\.py$
         additional_dependencies: [ 'rich>=12.4.4' ]
-        # TODO: Handle the provider-specific exclusions and remove them from 
the list, see:
-        #       https://github.com/apache/airflow/issues/36484
-        exclude: |
-          (?x)^(
-              
^airflow\/providers\/google\/cloud\/operators\/cloud_storage_transfer_service.py$
-          )$
       - id: ruff
         name: Run 'ruff' for extremely fast Python linting
         description: "Run 'ruff' for extremely fast Python linting"
diff --git 
a/airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py 
b/airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py
index 9f1ee264e1..077edc31d7 100644
--- a/airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py
+++ b/airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py
@@ -530,7 +530,7 @@ class 
CloudDataTransferServiceListOperationsOperator(GoogleCloudBaseOperator):
 
     # [START gcp_transfer_operations_list_template_fields]
     template_fields: Sequence[str] = (
-        "filter",
+        "request_filter",
         "gcp_conn_id",
         "google_impersonation_chain",
     )
@@ -547,22 +547,27 @@ class 
CloudDataTransferServiceListOperationsOperator(GoogleCloudBaseOperator):
         **kwargs,
     ) -> None:
         super().__init__(**kwargs)
-        self.filter = request_filter
+        self.request_filter = request_filter
         self.project_id = project_id
         self.gcp_conn_id = gcp_conn_id
         self.api_version = api_version
         self.google_impersonation_chain = google_impersonation_chain
 
+    @property
+    def filter(self) -> dict | None:
+        """Alias for ``request_filter``, used for compatibility."""
+        return self.request_filter
+
     def execute(self, context: Context) -> list[dict]:
-        if not self.filter:
-            raise AirflowException("The required parameter 'filter' is empty 
or None")
+        if not self.request_filter:
+            raise AirflowException("The required parameter 'request_filter' is 
empty or None")
 
         hook = CloudDataTransferServiceHook(
             api_version=self.api_version,
             gcp_conn_id=self.gcp_conn_id,
             impersonation_chain=self.google_impersonation_chain,
         )
-        operations_list = 
hook.list_transfer_operations(request_filter=self.filter)
+        operations_list = 
hook.list_transfer_operations(request_filter=self.request_filter)
         self.log.info(operations_list)
 
         project_id = self.project_id or hook.project_id
diff --git 
a/tests/providers/google/cloud/operators/test_cloud_storage_transfer_service.py 
b/tests/providers/google/cloud/operators/test_cloud_storage_transfer_service.py
index 1ef5d6b729..01f8f1675a 100644
--- 
a/tests/providers/google/cloud/operators/test_cloud_storage_transfer_service.py
+++ 
b/tests/providers/google/cloud/operators/test_cloud_storage_transfer_service.py
@@ -539,7 +539,7 @@ class TestGcpStorageTransferOperationListOperator:
         )
         ti.render_templates()
 
-        assert dag_id == ti.task.filter["job_names"][0]
+        assert dag_id == ti.task.request_filter["job_names"][0]
         assert dag_id == ti.task.gcp_conn_id
 
 

Reply via email to