get_optional_arg
Get the argument from an Optional[...] annotation, or None if it is no such annotation.
def get_optional_arg(
annotation: typing.Any
) - > typing.Any
Get the argument from an Optional[...] annotation, or None if it is no such annotation.
Parameters
| Name | Type | Description |
|---|---|---|
| annotation | typing.Any | The type hint annotation to inspect for an Optional or two-member Union containing None |
Returns
| Type | Description |
|---|---|
typing.Any | The inner type argument of the Optional annotation if valid, otherwise None |