flake8-simplify
flake8-simplify copied to clipboard
[Adjust rule] SIM105
Desired change
- Rule: SIM105
-
Adjustment:
suppress
should not be used insidetry
/finally
statement
Explanation
The code is not simplified because the try
statement is still necessary then
Example
This is an example where the mentioned rule would currently be suboptimal:
try:
self._write_bytes(send_data)
except Exception:
pass
finally:
self._force_close()
using suppress would lead to
from contextlib import suppress
try:
with suppress(Exception):
self._write_bytes(send_data)
finally:
self._force_close()