is_optional

Returns True if the annotation is Optional[SomeType].

Signature:

def is_optional(annotation: Type) -> bool:
...

Parameters:

  1. annotation:

    Type
    Type