mirror of https://github.com/pypa/pip
Simplify ignoring urllib3 warnings
This commit is contained in:
parent
12e63b9def
commit
2f9f91882a
|
@ -4,20 +4,15 @@ from __future__ import absolute_import
|
|||
import locale
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
import sys
|
||||
|
||||
# 2016-06-17 barry@debian.org: urllib3 1.14 added optional support for socks,
|
||||
# but if invoked (i.e. imported), it will issue a warning to stderr if socks
|
||||
# isn't available. requests unconditionally imports urllib3's socks contrib
|
||||
# module, triggering this warning. The warning breaks DEP-8 tests (because of
|
||||
# the stderr output) and is just plain annoying in normal usage. I don't want
|
||||
# to add socks as yet another dependency for pip, nor do I want to allow-stderr
|
||||
# in the DEP-8 tests, so just suppress the warning. pdb tells me this has to
|
||||
# be done before the import of pip.vcs.
|
||||
from pip._vendor.urllib3.exceptions import DependencyWarning
|
||||
warnings.filterwarnings("ignore", category=DependencyWarning) # noqa
|
||||
# We ignore certain warnings from urllib3, since they are not relevant to pip's
|
||||
# usecases.
|
||||
from pip._vendor.urllib3.exceptions import (
|
||||
DependencyWarning,
|
||||
InsecureRequestWarning,
|
||||
)
|
||||
|
||||
import pip._internal.utils.inject_securetransport # noqa
|
||||
from pip._internal.cli.autocompletion import autocomplete
|
||||
|
@ -25,13 +20,16 @@ from pip._internal.cli.main_parser import parse_command
|
|||
from pip._internal.commands import create_command
|
||||
from pip._internal.exceptions import PipError
|
||||
from pip._internal.utils import deprecation
|
||||
from pip._vendor.urllib3.exceptions import InsecureRequestWarning
|
||||
|
||||
# Raised when using --trusted-host.
|
||||
warnings.filterwarnings("ignore", category=InsecureRequestWarning)
|
||||
# Raised since socks support depends on PySocks, which may not be installed.
|
||||
# Barry Warsaw noted (on 2016-06-17) that this should be done before
|
||||
# importing pip.vcs, which has since moved to pip._internal.vcs.
|
||||
warnings.filterwarnings("ignore", category=DependencyWarning)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Hide the InsecureRequestWarning from urllib3
|
||||
warnings.filterwarnings("ignore", category=InsecureRequestWarning)
|
||||
|
||||
|
||||
def main(args=None):
|
||||
if args is None:
|
||||
|
|
Loading…
Reference in New Issue