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:
with open(os.path.join(backup_root, 'custom.yaml')) as 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)
except:
pass

View File

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

View File

@ -38,7 +38,7 @@ def load_settings(env):
try:
with open(fn) as 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
except:
return { }

View File

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