@@ -89,7 +89,7 @@ def __init__(
89
89
self .object = object
90
90
self .use_glob = use_glob
91
91
self .google_cloud_conn_id = google_cloud_conn_id
92
- self ._matches : list [ str ] = []
92
+ self ._matches : bool = False
93
93
self .impersonation_chain = impersonation_chain
94
94
self .retry = retry
95
95
@@ -101,17 +101,16 @@ def poke(self, context: Context) -> bool:
101
101
gcp_conn_id = self .google_cloud_conn_id ,
102
102
impersonation_chain = self .impersonation_chain ,
103
103
)
104
- if self .use_glob :
105
- self ._matches = hook .list (self .bucket , match_glob = self .object )
106
- return bool (self ._matches )
107
- else :
108
- return hook .exists (self .bucket , self .object , self .retry )
104
+ self ._matches = (
105
+ bool (hook .list (self .bucket , match_glob = self .object ))
106
+ if self .use_glob
107
+ else hook .exists (self .bucket , self .object , self .retry )
108
+ )
109
+ return self ._matches
109
110
110
- def execute (self , context : Context ) -> None :
111
+ def execute (self , context : Context ):
111
112
"""Airflow runs this method on the worker and defers using the trigger."""
112
- if not self .deferrable :
113
- super ().execute (context )
114
- else :
113
+ if self .deferrable :
115
114
if not self .poke (context = context ):
116
115
self .defer (
117
116
timeout = timedelta (seconds = self .timeout ),
@@ -127,8 +126,11 @@ def execute(self, context: Context) -> None:
127
126
),
128
127
method_name = "execute_complete" ,
129
128
)
129
+ else :
130
+ super ().execute (context )
131
+ return self ._matches
130
132
131
- def execute_complete (self , context : Context , event : dict [str , str ]) -> str :
133
+ def execute_complete (self , context : Context , event : dict [str , str ]) -> bool :
132
134
"""
133
135
Act as a callback for when the trigger fires - returns immediately.
134
136
@@ -140,7 +142,7 @@ def execute_complete(self, context: Context, event: dict[str, str]) -> str:
140
142
raise AirflowSkipException (event ["message" ])
141
143
raise AirflowException (event ["message" ])
142
144
self .log .info ("File %s was found in bucket %s." , self .object , self .bucket )
143
- return event [ "message" ]
145
+ return True
144
146
145
147
146
148
@deprecated (
0 commit comments