diff options
| author | Scott Gasch <[email protected]> | 2021-09-08 23:29:05 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2021-09-08 23:29:05 -0700 |
| commit | 709370b2198e09f1dbe195fe8813602a3125b7f6 (patch) | |
| tree | 5bbe521d7973f86526ed09d4411a5b3ff0e23aaa /type_utils.py | |
| parent | b10d30a46e601c9ee1f843241f2d69a1f90f7a94 (diff) | |
Add doctests to some of this stuff.
Diffstat (limited to 'type_utils.py')
| -rw-r--r-- | type_utils.py | 5 |
1 files changed, 5 insertions, 0 deletions
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) |
