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


##########
airflow/utils/email.py:
##########
@@ -267,8 +306,13 @@ def _get_smtp_connection(host: str, port: int, timeout: 
int, with_ssl: bool) ->
 
 
 def _get_email_list_from_str(addresses: str) -> list[str]:
-    delimiters = [",", ";"]
-    for delimiter in delimiters:
-        if delimiter in addresses:
-            return [address.strip() for address in addresses.split(delimiter)]
-    return [addresses]
+    """
+    Extract a list of email addresses from a string. The string
+    can contain multiple email addresses separated by
+    any of the following delimiters: ',' or ';'.
+
+    :param addresses: A string containing one or more email addresses.
+    :return: A list of email addresses.
+    """
+    pattern = r"[,;]\s*"
+    return [address.strip() for address in re.split(pattern, addresses)]

Review Comment:
   Since we do `strip` afterwards, the `\s*` part in the pattern does not seem 
to be needed? (Wildcards incur a minor performance penalty.)
   
   An alternative is to do `\s*` at both sides and remove the extra `strip`.



-- 
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