From 497fb9e21f45ec08e1486abaee6dfa7b20b8a691 Mon Sep 17 00:00:00 2001 From: Scott Gasch Date: Wed, 24 Mar 2021 18:08:54 -0700 Subject: Initial revision --- type_utils.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 type_utils.py (limited to 'type_utils.py') diff --git a/type_utils.py b/type_utils.py new file mode 100644 index 0000000..7b79af0 --- /dev/null +++ b/type_utils.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 + +import logging +from typing import Any, Optional + +logger = logging.getLogger(__name__) + + +def unwrap_optional(x: Optional[Any]) -> Any: + if x is None: + msg = 'Argument to unwrap_optional was unexpectedly None' + logger.critical(msg) + raise AssertionError(msg) + return x -- cgit v1.3