if
statement can be simplified PYL-R1703 72 )
73
74 # Check if the request was successful
75 if response.status_code == 201: 76 # If the device was integrated successfully, return True
77 return True
78 else:
48 )
49
50 # Check if the request was successful
51 if response.status_code == 201: 52 # If the alert was sent successfully, return True
53 return True
54 else:
The highlighted if
block can be refactored into a simplified statement, increasing its readability.
def simplifiable_if(arg, arg2):
if arg and not arg2:
var = True
else:
var = False
return var
def simplifiable_if(arg, arg2):
var = bool(arg and not arg2)
return var