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

potiuk 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 cba3e3856ad Remove Provider Deprecations in SendGrid (#44637)
cba3e3856ad is described below

commit cba3e3856ad70d2c72110d7afe6ac4a3a5ba7d59
Author: LIU ZHE YOU <[email protected]>
AuthorDate: Fri Dec 6 15:56:11 2024 +0800

    Remove Provider Deprecations in SendGrid (#44637)
---
 providers/src/airflow/providers/sendgrid/CHANGELOG.rst | 12 ++++++++++++
 .../src/airflow/providers/sendgrid/utils/emailer.py    | 18 ++----------------
 2 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/providers/src/airflow/providers/sendgrid/CHANGELOG.rst 
b/providers/src/airflow/providers/sendgrid/CHANGELOG.rst
index 5928b42144a..92d038674c9 100644
--- a/providers/src/airflow/providers/sendgrid/CHANGELOG.rst
+++ b/providers/src/airflow/providers/sendgrid/CHANGELOG.rst
@@ -27,6 +27,18 @@
 Changelog
 ---------
 
+main
+.....
+
+.. warning::
+   All deprecated classes, parameters and features have been removed from the 
SendGrid provider package.
+   The following breaking changes were introduced:
+
+   * Utils
+
+      * Removed Fetching SendGrid credentials from environment variables. Use 
``Connection`` to set credentials instead.
+
+
 3.6.0
 .....
 
diff --git a/providers/src/airflow/providers/sendgrid/utils/emailer.py 
b/providers/src/airflow/providers/sendgrid/utils/emailer.py
index c096246d250..f22a080deba 100644
--- a/providers/src/airflow/providers/sendgrid/utils/emailer.py
+++ b/providers/src/airflow/providers/sendgrid/utils/emailer.py
@@ -23,7 +23,6 @@ import base64
 import logging
 import mimetypes
 import os
-import warnings
 from collections.abc import Iterable
 from typing import Union
 
@@ -40,7 +39,6 @@ from sendgrid.helpers.mail import (
     SandBoxMode,
 )
 
-from airflow.exceptions import AirflowException, 
AirflowProviderDeprecationWarning
 from airflow.hooks.base import BaseHook
 from airflow.utils.email import get_email_address_list
 
@@ -126,20 +124,8 @@ def send_email(
 
 
 def _post_sendgrid_mail(mail_data: dict, conn_id: str = "sendgrid_default") -> 
None:
-    api_key = None
-    try:
-        conn = BaseHook.get_connection(conn_id)
-        api_key = conn.password
-    except AirflowException:
-        pass
-    if api_key is None:
-        warnings.warn(
-            "Fetching Sendgrid credentials from environment variables will be 
deprecated in a future "
-            "release. Please set credentials using a connection instead.",
-            AirflowProviderDeprecationWarning,
-            stacklevel=2,
-        )
-        api_key = os.environ.get("SENDGRID_API_KEY")
+    conn = BaseHook.get_connection(conn_id)
+    api_key = conn.password
     sendgrid_client = sendgrid.SendGridAPIClient(api_key=api_key)
     response = sendgrid_client.client.mail.send.post(request_body=mail_data)
     # 2xx status code.

Reply via email to