def validate_ok_for_replace(replacement):
 validate_is_mapping('replacement', replacement)
 if (replacement and (not isinstance(replacement, RawBSONDocument))):
  first = next(iter(replacement))
  if first.startswith('$'):
   raise ValueError('replacement can not include $ operators')

def validate_ok_for_replace ( replacement ) : validate_is_mapping ( 'replacement' , replacement ) if ( replacement and ( not isinstance ( replacement , RawBSONDocument ) ) ) : first = next ( iter ( replacement ) ) if first . startswith ( '$' ) : raise ValueError ( 'replacement can not include $ operators' )
validate a replacement document .