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

list: disable pip version self check unless given --outdated/--uptodate #12568

Closed
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/11677.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``pip list`` no longer performs the pip version check unless ``--outdated`` or ``--uptodate`` is given.
10 changes: 9 additions & 1 deletion src/pip/_internal/cli/req_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ class IndexGroupCommand(Command, SessionCommandMixin):
This also corresponds to the commands that permit the pip version check.
"""

def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
self.allow_pip_version_check = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes this class a little bit at odds with its docstring.


def handle_pip_version_check(self, options: Values) -> None:
"""
Do the pip version check if not disabled.
Expand All @@ -170,7 +174,11 @@ def handle_pip_version_check(self, options: Values) -> None:
# Make sure the index_group options are present.
assert hasattr(options, "no_index")

if options.disable_pip_version_check or options.no_index:
if (
options.disable_pip_version_check
or options.no_index
or not self.allow_pip_version_check
):
return

# Otherwise, check if we're using the latest version of pip available.
Expand Down
1 change: 1 addition & 0 deletions src/pip/_internal/commands/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def _build_package_finder(
)

def run(self, options: Values, args: List[str]) -> int:
self.allow_pip_version_check = options.outdated or options.uptodate
if options.outdated and options.uptodate:
raise CommandError("Options --outdated and --uptodate cannot be combined.")

Expand Down
Loading