def should_bypass_proxies(url):
 get_proxy = (lambda k: (os.environ.get(k) or os.environ.get(k.upper())))
 no_proxy = get_proxy('no_proxy')
 netloc = urlparse(url).netloc
 if no_proxy:
  no_proxy = no_proxy.replace(' ', '').split(',')
  ip = netloc.split(':')[0]
  if is_ipv4_address(ip):
   for proxy_ip in no_proxy:
    if is_valid_cidr(proxy_ip):
     if address_in_network(ip, proxy_ip):
      return True
  else:
   for host in no_proxy:
    if (netloc.endswith(host) or netloc.split(':')[0].endswith(host)):
     return True
 try:
  bypass = proxy_bypass(netloc)
 except (TypeError, socket.gaierror):
  bypass = False
 if bypass:
  return True
 return False

def should_bypass_proxies ( url ) : get_proxy = ( lambda k : ( os . environ . get ( k ) or os . environ . get ( k . upper ( ) ) ) ) no_proxy = get_proxy ( 'no_proxy' ) netloc = urlparse ( url ) . netloc if no_proxy : no_proxy = no_proxy . replace ( ' ' , '' ) . split ( ',' ) ip = netloc . split ( ':' ) [ 0 ] if is_ipv4_address ( ip ) : for proxy_ip in no_proxy : if is_valid_cidr ( proxy_ip ) : if address_in_network ( ip , proxy_ip ) : return True else : for host in no_proxy : if ( netloc . endswith ( host ) or netloc . split ( ':' ) [ 0 ] . endswith ( host ) ) : return True try : bypass = proxy_bypass ( netloc ) except ( TypeError , socket . gaierror ) : bypass = False if bypass : return True return False
returns whether we should bypass proxies or not .