Skip to content

Commit

Permalink
Rely on contextlib.suppress in util.suppress_exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Mar 22, 2024
1 parent 8692ca2 commit ca6fcd4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions keyring/util/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import contextlib


def suppress_exceptions(callables, exceptions=Exception):
"""
yield the results of calling each element of callables, suppressing
any indicated exceptions.
"""
for callable in callables:
try:
with contextlib.suppress(exceptions):
yield callable()
except exceptions:
pass

0 comments on commit ca6fcd4

Please sign in to comment.