uranusjr commented on code in PR #28569:
URL: https://github.com/apache/airflow/pull/28569#discussion_r1060300383


##########
airflow/notifications/basenotifier.py:
##########
@@ -0,0 +1,95 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from __future__ import annotations
+
+from abc import abstractmethod
+from typing import TYPE_CHECKING, Sequence
+
+import jinja2
+
+from airflow.template.templater import Templater
+from airflow.utils.context import Context, context_merge
+
+if TYPE_CHECKING:
+    from airflow import DAG
+
+
+class BaseNotifier(Templater):
+    """BaseNotifier class for sending notifications"""
+
+    template_fields: Sequence[str] = ()
+    template_ext: Sequence[str] = ()
+
+    def __init__(self):
+        super().__init__()
+        self.resolve_template_files()
+
+    def _update_context(self, context: Context) -> Context:
+        """
+        Add additional context to the context
+
+        :param context: The airflow context
+        """
+        additional_context = {}
+        for field in self.template_fields:
+            additional_context[field] = getattr(self, field)
+        context_merge(context, additional_context)
+        return context
+
+    def _render(self, template, context, dag: DAG | None = None):
+        dag = context["dag"] if dag is None else dag

Review Comment:
   ```suggestion
           dag = dag or context["dag"]
   ```



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to