code: def _assert_expandable(repl, use_format=False):
      
  
      if isinstance(repl, ReplaceTemplate):
          if repl.use_format != use_format:
              if use_format:
                  raise ValueError("Replace not compiled as a format replace")
              else:
                  raise ValueError("Replace should not be compiled as a format replace!")
      elif not isinstance(repl, (str, bytes)):
          raise TypeError("Expected string, buffer, or compiled replace!")
docs: Check if replace template is expandable.