docs: def strip_optional_suffix(string, suffix, log=None):
      """
      >>> strip_optional_suffix('abcdef', 'def')
      'abc'
      >>> strip_optional_suffix('abcdef', '123')
      'abcdef'
      >>> strip_optional_suffix('abcdef', '123', PrintingLogger())
      String ends with 'def', not '123'
      'abcdef'
      """
      if string.endswith(suffix):
          return string[:-len(suffix)]
      if log:
          log.warn('String ends with %r, not %r', string[-len(suffix):], suffix)
      return string