4 from typing import Any, Optional
6 logger = logging.getLogger(__name__)
9 def unwrap_optional(x: Optional[Any]) -> Any:
10 """Unwrap an Optional[Type] argument returning a Type value back.
11 If the Optional[Type] argument is None, however, raise an exception.
12 Use this to satisfy most type checkers that a value that could
13 be None isn't so as to drop the Optional.
16 msg = 'Argument to unwrap_optional was unexpectedly None'
18 raise AssertionError(msg)