requests icon indicating copy to clipboard operation
requests copied to clipboard

refactor: use contextlib.suppress instead of empty except

Open kkirsche opened this issue 3 years ago • 0 comments

Use contextlib's suppress method to silence a specific error, instead of passing in an exception handler.

The context manager slightly shortens the code and significantly clarifies the author's intention to ignore the specific errors. The standard library feature was introduced following a discussion, where the consensus was that

A key benefit here is in the priming effect for readers... The with statement form makes it clear before you start reading the code that certain exceptions won't propagate.

kkirsche avatar Jun 29 '22 15:06 kkirsche