TJaniF commented on code in PR #29842:
URL: https://github.com/apache/airflow/pull/29842#discussion_r1152503500


##########
airflow/providers/github/sensors/github.py:
##########
@@ -46,21 +48,28 @@ def __init__(
         github_conn_id: str = "github_default",
         method_params: dict | None = None,
         result_processor: Callable | None = None,
+        allow_templates_in_result_processor: bool = True,
         **kwargs,
     ) -> None:
         super().__init__(**kwargs)
         self.github_conn_id = github_conn_id
-        self.result_processor = None
-        if result_processor is not None:
-            self.result_processor = result_processor
+        self.result_processor = result_processor
+        self.allow_templates_in_result_processor = 
allow_templates_in_result_processor
         self.method_name = method_name
         self.method_params = method_params
 
-    def poke(self, context: Context) -> bool:
+    def poke(self, context: Context, templated_fields: dict | None = None) -> 
bool:
         hook = GithubHook(github_conn_id=self.github_conn_id)
         github_result = getattr(hook.client, 
self.method_name)(**self.method_params)
 
         if self.result_processor:
+            argspec = inspect.getfullargspec(self.result_processor)
+            if self.allow_templates_in_result_processor and (
+                "templated_fields" in argspec.kwonlyargs or "templated_fields" 
in argspec.args
+            ):
+                return self.result_processor(github_result, 
templated_fields=templated_fields)
+            if self.allow_templates_in_result_processor:
+                self.log.info("To use templated fields in your 
`result_processor` function, provide them as a dict to a `templated_fields` 
parameter in your `result_processor` function.")

Review Comment:
   Thank you! 
   I did the changelog and provider.yaml entry now for a 2.2.2 version since at 
least as far as I can tell this change should now not break anything :) 
   Is there anything else I should be doing? (this is my first time committing 
to Airflow) 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to