return-in-finally / W0134#
'return' shadowed by the 'finally' clause.
Emitted when a 'return' statement is found in a 'finally' block. This will overwrite the return value of a function and should be avoided.
def second_favorite(): fruits = ["kiwi", "pineapple"] try: return fruits finally: # because of this `return` statement, this function will always return "kiwi" return fruits # [return-in-finally]
def second_favorite(): fruits = ["kiwi", "pineapple"] try: return fruits except KeyError: ... return fruits
Created by the basic checker.