parameters: (self, *args, **kwargs)
docstring: :param trusted_hosts: Domains not to emit warnings for when not using
  
              HTTPS.
function: def __init__(self, *args, **kwargs):
  
          """
  
          :param trusted_hosts: Domains not to emit warnings for when not using
  
              HTTPS.
  
          """
  
          retries = kwargs.pop("retries", 0)
  
          cache = kwargs.pop("cache", None)
  
          trusted_hosts = kwargs.pop("trusted_hosts", [])  # type: List[str]
  
          index_urls = kwargs.pop("index_urls", None)
  
  
  
          super().__init__(*args, **kwargs)
  
  
  
          # Namespace the attribute with "pip_" just in case to prevent
  
          # possible conflicts with the base class.
  
          self.pip_trusted_origins = []  # type: List[Tuple[str, Optional[int]]]
  
  
  
          # Attach our User Agent to the request
  
          self.headers["User-Agent"] = user_agent()
  
  
  
          # Attach our Authentication handler to the session
  
          self.auth = MultiDomainBasicAuth(index_urls=index_urls)
  
  
  
          # Create our urllib3.Retry instance which will allow us to customize
  
          # how we handle retries.
  
          retries = urllib3.Retry(
  
              # Set the total number of retries that a particular request can
  
              # have.
  
              total=retries,
  
  
  
              # A 503 error from PyPI typically means that the Fastly -> Origin
  
              # connection got interrupted in some way. A 503 error in general
  
              # is typically considered a transient error so we'll go ahead and
  
              # retry it.
  
              # A 500 may indicate transient error in Amazon S3
  
              # A 520 or 527 - may indicate transient error in CloudFlare
  
              status_forcelist=[500, 503, 520, 527],
  
  
  
              # Add a small amount of back off between failed requests in
  
              # order to prevent hammering the service.
  
              backoff_factor=0.25,
  
          )
  
  
  
          # Our Insecure HTTPAdapter disables HTTPS validation. It does not
  
          # support caching so we'll use it for all http:// URLs.
  
          # If caching is disabled, we will also use it for
  
          # https:// hosts that we've marked as ignoring
  
          # TLS errors for (trusted-hosts).
  
          insecure_adapter = InsecureHTTPAdapter(max_retries=retries)
  
  
  
          # We want to _only_ cache responses on securely fetched origins or when
  
          # the host is specified as trusted. We do this because
  
          # we can't validate the response of an insecurely/untrusted fetched
  
          # origin, and we don't want someone to be able to poison the cache and
  
          # require manual eviction from the cache to fix it.
  
          if cache:
  
              secure_adapter = CacheControlAdapter(
  
                  cache=SafeFileCache(cache),
  
                  max_retries=retries,
  
              )
  
              self._trusted_host_adapter = InsecureCacheControlAdapter(
  
                  cache=SafeFileCache(cache),
  
                  max_retries=retries,
  
              )
  
          else:
  
              secure_adapter = HTTPAdapter(max_retries=retries)
  
              self._trusted_host_adapter = insecure_adapter
  
  
  
          self.mount("https://", secure_adapter)
  
          self.mount("http://", insecure_adapter)
  
  
  
          # Enable file:// urls
  
          self.mount("file://", LocalFSAdapter())
  
  
  
          for host in trusted_hosts:
  
              self.add_trusted_host(host, suppress_logging=True)
function_tokens: def __init__ ( self , * args , * * kwargs ) : retries = kwargs . pop ( "retries" , 0 ) cache = kwargs . pop ( "cache" , None ) trusted_hosts = kwargs . pop ( "trusted_hosts" , [ ] ) # type: List[str] index_urls = kwargs . pop ( "index_urls" , None ) super ( ) . __init__ ( * args , * * kwargs ) # Namespace the attribute with "pip_" just in case to prevent # possible conflicts with the base class. self . pip_trusted_origins = [ ] # type: List[Tuple[str, Optional[int]]] # Attach our User Agent to the request self . headers [ "User-Agent" ] = user_agent ( ) # Attach our Authentication handler to the session self . auth = MultiDomainBasicAuth ( index_urls = index_urls ) # Create our urllib3.Retry instance which will allow us to customize # how we handle retries. retries = urllib3 . Retry ( # Set the total number of retries that a particular request can # have. total = retries , # A 503 error from PyPI typically means that the Fastly -> Origin # connection got interrupted in some way. A 503 error in general # is typically considered a transient error so we'll go ahead and # retry it. # A 500 may indicate transient error in Amazon S3 # A 520 or 527 - may indicate transient error in CloudFlare status_forcelist = [ 500 , 503 , 520 , 527 ] , # Add a small amount of back off between failed requests in # order to prevent hammering the service. backoff_factor = 0.25 , ) # Our Insecure HTTPAdapter disables HTTPS validation. It does not # support caching so we'll use it for all http:// URLs. # If caching is disabled, we will also use it for # https:// hosts that we've marked as ignoring # TLS errors for (trusted-hosts). insecure_adapter = InsecureHTTPAdapter ( max_retries = retries ) # We want to _only_ cache responses on securely fetched origins or when # the host is specified as trusted. We do this because # we can't validate the response of an insecurely/untrusted fetched # origin, and we don't want someone to be able to poison the cache and # require manual eviction from the cache to fix it. if cache : secure_adapter = CacheControlAdapter ( cache = SafeFileCache ( cache ) , max_retries = retries , ) self . _trusted_host_adapter = InsecureCacheControlAdapter ( cache = SafeFileCache ( cache ) , max_retries = retries , ) else : secure_adapter = HTTPAdapter ( max_retries = retries ) self . _trusted_host_adapter = insecure_adapter self . mount ( "https://" , secure_adapter ) self . mount ( "http://" , insecure_adapter ) # Enable file:// urls self . mount ( "file://" , LocalFSAdapter ( ) ) for host in trusted_hosts : self . add_trusted_host ( host , suppress_logging = True )