SCR119: return-in-finally
return or break in a finally clause
| Code | SCR119 |
| Name | return-in-finally |
| Category | Scripts (SCR) |
| Default severity | warning |
| Enabled by default | yes |
| Fix available | no |
| ign-lint equivalent | none |
What it does
Section titled “What it does”Reports return in a finally clause, and break in a finally clause
that leaves a loop outside the try.
Why is this bad?
Section titled “Why is this bad?”When the try body raises, the finally clause runs and the return or
break discards the exception: the error vanishes without a trace, not
even in the gateway log.
Example
Section titled “Example”def readSetpoint(path): try: return system.tag.readBlocking([path])[0].value finally: return NoneUse instead:
def readSetpoint(path): try: return system.tag.readBlocking([path])[0].value except Exception: return Nonepylint
Section titled “pylint”Corresponds to W0150 lost-exception.
Generated from the rule metadata by iglint generate-docs; iglint rule SCR119 prints the same page in the terminal. Source: docs/rules/SCR119.md.