code: def valid_hook(hook_file, hook_name):
      
      filename = os.path.basename(hook_file)
      basename = os.path.splitext(filename)[0]
  
      matching_hook = basename == hook_name
      supported_hook = basename in _HOOKS
      backup_file = filename.endswith('~')
  
      return matching_hook and supported_hook and not backup_file
docs: Determine if a hook file is valid.
  
      :param hook_file: The hook file to consider for validity
      :param hook_name: The hook to find
      :return: The hook file validity