1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-11-23 02:27:05 +00:00

Fixed RSE102 (unnecessary-paren-on-raise-exception): Unnecessary parentheses on raised exception

This commit is contained in:
Teal Dulcet 2023-12-22 07:16:15 -08:00 committed by Joshua Tauberer
parent 13b38cc04d
commit 51dc7615f7
4 changed files with 11 additions and 11 deletions

View File

@ -581,7 +581,7 @@ def get_backup_config(env, for_save=False, for_ui=False):
try: try:
with open(os.path.join(backup_root, 'custom.yaml')) as f: with open(os.path.join(backup_root, 'custom.yaml')) as f:
custom_config = rtyaml.load(f) custom_config = rtyaml.load(f)
if not isinstance(custom_config, dict): raise ValueError() # caught below if not isinstance(custom_config, dict): raise ValueError # caught below
config.update(custom_config) config.update(custom_config)
except: except:
pass pass

View File

@ -817,7 +817,7 @@ def get_custom_dns_config(env, only_real_records=False):
try: try:
with open(os.path.join(env['STORAGE_ROOT'], 'dns/custom.yaml')) as f: with open(os.path.join(env['STORAGE_ROOT'], 'dns/custom.yaml')) as f:
custom_dns = rtyaml.load(f) custom_dns = rtyaml.load(f)
if not isinstance(custom_dns, dict): raise ValueError() # caught below if not isinstance(custom_dns, dict): raise ValueError # caught below
except: except:
return [ ] return [ ]
@ -835,7 +835,7 @@ def get_custom_dns_config(env, only_real_records=False):
# No other type of data is allowed. # No other type of data is allowed.
else: else:
raise ValueError() raise ValueError
for rtype, value2 in values: for rtype, value2 in values:
if isinstance(value2, str): if isinstance(value2, str):
@ -845,7 +845,7 @@ def get_custom_dns_config(env, only_real_records=False):
yield (qname, rtype, value3) yield (qname, rtype, value3)
# No other type of data is allowed. # No other type of data is allowed.
else: else:
raise ValueError() raise ValueError
def filter_custom_records(domain, custom_dns_iter): def filter_custom_records(domain, custom_dns_iter):
for qname, rtype, value in custom_dns_iter: for qname, rtype, value in custom_dns_iter:

View File

@ -38,7 +38,7 @@ def load_settings(env):
try: try:
with open(fn) as f: with open(fn) as f:
config = rtyaml.load(f) config = rtyaml.load(f)
if not isinstance(config, dict): raise ValueError() # caught below if not isinstance(config, dict): raise ValueError # caught below
return config return config
except: except:
return { } return { }

View File

@ -33,7 +33,7 @@ def smtp_test():
server = smtplib.SMTP(hostname, 587) server = smtplib.SMTP(hostname, 587)
except ConnectionRefusedError: except ConnectionRefusedError:
# looks like fail2ban worked # looks like fail2ban worked
raise IsBlocked() raise IsBlocked
server.starttls() server.starttls()
server.ehlo_or_helo_if_needed() server.ehlo_or_helo_if_needed()
@ -58,7 +58,7 @@ def imap_test():
M = imaplib.IMAP4_SSL(hostname) M = imaplib.IMAP4_SSL(hostname)
except ConnectionRefusedError: except ConnectionRefusedError:
# looks like fail2ban worked # looks like fail2ban worked
raise IsBlocked() raise IsBlocked
try: try:
M.login("fakeuser", "fakepassword") M.login("fakeuser", "fakepassword")
@ -77,7 +77,7 @@ def pop_test():
M = poplib.POP3_SSL(hostname) M = poplib.POP3_SSL(hostname)
except ConnectionRefusedError: except ConnectionRefusedError:
# looks like fail2ban worked # looks like fail2ban worked
raise IsBlocked() raise IsBlocked
try: try:
M.user('fakeuser') M.user('fakeuser')
try: try:
@ -102,7 +102,7 @@ def managesieve_test():
M = imaplib.IMAP4(hostname, 4190) M = imaplib.IMAP4(hostname, 4190)
except ConnectionRefusedError: except ConnectionRefusedError:
# looks like fail2ban worked # looks like fail2ban worked
raise IsBlocked() raise IsBlocked
try: try:
M.login("fakeuser", "fakepassword") M.login("fakeuser", "fakepassword")
@ -134,10 +134,10 @@ def http_test(url, expected_status, postdata=None, qsargs=None, auth=None):
timeout=8, timeout=8,
verify=False) # don't bother with HTTPS validation, it may not be configured yet verify=False) # don't bother with HTTPS validation, it may not be configured yet
except requests.exceptions.ConnectTimeout: except requests.exceptions.ConnectTimeout:
raise IsBlocked() raise IsBlocked
except requests.exceptions.ConnectionError as e: except requests.exceptions.ConnectionError as e:
if "Connection refused" in str(e): if "Connection refused" in str(e):
raise IsBlocked() raise IsBlocked
raise # some other unexpected condition raise # some other unexpected condition
# return response status code # return response status code