Skip to content

Commit 4cd8258

Browse files
committed
Remove get_summaries().
1 parent 1f09e67 commit 4cd8258

File tree

4 files changed

+9
-27
lines changed

4 files changed

+9
-27
lines changed

src/pip/_internal/cli/autocompletion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sys
77

88
from pip._internal.cli.main_parser import create_main_parser
9-
from pip._internal.commands import create_command, get_summaries
9+
from pip._internal.commands import commands_dict, create_command
1010
from pip._internal.utils.misc import get_installed_distributions
1111

1212

@@ -23,7 +23,7 @@ def autocomplete():
2323
except IndexError:
2424
current = ''
2525

26-
subcommands = [cmd for cmd, summary in get_summaries()]
26+
subcommands = list(commands_dict)
2727
options = []
2828
# subcommand
2929
try:

src/pip/_internal/cli/main_parser.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@
99
ConfigOptionParser,
1010
UpdatingDefaultsHelpFormatter,
1111
)
12-
from pip._internal.commands import (
13-
commands_dict,
14-
get_similar_commands,
15-
get_summaries,
16-
)
12+
from pip._internal.commands import commands_dict, get_similar_commands
1713
from pip._internal.exceptions import CommandError
1814
from pip._internal.utils.misc import get_pip_version, get_prog
1915
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
@@ -51,8 +47,10 @@ def create_main_parser():
5147
parser.main = True # type: ignore
5248

5349
# create command listing for description
54-
command_summaries = get_summaries()
55-
description = [''] + ['%-27s %s' % (i, j) for i, j in command_summaries]
50+
description = [''] + [
51+
'%-27s %s' % (name, command_info.summary)
52+
for name, command_info in commands_dict.items()
53+
]
5654
parser.description = '\n'.join(description)
5755

5856
return parser

src/pip/_internal/commands/__init__.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
1010

1111
if MYPY_CHECK_RUNNING:
12-
from typing import Any, Iterable, Tuple
12+
from typing import Any
1313
from pip._internal.cli.base_command import Command
1414

1515

@@ -96,13 +96,6 @@ def create_command(name, **kwargs):
9696
return command
9797

9898

99-
def get_summaries():
100-
# type: () -> Iterable[Tuple[str, str]]
101-
"""Yield command (name, summary) tuples in display order."""
102-
for name, command_info in commands_dict.items():
103-
yield (name, command_info.summary)
104-
105-
10699
def get_similar_commands(name):
107100
"""Command name auto-correct."""
108101
from difflib import get_close_matches

tests/unit/test_commands.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from pip._internal.commands import commands_dict, create_command, get_summaries
3+
from pip._internal.commands import commands_dict, create_command
44

55

66
def test_commands_dict__order():
@@ -20,12 +20,3 @@ def test_create_command(name):
2020
command = create_command(name)
2121
assert command.name == name
2222
assert command.summary == commands_dict[name].summary
23-
24-
25-
def test_get_summaries():
26-
actual = list(get_summaries())
27-
for name, summary in actual:
28-
assert summary == commands_dict[name].summary
29-
30-
# Also check that the result is ordered correctly.
31-
assert [item[0] for item in actual] == list(commands_dict)

0 commit comments

Comments
 (0)