def validate_ok_for_update(update):
 validate_is_mapping('update', update)
 if (not update):
  raise ValueError('update only works with $ operators')
 first = next(iter(update))
 if (not first.startswith('$')):
  raise ValueError('update only works with $ operators')

def validate_ok_for_update ( update ) : validate_is_mapping ( 'update' , update ) if ( not update ) : raise ValueError ( 'update only works with $ operators' ) first = next ( iter ( update ) ) if ( not first . startswith ( '$' ) ) : raise ValueError ( 'update only works with $ operators' )
validate an update document .