Open xqt opened 2 years ago
suppress
try
finally
The code is not simplified because the try statement is still necessary then
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()
Desired change
suppress
should not be used insidetry
/finally
statementExplanation
The code is not simplified because the
try
statement is still necessary thenExample
This is an example where the mentioned rule would currently be suboptimal:
using suppress would lead to