Skip to content

Commit e127797

Browse files
leopdjesterhazy
authored andcommitted
Very minor: Better documentation comment on DeferredError. (#469)
* Better documentation comment on DeferredError. * Using Napolean-style docstring formatting for example code. * Fixup flake8 trailing whitespace.
1 parent 4f08a3d commit e127797

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/sagemaker/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,18 @@ def download_file(bucket_name, path, target, sagemaker_session):
284284

285285

286286
class DeferredError(object):
287-
"""Stores an exception and raises it at a later time anytime this
287+
"""Stores an exception and raises it at a later time if this
288288
object is accessed in any way. Useful to allow soft-dependencies on imports,
289289
so that the ImportError can be raised again later if code actually
290290
relies on the missing library.
291+
292+
Example::
293+
294+
try:
295+
import obscurelib
296+
except ImportError as e:
297+
logging.warning("Failed to import obscurelib. Obscure features will not work.")
298+
obscurelib = DeferredError(e)
291299
"""
292300

293301
def __init__(self, exception):

0 commit comments

Comments
 (0)