refactor: refactor unnecessary `else` / `elif` when `if` block has a `raise` statement

`raise` causes control flow to be disrupted, as it will exit the block.
It is recommended to check other conditions using another `if` statement, and get rid of `else` statements as they are unnecessary.
This commit is contained in:
deepsource-autofix[bot] 2023-08-06 23:03:35 +00:00 committed by GitHub
parent 36f2b87823
commit ed8a4755c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 18 deletions

View File

@ -19,7 +19,6 @@ class Config:
def token(self, token):
if token is None:
raise ValueError("No token provided")
else:
url = "https://api.cloudflare.com/client/v4/user/tokens/verify"
headers = {
"Authorization": f"Bearer {token}",
@ -28,7 +27,6 @@ class Config:
response = requests.get(url, headers=headers, timeout=10)
if response.json()["success"] is False:
raise ValueError("Invalid token")
else:
# Token needs the following scopes:
# Zero Trust: Read/Edit
# Account Firewall Access Rules: Read/Edit
@ -43,7 +41,6 @@ class Config:
def account_id(self, account_id):
if account_id is None:
raise ValueError("No account ID provided")
else:
# Possibly make a request to lists to check if the account ID exists
self._account_id = account_id