Skip to content

Commit 752ba0f

Browse files
authored
Merge branch 'main' into make-mypy-nox-session
2 parents 3b80e14 + 18694f6 commit 752ba0f

17 files changed

+158
-48
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# Byte-compiled / optimized / DLL files
1+
# Byte-compiled files
22
__pycache__/
3-
*.py[cod]
43
*$py.class
54

65
# Distribution / packaging

news/10915.bugfix.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Suppress the progress bar, when running with ``--log`` and ``--quiet``.
2+
3+
Consequently, a new ``auto`` mode for ``--progress-bar`` has been added.
4+
``auto`` will enable progress bars unless suppressed by ``--quiet``,
5+
while ``on`` will always enable progress bars.

news/12099.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
``pip config debug`` now correctly separates options as set by the different files
2+
at the same level.

news/13464.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Automatic download resumption and retrying is enabled by default.

news/627ddbb6-5268-4fd9-b04b-0485abc35295.trivial.rst

Whitespace-only changes.

src/pip/_internal/cli/base_command.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ def _main(self, args: list[str]) -> int:
176176
if options.debug_mode:
177177
self.verbosity = 2
178178

179+
if hasattr(options, "progress_bar") and options.progress_bar == "auto":
180+
options.progress_bar = "on" if self.verbosity >= 0 else "off"
181+
179182
reconfigure(no_color=options.no_color)
180183
level_number = setup_logging(
181184
verbosity=self.verbosity,

src/pip/_internal/cli/cmdoptions.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,13 @@ class PipOption(Option):
228228
"--progress-bar",
229229
dest="progress_bar",
230230
type="choice",
231-
choices=["on", "off", "raw"],
232-
default="on",
233-
help="Specify whether the progress bar should be used [on, off, raw] (default: on)",
231+
choices=["auto", "on", "off", "raw"],
232+
default="auto",
233+
help=(
234+
"Specify whether the progress bar should be used. In 'auto'"
235+
" mode, --quiet will suppress all progress bars."
236+
" [auto, on, off, raw] (default: auto)"
237+
),
234238
)
235239

236240
log: Callable[..., Option] = partial(
@@ -290,7 +294,7 @@ class PipOption(Option):
290294
"--resume-retries",
291295
dest="resume_retries",
292296
type="int",
293-
default=0,
297+
default=5,
294298
help="Maximum attempts to resume or restart an incomplete download. "
295299
"(default: %default)",
296300
)

src/pip/_internal/cli/parser.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -188,23 +188,24 @@ def _get_ordered_configuration_items(
188188
section_items: dict[str, list[tuple[str, Any]]] = {
189189
name: [] for name in override_order
190190
}
191-
for section_key, val in self.config.items():
192-
# ignore empty values
193-
if not val:
194-
logger.debug(
195-
"Ignoring configuration key '%s' as it's value is empty.",
196-
section_key,
197-
)
198-
continue
199191

200-
section, key = section_key.split(".", 1)
201-
if section in override_order:
202-
section_items[section].append((key, val))
192+
for _, value in self.config.items(): # noqa: PERF102
193+
for section_key, val in value.items():
194+
# ignore empty values
195+
if not val:
196+
logger.debug(
197+
"Ignoring configuration key '%s' as its value is empty.",
198+
section_key,
199+
)
200+
continue
201+
202+
section, key = section_key.split(".", 1)
203+
if section in override_order:
204+
section_items[section].append((key, val))
203205

204-
# Yield each group in their override order
205-
for section in override_order:
206-
for key, val in section_items[section]:
207-
yield key, val
206+
# Yield each group in their override order
207+
for section in override_order:
208+
yield from section_items[section]
208209

209210
def _update_defaults(self, defaults: dict[str, Any]) -> dict[str, Any]:
210211
"""Updates the given defaults with values from the config files and

src/pip/_internal/cli/progress_bars.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import functools
44
import sys
55
from collections.abc import Generator, Iterable, Iterator
6-
from typing import Callable, TypeVar
6+
from typing import Callable, Literal, TypeVar
77

88
from pip._vendor.rich.progress import (
99
BarColumn,
@@ -25,12 +25,13 @@
2525

2626
T = TypeVar("T")
2727
ProgressRenderer = Callable[[Iterable[T]], Iterator[T]]
28+
BarType = Literal["on", "off", "raw"]
2829

2930

3031
def _rich_download_progress_bar(
3132
iterable: Iterable[bytes],
3233
*,
33-
bar_type: str,
34+
bar_type: BarType,
3435
size: int | None,
3536
initial_progress: int | None = None,
3637
) -> Generator[bytes, None, None]:
@@ -112,7 +113,7 @@ def write_progress(current: int, total: int) -> None:
112113

113114

114115
def get_download_progress_renderer(
115-
*, bar_type: str, size: int | None = None, initial_progress: int | None = None
116+
*, bar_type: BarType, size: int | None = None, initial_progress: int | None = None
116117
) -> ProgressRenderer[bytes]:
117118
"""Get an object that can be used to render the download progress.
118119
@@ -136,7 +137,7 @@ def get_download_progress_renderer(
136137

137138

138139
def get_install_progress_renderer(
139-
*, bar_type: str, total: int
140+
*, bar_type: BarType, total: int
140141
) -> ProgressRenderer[InstallRequirement]:
141142
"""Get an object that can be used to render the install progress.
142143
Returns a callable, that takes an iterable to "wrap".

src/pip/_internal/commands/configuration.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ def list_values(self, options: Values, args: list[str]) -> None:
177177
self._get_n_args(args, "list", n=0)
178178

179179
for key, value in sorted(self.configuration.items()):
180-
write_output("%s=%r", key, value)
180+
for key, value in sorted(value.items()):
181+
write_output("%s=%r", key, value)
181182

182183
def get_name(self, options: Values, args: list[str]) -> None:
183184
key = self._get_n_args(args, "get [name]", n=1)
@@ -211,13 +212,15 @@ def list_config_values(self, options: Values, args: list[str]) -> None:
211212
file_exists = os.path.exists(fname)
212213
write_output("%s, exists: %r", fname, file_exists)
213214
if file_exists:
214-
self.print_config_file_values(variant)
215+
self.print_config_file_values(variant, fname)
215216

216-
def print_config_file_values(self, variant: Kind) -> None:
217+
def print_config_file_values(self, variant: Kind, fname: str) -> None:
217218
"""Get key-value pairs from the file of a variant"""
218219
for name, value in self.configuration.get_values_in_config(variant).items():
219220
with indent_log():
220-
write_output("%s: %s", name, value)
221+
if name == fname:
222+
for confname, confvalue in value.items():
223+
write_output("%s: %s", confname, confvalue)
221224

222225
def print_env_var_values(self) -> None:
223226
"""Get key-values pairs present as environment variables"""

0 commit comments

Comments
 (0)