mirror of
https://github.com/dmunozv04/iSponsorBlockTV.git
synced 2025-12-10 22:16:44 +03:00
refactor: refactor unnecessary else / elif when if block has a return statement
The use of `else` or `elif` becomes redundant and can be dropped if the last statement under the leading `if` / `elif` block is a `return` statement. In the case of an `elif` after `return`, it can be written as a separate `if` block. For `else` blocks after `return`, the statements can be shifted out of `else`. Please refer to the examples below for reference. Refactoring the code this way can improve code-readability and make it easier to maintain.
This commit is contained in:
committed by
GitHub
parent
784d54c4e2
commit
446393b078
@@ -41,13 +41,11 @@ class AsyncConditionalTTL:
|
||||
def __contains__(self, key):
|
||||
if key not in self.keys():
|
||||
return False
|
||||
else:
|
||||
key_expiration = super().__getitem__(key)[1]
|
||||
if key_expiration and key_expiration < datetime.datetime.now():
|
||||
del self[key]
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
key_expiration = super().__getitem__(key)[1]
|
||||
if key_expiration and key_expiration < datetime.datetime.now():
|
||||
del self[key]
|
||||
return False
|
||||
return True
|
||||
|
||||
def __getitem__(self, key):
|
||||
value = super().__getitem__(key)[0]
|
||||
|
||||
Reference in New Issue
Block a user