From 709370b2198e09f1dbe195fe8813602a3125b7f6 Mon Sep 17 00:00:00 2001 From: Scott Gasch Date: Wed, 8 Sep 2021 23:29:05 -0700 Subject: Add doctests to some of this stuff. --- type_utils.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'type_utils.py') diff --git a/type_utils.py b/type_utils.py index 7b79af0..ee52444 100644 --- a/type_utils.py +++ b/type_utils.py @@ -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) -- cgit v1.3