Running flake8-return with Python 3.7, I get an R504 error for the following code:
def close(self):
any_failed = False
for task in self.tasks:
try:
task()
except BaseException:
any_failed = True
report(traceback.format_exc())
return any_failed # R504 you shouldn't assign value to variable if it will be use only as return value
While any_failed is not used in any other expressions before being returned, it's still important to run all cleanup tasks instead of returning immediately after the first error. Perhaps R504 should be disabled when the assignment is in a loop and the return statement is not?
Running
flake8-return
with Python 3.7, I get anR504
error for the following code:While
any_failed
is not used in any other expressions before being returned, it's still important to run all cleanup tasks instead of returning immediately after the first error. PerhapsR504
should be disabled when the assignment is in a loop and the return statement is not?