else
/elif
used after raise
PYL-R1720That’s all we can say right now.
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