#8233 Fix PEP8 compliances

This commit is contained in:
Pieter Lambrecht 2022-03-14 12:48:18 +01:00
parent a37d0897c2
commit a8114e9c53
2 changed files with 20 additions and 20 deletions

View File

@ -37,7 +37,6 @@ class TokenAuthentication(authentication.TokenAuthentication):
if not token.validateclientip(clientip): if not token.validateclientip(clientip):
raise exceptions.AuthenticationFailed(f"Source IP {clientip} is not allowed to use this token.") raise exceptions.AuthenticationFailed(f"Source IP {clientip} is not allowed to use this token.")
# Enforce the Token's expiration time, if one has been set. # Enforce the Token's expiration time, if one has been set.
if token.is_expired: if token.is_expired:
raise exceptions.AuthenticationFailed("Token expired") raise exceptions.AuthenticationFailed("Token expired")

View File

@ -257,7 +257,7 @@ class Token(BigIDModel):
raise ValidationError() raise ValidationError()
else: else:
iptest = ipaddress.ip_address(ip) iptest = ipaddress.ip_address(ip)
except: except ValueError:
raise ValidationError(f"{ip} is an invalid value in the Allowed IP Ranges ({ip_addresses})") raise ValidationError(f"{ip} is an invalid value in the Allowed IP Ranges ({ip_addresses})")
return True return True
@ -271,7 +271,7 @@ class Token(BigIDModel):
try: try:
ip_address = ipaddress.ip_address(raw_ip_address) ip_address = ipaddress.ip_address(raw_ip_address)
except: except ValueError:
raise ValidationError(f"{raw_ip_address} is an invalid IP address") raise ValidationError(f"{raw_ip_address} is an invalid IP address")
for ip in self.allowed_ipranges.split(','): for ip in self.allowed_ipranges.split(','):
@ -291,6 +291,7 @@ class Token(BigIDModel):
return True return True
return False return False
# #
# Permissions # Permissions
# #