# HG changeset patch # User Goffi # Date 1725637448 -7200 # Node ID 060d695ae98eed21161c2c0d582cbee92743a60a # Parent 0f953ce5f0a8667e8e3e86f719434fb17922aa2e plugin XEP-0106, tools (common/email): type hints. diff -r 0f953ce5f0a8 -r 060d695ae98e libervia/backend/plugins/plugin_xep_0106.py --- a/libervia/backend/plugins/plugin_xep_0106.py Fri Sep 06 17:42:07 2024 +0200 +++ b/libervia/backend/plugins/plugin_xep_0106.py Fri Sep 06 17:44:08 2024 +0200 @@ -61,7 +61,7 @@ def get_handler(self, client): return XEP_0106_handler() - def escape(self, text): + def escape(self, text) -> str: """Escape text @param text(unicode): text to escape @@ -78,7 +78,7 @@ escaped.append(c) return "".join(escaped) - def unescape(self, escaped): + def unescape(self, escaped) -> str: """Unescape text @param escaped(unicode): text to unescape diff -r 0f953ce5f0a8 -r 060d695ae98e libervia/backend/tools/common/email.py --- a/libervia/backend/tools/common/email.py Fri Sep 06 17:42:07 2024 +0200 +++ b/libervia/backend/tools/common/email.py Fri Sep 06 17:44:08 2024 +0200 @@ -20,7 +20,9 @@ """email sending facilities""" +from configparser import ConfigParser from email.mime.text import MIMEText +from twisted.internet import defer from twisted.mail import smtp from libervia.backend.core.constants import Const as C from libervia.backend.tools import config as tools_config @@ -29,16 +31,22 @@ log = getLogger(__name__) -def send_email(config, to_emails, subject="", body="", from_email=None): - """Send an email using SàT configuration +def send_email( + config: ConfigParser, + to_emails: list[str] | str, + subject: str = "", + body: str = "", + from_email: str | None = None, +) -> defer.Deferred: + """Send an email using Libervia configuration - @param config (ConfigParser): the configuration instance - @param to_emails(list[unicode], unicode): list of recipients + @param config: the configuration instance + @param to_emails: list of recipients if unicode, it will be split to get emails - @param subject(unicode): subject of the message - @param body(unicode): body of the message - @param from_email(unicode): address of the sender - @return (D): same as smtp.sendmail + @param subject: subject of the message + @param body: body of the message + @param from_email: address of the sender + @return:Same as smtp.sendmail. """ if isinstance(to_emails, str): to_emails = to_emails.split()