Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show deprecation warning against --trusted-host with port part. #6710

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/6705.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Show deprecation warning against ``--trusted-host`` with port part.
19 changes: 18 additions & 1 deletion src/pip/_internal/cli/cmdoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
from optparse import SUPPRESS_HELP, Option, OptionGroup
from textwrap import dedent

from pip._vendor.six.moves.urllib import parse as urllib_parse

from pip._internal.exceptions import CommandError
from pip._internal.locations import USER_CACHE_DIR, src_prefix
from pip._internal.models.format_control import FormatControl
from pip._internal.models.index import PyPI
from pip._internal.models.search_scope import SearchScope
from pip._internal.models.target_python import TargetPython
from pip._internal.utils.deprecation import deprecated
from pip._internal.utils.hashes import STRONG_HASHES
from pip._internal.utils.misc import redact_password_from_url
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
Expand Down Expand Up @@ -378,13 +381,27 @@ def make_search_scope(options, suppress_no_index=False):
return search_scope


def _handle_trusted_host(option, opt_str, value, parser):
# type: (Option, str, str, OptionParser) -> None
if urllib_parse.urlparse("//{}/".format(value)).port:
deprecated(
"--trusted-host no longer needs port part with it.",
replacement=None,
gone_in=None,
issue=6705
)
parser.values.trusted_hosts.append(value)


def trusted_host():
# type: () -> Option
return Option(
"--trusted-host",
dest="trusted_hosts",
action="append",
metavar="HOSTNAME",
type="string",
action="callback",
callback=_handle_trusted_host,
default=[],
help="Mark this host as trusted, even though it does not have valid "
"or any HTTPS.",
Expand Down