def _check_for_invalid_keys(fname, kwargs, compat_args):
 diff = (set(kwargs) - set(compat_args))
 if diff:
  bad_arg = list(diff)[0]
  raise TypeError("{fname}() got an unexpected keyword argument '{arg}'".format(fname=fname, arg=bad_arg))

def _check_for_invalid_keys ( fname , kwargs , compat_args ) : diff = ( set ( kwargs ) - set ( compat_args ) ) if diff : bad_arg = list ( diff ) [ 0 ] raise TypeError ( "{fname}() got an unexpected keyword argument '{arg}'" . format ( fname = fname , arg = bad_arg ) )
checks whether kwargs contains any keys that are not in compat_args and raises a typeerror if there is one .