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