parse_optional

parse_optional(value, parser)[source]

Applies parsing only if input is not None.

Parameters:
  • value (T or None) – The input value to parse if not None.

  • parser (callable, of type T -> R) – The parser to use if the input is not None.

Returns:

The result of applying the parser.

Return type:

R or None