else
/elif
used after raise
PYL-R1720 9
10def handle_unmatched_provider(provider: str) -> NoReturn:
11 """Handles an unmatched provider raise corrent error messages"""
12 if provider in CloudProvider.all():13 raise NotImplementedError(f"{provider} is not yet supported")
14 else:
15 raise Exception("No such provider")
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.
def check_magic_generator(attribute):
magic = get_magic_number(attribute)
if magic < 0:
raise ValueError(f"{attribute} looks invalid")
elif magic > 100
raise ValueError(f"{attribute} is very magical")
else:
return magic
def check_magic_generator(attribute):
magic = get_magic_number(attribute)
if magic < 0:
raise ValueError(f"{attribute} looks invalid")
if magic > 100
raise ValueError(f"{attribute} is very magical")
return magic