Optionally surface exceptions that happen under executors by reading
[python_utils.git] / type_utils.py
index 7b79af08f934f0b93153c5c14065a3a884de9a91..ee52444e7828c1d2b7920749a800dbf77e653983 100644 (file)
@@ -7,6 +7,11 @@ logger = logging.getLogger(__name__)
 
 
 def unwrap_optional(x: Optional[Any]) -> Any:
+    """Unwrap an Optional[Type] argument returning a Type value back.
+    If the Optional[Type] argument is None, however, raise an exception.
+    Use this to satisfy most type checkers that a value that could
+    be None isn't so as to drop the Optional.
+    """
     if x is None:
         msg = 'Argument to unwrap_optional was unexpectedly None'
         logger.critical(msg)