diff options
| author | Scott Gasch <[email protected]> | 2022-05-31 15:36:40 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2022-05-31 15:36:40 -0700 |
| commit | 02302bbd9363facb59c4df2c1f4013087702cfa6 (patch) | |
| tree | 938e51338678416afc891d2839c2ee8dd341f34d /type_utils.py | |
| parent | f3dbc7dc19ba5703f8f5aa9bf8af3c491b3510f6 (diff) | |
Improve docstrings for sphinx.
Diffstat (limited to 'type_utils.py')
| -rw-r--r-- | type_utils.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/type_utils.py b/type_utils.py index 5e4187e..e760dba 100644 --- a/type_utils.py +++ b/type_utils.py @@ -12,9 +12,16 @@ 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 typing hint. + Use this to satisfy most type checkers that a value that could be + None isn't so as to drop the Optional typing hint. + + Args: + x: an Optional[Type] argument + + Returns: + If the Optional[Type] argument is non-None, return it. + If the Optional[Type] argument is None, however, raise an + exception. >>> x: Optional[bool] = True >>> unwrap_optional(x) @@ -25,7 +32,6 @@ def unwrap_optional(x: Optional[Any]) -> Any: Traceback (most recent call last): ... AssertionError: Argument to unwrap_optional was unexpectedly None - """ if x is None: msg = 'Argument to unwrap_optional was unexpectedly None' |
