From 5fdc7c4aec21e498325dad958b9b36e6508dfd5a Mon Sep 17 00:00:00 2001 From: Lazlo Westerhof Date: Tue, 6 Aug 2024 11:17:03 +0200 Subject: [PATCH] Use property access since attributes are defined as constants --- mail.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mail.py b/mail.py index 13dab3ccb..fc1a99c00 100644 --- a/mail.py +++ b/mail.py @@ -45,9 +45,9 @@ def send(ctx, to, actor, subject, body, cc=None): ('reply_to', 'notifications_reply_to'), ('server', 'smtp_server')]} - if getattr(config, "smtp_auth"): - cfg['username'] = getattr(config, "smtp_username") - cfg['password'] = getattr(config, "smtp_password") + if config.smtp_auth: + cfg['username'] = config.smtp_username + cfg['password'] = config.smtp_password try: # e.g. 'smtps://smtp.gmail.com:465' for SMTP over TLS, or @@ -65,7 +65,7 @@ def send(ctx, to, actor, subject, body, cc=None): try: smtp = (smtplib.SMTP_SSL if proto == 'smtps' else smtplib.SMTP)(host, port) - if proto != 'smtps' and getattr(config, "smtp_starttls"): + if proto != 'smtps' and config.smtp_starttls: # Enforce TLS. smtp.starttls() @@ -74,7 +74,7 @@ def send(ctx, to, actor, subject, body, cc=None): return api.Error('internal', 'Mail configuration error') try: - if getattr(config, "smtp_auth"): + if config.smtp_auth: smtp.login(cfg['username'], cfg['password']) except Exception: