summaryrefslogtreecommitdiff
path: root/type_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'type_utils.py')
-rw-r--r--type_utils.py14
1 files changed, 14 insertions, 0 deletions
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