(file, check)
return file_uses_http_wrapper, has_failed, None
Return true if the file uses the http wrapper class.
    Also outputs every instance of deprecated request library function use

    file -- filepath of file to validate
    check -- name of the check
Return true if the file uses the http wrapper class.
    Also outputs every instance of deprecated request library function use
Return true if the file uses the http wrapper class . Also outputs every instance of deprecated request library function use
def validate_use_http_wrapper_file(file, check):
    """Return true if the file uses the http wrapper class.
    Also outputs every instance of deprecated request library function use

    file -- filepath of file to validate
    check -- name of the check
    """
    file_uses_http_wrapper = False
    has_failed = False
    with open(file, 'r', encoding='utf-8') as f:
        read_file = f.read()
        found_match_arg = re.search(r"auth=|header=", read_file)
        found_http = re.search(r"self.http|OpenMetricsBaseCheck", read_file)
        skip_validation = re.search(r"SKIP_HTTP_VALIDATION", read_file)
        if found_http and not skip_validation:
            return found_http, has_failed, found_match_arg

        http_func = re.search(REQUEST_LIBRARY_FUNC_RE, read_file)
        if http_func:
            echo_failure(
                f'Check `{check}` uses `{http_func}` in `{os.path.basename(file)}`, '
                f'please use the HTTP wrapper instead'
            )
            annotate_error(
                file,
                "Detected use of `{}`, please use the HTTP wrapper instead".format(http_func),
            )
            return False, True, None

    return file_uses_http_wrapper, has_failed, None
def validate_use_http_wrapper_file ( file , check ) : file_uses_http_wrapper = False has_failed = False with open ( file , 'r' , encoding = 'utf-8' ) as f : read_file = f . read ( ) found_match_arg = re . search ( r"auth=|header=" , read_file ) found_http = re . search ( r"self.http|OpenMetricsBaseCheck" , read_file ) skip_validation = re . search ( r"SKIP_HTTP_VALIDATION" , read_file ) if found_http and not skip_validation : return found_http , has_failed , found_match_arg http_func = re . search ( REQUEST_LIBRARY_FUNC_RE , read_file ) if http_func : echo_failure ( f'Check `{check}` uses `{http_func}` in `{os.path.basename(file)}`, ' f'please use the HTTP wrapper instead' ) annotate_error ( file , "Detected use of `{}`, please use the HTTP wrapper instead" . format ( http_func ) , ) return False , True , None return file_uses_http_wrapper , has_failed , None